smalltalk-tng
view r3/barewords.tng @ 323:454c18798969
merger
| author | Tony Garnock-Jones <tonygarnockjones@gmail.com> |
|---|---|
| date | Tue Feb 07 11:34:20 2012 -0500 (3 months ago) |
| parents | |
| children |
line source
1 define [
2 .proto: [.list: .nil]
4 (x=[.list: _] .initialize: aList):
5 (x \ [.list: aList])
7 (x=[.list: l] .with: aThing):
8 (x \ [.list: (l .with: aThing)])
10 (x=[.list: l] .handle):
11 (l .do: [eachItem: eachItem .print])
12 ];;
15 define [
16 proto: [list: nil]
18 (.x=[list: _] initialize: .aList):
19 (.x \ [list: .aList])
21 (.x=[list: .l] with: .aThing):
22 (.x \ [list: (.l with: .aThing)])
24 (.x=[list: .l] handle):
25 (.l do: [.eachItem: .eachItem print])
26 ];;
29 "
30 The problem is really barewords. (Or applications, if you want to look at it that way.)
31 What if application got syntax? f $ x
32 $ looks like S, for Send
34 We need to do something about bindings, too.
35 var=pattern ?
36 var@pattern ?
37 "
39 define [
40 proto: [list: nil]
42 (x=[list: _] initialize: aList=_):
43 (x \ [list: aList])
45 (x=[list: l=_] with: aThing=_):
46 (x \ [list: (l with: aThing)])
48 (x=[list: l=_] handle):
49 (l do: [eachItem=_: eachItem print])
50 ];;
55 [self
57 .list: .nil
59 [.initialize: aList]:
60 (self \ [.list: aList])
62 [.with: aThing]:
63 (self \ [.list: (self.list .with: aThing)])
65 .handle:
66 (self.list [.do: [eachItem: eachItem.print]])
67 ];;
70 [.self
72 list: nil
74 [initialize: .aList]:
75 (.self \ [list: .aList])
77 [with: .aThing]:
78 (.self \ [list: (.self list with: .aThing)])
80 handle:
81 (.self list [do: [.eachItem: .eachItem print]])
82 ];;
86 initialize: aList
87 list := aList.
89 add: aThing
90 list add: aThing.
92 handle
93 list do: [:eachItem | eachItem print].
