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