-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.si
85 lines (63 loc) · 2.71 KB
/
test.si
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import silver
import console
mod simple-two [
int var2: 1
int method2[int arg] [ return var2 + arg ]
]
proto key
object data
u64 hash[]
return data.hash # method call, with no-args we never-provide '[]', only definitions (thats an error in silver)
key[ object data ]
# express your primitives with mod
# these types of mods with described data are virtually-instanced in any value reference
# we write over the user's scope, thats what inlay is for and only for things like this
# its best not let the user do it, its best done by the designer
# any value given that reduces bits covered will not be warned by default,
# however can be changed to more strict type checks with --strict
# two modes are better than one
# map has these args in a constructor, and template args here will flow into map there
# express observing proto'd args (for key, value is any at all)
template [ K:key, V:object ]
inlay alias V[K]: map
# the single letter variable names in upper case as Template args; i think its ok for generics
# when its upper case you can further define what sort of incoming type it is:traits
# it may replace all of these with a simple object or type
# the main thing, is i dont want templated types cluttering up memory. i dont think it will save time it will cost time.
# even exec wouldnt be that much better in majority of cases
# the idea is to save code bloat creation, and show how flexible the language is
mod map
map [ K:key, V:object ] # you will always have different letters in these types, so one can use them as
# without constructors, we have more options for init. correct?
#
mod simple {
int var: 1
int[] ar: [1, 2, 3, 4]
string[int] map: [0:'one', 100:'two']
map::int::string map2: ['one':2, 'two':102]
init [
# post-init here
# everything is named args, and arrays are elements
map2 = ['key-object': 'value-object'] # the meta would need some influence on type conversion
]
int func[ int arg, short arg2 ] [ return arg + arg2 ]
simple[ int var, int[] ar ]
# automatic: [ var : var, ar : ar ]
# redundant, it sets these automatically if there is a type and name binding in membership
# but then you dont have a function block so you cant do anything else
# declare does it for you if a simple set is all you need
# in silver, no method body means automatic
int method[] [
simple-two state
return var + state.method2[1]
]
}
mod app [
int int_argument : 1
string[] strings : ["default"]
simple simpleton : [2, [2,3,4,5]]
int run[] [
console.log['int argument is {int_argument}, and strings is {strings}']
return 0
]
]