smalltalk-tng

view r3/io-build.tng @ 323:454c18798969

merger
author Tony Garnock-Jones <tonygarnockjones@gmail.com>
date Tue Feb 07 11:34:20 2012 -0500 (3 months ago)
parents 6a9fab6479be
children
line source
2 define-method (d=[Directory: _] nonUnderscoreFolders) (
3 filter: d folders by: [x=_: (x name beginsWith: '_') not]
4 );;
6 "filter: folders d by: [$x: not (name x beginsWith: '_')]"
8 define [
9 Log: [indentLevel: 0 ref]
11 ([indentLevel: i] indentDuring: blk):
12 ( i set: i get + 1,
13 blk $ (),
14 i set: i get - 1 )
16 (write $x)
17 ];;
19 "
20 Syntactic sugar:
22 a + b ==> (0: a #(+): b)
23 a b ==> (#b: a)
24 a: b ==> (a: b)
26 [a + b] ==> [0: a #(+): b]
27 [a b] ==> [#b: a]
28 [a: b] ==> [a: b]
29 "
31 "
32 Read '<==>' as 'matched against' (with pattern on left, value on right)
34 As a pattern: ((indentLevel: i) indentDuring: blk) <==> msg
35 Expands to: (0: (indentLevel: i) indentDuring: blk) <==> msg
36 Which results in (indentLevel: i) <==> (msg $ #0)
37 and blk <==> (msg $ #indentDuring)
38 Which results in i <==> (msg $ #0) $ #indentLevel
39 and blk <==> (msg $ #indentDuring)
42 (foo: bar): ... -> bar bound to (msg $ #foo)
43 (foo bar): ... -> foo bound to (msg $ #bar)
44 (foo $ bar): ... -> illegal pattern
45 foo: ... -> foo bound to msg
46 123: ... -> 123 matched with msg
47 #foo: ... -> #foo matched with msg
49 Essentially, on the left of the colon (i.e. in pattern context), it is
50 a form entirely analogous to an expression, although obviously
51 application can't be matched since it's already been reduced. On the
52 right of the colon is another pattern. (??????????????????????????)
54 [
55 (foo: bar): zot
57 [foo: bar]: zot
58 ] $ msg
60 2 = [lowBit: false high: [lowBit: true high: zero]]
62 [lowBit: false high: [lowBit: true high: zero]] <>
63 [lowBit: false high: [lowBit: true high: zero]]
64 --> (false <> ([lowBit: false high: [lowBit: true high: zero]] $ #lowBit)) ^
65 ([lowBit: true high: zero] <> ([lowBit: false high: [lowBit: true high: zero]] $ #high))
67 ([lowBit: false high: [lowBit: true high: zero]] $ #lowBit)
68 --> {presume matching against #high fails}
69 results in false
71 What's the base case of the recursion??
72 Need a distinction somewhere!
73 "