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
86
87
88
89
90
91
92
|
# This file is for playing with syntax and seeing what works and what does not.
## TEST 1 - newlines seperate statements, not ;
## newlines can be escaped with \
/; test1
int main = 0
/; loop (int i = 0, i < 5) [i++]
tnsl.io.println("Hi!")
;/
String str = {}
/; loop (char j = ' ', j != 'k') \
[j++]
str.append(j)
;/
tnsl.io.println(str)
return main
;/
## END TEST 1
##
## Thoughts: this is much better.
## TEST 2 - get '.' augment auto de-references pointers
struct a {
int i, j
}
struct b {
String str,
~a ints
}
/; ptr_test1
b str_b = {"Hello", {0, 1}}
~b ptr_b = ~str_b
tnsl.io.println(ptr_b.str)
# vs
tnsl.io.println(ptr_b`.str)
# both work
ptr_b.ints.i = 12
ptr_b.ints.j = ptr_b.ints.i / 4
# vs
ptr_b`.ints`.i = 12
ptr_b`.ints`.j = ptr_b`.ints`.i / 4
# Again, the second one is more descriptive, but is it better?
ptr_call(ptr_b)
ref_call(ptr_b)
;/
/; ptr_call (~b ptr)
ptr.ints.i = 8
;/
/; ref_call (b` ref)
ref.ints.j = 9
;/
## END TEST 2
##
## Thoughts: not sure, the . operator could become a little too ambiguous if this is added
## Test 3: using [] for array indexing instead of {}
:include "tnsl"
:using "tnsl"
/; main ({}String args) [int]
int i = len args
String first = args[0]
{}int list = {0, 1, 2, 3}
i = list[2]
return i
;/
## End test 3
##
## Thoughts: I'm not sure weather I like it better or not.
|