smalltalk-tng
view doc/hll.experiments @ 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 -*- slate -*-
3 (to (handle-event (e (mouse-button-down (events sdl))))
4 (let ((s2 (render-text-blended (system-font sdl)
5 "(click)"
6 (make (color sdl) 255 255 255))))
7 (blit s2
8 (nil (rect sdl))
9 (video-surface sdl)
10 (make (rect sdl) (x e) (y e) 0 0))
11 (free s2)
12 (flip (video-surface sdl))
13 (resend)))
15 [ counter:= 0 | ->. ^ counter. counter:= counter + 1 ]
18 [ -> a b. c = a + b. ^ c. ]
20 [ -> a b. ^ (a + b). ]
23 ! e@(SDL EventTraits MouseButtonDown) handle !
25 s2 = SDL SystemFont renderText: "(click)" color: (SDL Color White).
26 s2 blitOn: SDL VideoSurface location: (SDL Rectangle x:= e x y:= e y).
27 s2 free.
28 SDL VideoSurface flip.
29 ^ resend.
30 !!
32 addGlobal: #Counter value: (generator:= Nil).
34 ! c@Counter new !
35 generator = [ loop(count:= 0) { ->. ^ count. loop(count:= count + 1) } ].
36 ^ (c generator:= generator).
37 !!
39 ! c@Counter next !
40 ^ (c generator <- ).
41 !!
44 ! _@0 isEven ! ^ True. !!
45 ! _@0 isOdd ! ^ False. !!
47 ! i@(Integer traits) isEven ! ^ (i - 1) isOdd. !!
48 ! i@(Integer traits) isOdd ! ^ (i - 1) isEven. !!
51 {
52 x = y ifTrue: [
53 }
56 "---------------------------------------------------------------------------"
58 loop(count:= 0) [ ^ count. loop(count:= count + 1). ].
60 [ :a :b | c = a + b. ^ c. ]
62 [ :a :b | ^ (a + b). ]
64 addGlobal: #Counter value: (generator:= Nil).
66 ! c@Counter new !
67 generator = loop(count:= 0) [ ^ count. loop(count:= count + 1) ].
68 ^ (c generator:= generator).
69 !!
71 ! c@Counter next !
72 ^ (c generator value).
73 !!
