-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.wolf
More file actions
34 lines (27 loc) · 907 Bytes
/
Copy pathbasic.wolf
File metadata and controls
34 lines (27 loc) · 907 Bytes
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
;; import expression (import <modules>...)
(import io)
;; type expression (type <name> <primitives or user defined types>)
(type Wolf (struct
;; variable expression (var <name>: <type> <val>(optional))
(let size: int)
;; function expression (def <name> <params> <return type> <expressions>)
;; param expression (<name>: <type>)
(def new (size: int) Self ( ;; functions named new
(= self.size size)
))
(def bark () nil (
;; if expression (if <condition> <expressions>)
(if (and (>= self.size 0) (< self.size 50)) (
;; call expression (call <function name> <args>...)
(call io.println "Bark!")
)
elseif (>= self.size 50) (
(call io.println "Big bark!")
)
else (
(call io.println "Little bark")
))
))
))
(let wolf: Wolf (call Wolf.new 48))
(call wolf.bark)