| 1 | import math { max, min } |
| 2 | import cli { Command } |
| 3 | import math.complex { Complex, complex } |
| 4 | import os { |
| 5 | file_ext, |
| 6 | user_os, |
| 7 | } |
| 8 | import mod { |
| 9 | AliasTarget, |
| 10 | Enum, |
| 11 | FnAliasParam, |
| 12 | FnAliasRet, |
| 13 | FnArg, |
| 14 | FnArgGeneric, |
| 15 | FnArgTypeParam1, |
| 16 | FnArgTypeParam2, |
| 17 | FnArgVariadic, |
| 18 | FnRet, |
| 19 | FnRetGeneric, |
| 20 | FnRetTypeParam1, |
| 21 | FnRetTypeParam2, |
| 22 | InterfaceField, |
| 23 | InterfaceMethodArg, |
| 24 | InterfaceMethodRet, |
| 25 | RightOfAs, |
| 26 | RightOfIs, |
| 27 | StructArrayFieldElem, |
| 28 | StructEmbed, |
| 29 | StructField, |
| 30 | StructFixedArrayFieldElem, |
| 31 | StructMapFieldKey, |
| 32 | StructMapFieldValue, |
| 33 | StructMethodArg, |
| 34 | StructMethodArgGeneric, |
| 35 | StructMethodRet, |
| 36 | StructMethodRetGeneric, |
| 37 | StructRefField, |
| 38 | SumVariant1, |
| 39 | SumVariant2, |
| 40 | } |
| 41 | |
| 42 | type Alias = AliasTarget |
| 43 | type SumType = SumVariant1 | SumVariant2 |
| 44 | type Fn = fn (FnAliasParam) FnAliasRet |
| 45 | |
| 46 | struct Struct { |
| 47 | StructEmbed |
| 48 | v StructField |
| 49 | ref &StructRefField |
| 50 | map map[StructMapFieldKey]StructMapFieldValue |
| 51 | arr []StructArrayFieldElem |
| 52 | arr_fixed [2]StructFixedArrayFieldElem |
| 53 | } |
| 54 | |
| 55 | fn (s Struct) method(v StructMethodArg) StructMethodRet { |
| 56 | return StructMethodRet{} |
| 57 | } |
| 58 | |
| 59 | fn (s Struct) method_generic[T](v StructMethodArgGeneric[T]) StructMethodRetGeneric[T] { |
| 60 | return StructMethodRet[T]{} |
| 61 | } |
| 62 | |
| 63 | interface Interface { |
| 64 | v InterfaceField |
| 65 | f(InterfaceMethodArg) InterfaceMethodRet |
| 66 | } |
| 67 | |
| 68 | fn f(v FnArg, vv ...FnArgVariadic) FnRet { |
| 69 | if v is RightOfIs { |
| 70 | } |
| 71 | _ = v as RightOfAs |
| 72 | |
| 73 | println(Enum.val) |
| 74 | |
| 75 | return FnRet{} |
| 76 | } |
| 77 | |
| 78 | fn f2(v Generic[FnArgTypeParam1, FnArgTypeParam2]) Generic[FnRetTypeParam1, FnRetTypeParam2] {} |
| 79 | |
| 80 | fn f_generic[T](v FnArgGeneric[T]) FnRetGeneric[T] { |
| 81 | return FnRetGeneric[T]{} |
| 82 | } |
| 83 | |
| 84 | struct App { |
| 85 | command &Command |
| 86 | } |
| 87 | |
| 88 | struct MyCommand { |
| 89 | Command |
| 90 | } |
| 91 | |
| 92 | fn imaginary(im f64) Complex { |
| 93 | return complex(0, im) |
| 94 | } |
| 95 | |
| 96 | fn main() { |
| 97 | println(max(0.1, 0.2)) |
| 98 | println(min(0.1, 0.2)) |
| 99 | println(user_os()) |
| 100 | println(file_ext('main.v')) |
| 101 | println(imaginary(1)) |
| 102 | } |
| 103 | |