Minimal (?) protype-based language.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 

208 Zeilen
4.0 KiB

nil 42 3.140000 string Symbol newline
Object => <Object>
Lambda => <Lambda>
Closure => <Closure>
o = Object.new() => <<Object>>
o = Object.new(foo:42, bar: 666) => <<Object>>
| bar: 666
| foo: 42
o.foo => 42
Point.new() => <<Point>>
Point.new(x: 3, y: 4) => <<Point>>
| y: 4
| x: 3
twice 21 is 42
double => <<Closure>>
| environment: nil
| function: <<Lambda>>
| | body: <<Object>>
| | | 0: <<Binop>>
| | | | operation: 13
| | | | 0: <<GetVar>>
| | | | | name: x
| | | | 1: <<GetVar>>
| | | | | name: x
| | parameters: <<Object>>
| | | 0: x
Point.new(x:3, y:4).magnitude() => 5.000000
<<?>>
| self: nil =>
| self: nil
| n: 39
| 0: 40
40
<<?>>
| self: nil =>
| self: nil
| n: 40
| 0: 40
41
<<?>>
| self: nil =>
| self: nil
| n: 41
| 0: 40
42
<<?>>
| self: nil =>
| self: nil
| n: 42
| 0: 40
43
nil no
1 yes
hello yes
15
1973
42 42 42 42
ok
ok
42
----
MyType.__eval__() invoked
42
<<Closure>>
====
42
hello
nil
<Undefined>
<Object>
nil
[KEY: __delegate__
KEY: y
KEY: x
]
Symbol
<Symbol>
<Object>
nil
POINT <Point>
P <<Object>>
P <<Point>>
Q <<Point>>
P.mag 13.000000
<<Object>>
| bar: 666
| foo: 42
| 0: 1
| 1: <<Object>>
| | 0: 2
| | 1: 3
| | 2: 42
[KEY: __delegate__
KEY: bar
KEY: foo
]
5
7
0
1
2
0
1
0: a
2
0: a
1: b
3
0: a
1: b
2: c
12
0: 104
1: 101
2: 108
3: 108
4: 111
5: 44
6: 32
7: 119
8: 111
9: 114
10: 108
11: 100
hello, world
hallo, world
hally, world
hally, wirld
READ = f() { print(__env__()) }
f();
0 30 t
<<Stream>>
f 102 ( 40 ) 41 32 { 123 32 p 112 r 114 i 105 n 110 t 116 ( 40 _ 95 _ 95 e 101 n 110 v 118 _ 95 _ 95 ( 40 ) 41 ) 41 32 } 125
10 f 102 ( 40 ) 41 ; 59
10
<<Binop>>
| operation: 15
| 0: 6
| 1: 7
42
42
6 * 7
MACRO table <<Object>>
| test: <<Closure>>
| | environment: nil
| | function: <<Lambda>>
| | | body: <<Object>>
| | | | 0: <<Call>>
| | | | | arguments: <<Object>>
| | | | | | 0: MACRO EVAL test with
| | | | | | 1: <<GetVar>>
| | | | | | | name: x
| | | | | | 2: and
| | | | | | 3: <<GetVar>>
| | | | | | | name: y
| | | | | | 4:
| | | | | function: <<GetVar>>
| | | | | | name: print
| | | | 1: <<Unyop>>
| | | | | operation: 3
| | | | | 0: <<Block>>
| | | | | | body: <<Object>>
| | | | | | | 0: <<Call>>
| | | | | | | | arguments: <<Object>>
| | | | | | | | | 0: REPLACEMENT
| | | | | | | | | 1: <<Unyop>>
| | | | | | | | | | operation: 4
| | | | | | | | | | 0: <<GetVar>>
| | | | | | | | | | | name: x
| | | | | | | | | 2:
| | | | | | | | function: <<GetVar>>
| | | | | | | | | name: print
| | | | | | | 1: <<Unyop>>
| | | | | | | | operation: 4
| | | | | | | | 0: <<GetVar>>
| | | | | | | | | name: y
| | | parameters: <<Object>>
| | | | 0: x
| | | | 1: y
define testfun
MACRO EVAL test with 1 and 2
MACRO EVAL test with three and four
call testfun
REPLACEMENT 1
REPLACEMENT three
MakeSeven.__eval__ invoked
AST eval => 42
0 1 2 3 4 5 6 7 8 9 10
10 9 8 7 6 5 4 3 2 1 0
0 1 2 3 4 5 6 7 8 9
65 66 67 68 69
1 two 3 four
test.txt:346: *: illegal operand types Integer and String
11: n * factorial(n - 1)
10: if (n < 2) "1" else n * factorial(n - 1)
9: factorial(n - 1)
8: n * factorial(n - 1)
7: if (n < 2) "1" else n * factorial(n - 1)
6: factorial(n - 1)
5: n * factorial(n - 1)
4: if (n < 2) "1" else n * factorial(n - 1)
3: factorial(n - 1)
2: n * factorial(n - 1)
1: if (n < 2) "1" else n * factorial(n - 1)
0: factorial(5)