-
Notifications
You must be signed in to change notification settings - Fork 0
/
code2.lisp
69 lines (51 loc) · 1.23 KB
/
code2.lisp
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
/**
macro functions get the entire AST list behind its initial keyword
ie
*/
macro removefirst x [
//macro body
tail x
]
ignore [removefirst 1 2 3]
/*
gets turned into
ignore [2 3]
This allows for complex macros to operate on entire subsections of code and create powerfull DSL
Is/will be used to implement recursive functions
Is/will be used to implement argMacro (a macro with specific numbers of args)
*/
macro argMacro x [
let arglist [head x]
let body [head [tail x]]
let rest [tail [tail x]]
quote NotImplemented
]
argMacro ' [followingList] [
[list [quote quote [followinglist]]]
]
//random ass comment
macro if [condition _then option1 _else option2] [
list ['cond condition option1 option2]
]
macro func [somename arguments body] /* inline comments*/ [
let x [some calculation] //wordt uitgevoert in de macro
list ['let somename [lambda arguments body]]
]
func somename [arg1 arg2] [
macro dummy [test test2] [
]
ignore [print arg1]
let someshit [some calculation]
ignore [print arg2]
sum [list [1,2,3,4]]
]
let x [
sum 1 [
let z 6
argMacro y [] [
list [z]
]
sum 3 y
]
]
somename "some" "string\n"