Created
July 30, 2010 14:17
-
-
Save vito/500585 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ the | |
> a = 0 | |
> { a = a + 1; a print } do -- normal; assigns a only within the block | |
1 | |
> a | |
0 | |
> action = { a = a + 1; a print } | |
> action scope do: action -- now executing it as part of its original scope | |
1 | |
<prototype (delegates to <bottom>) | |
(<self> Object = <reference>) | |
(<self> Block = <reference>) | |
(<self> Char = <reference>) | |
(<self> Double = <reference>) | |
(<self> Integer = <reference>) | |
(<self> List = <reference>) | |
(<self> Message = <reference>) | |
(<self> Particle = <reference>) | |
(<self> Process = <reference>) | |
(<self> String = <reference>) | |
(<self> if: <id> then: (a: <id>) else: <id> = (((a) do))) | |
(<self> if: <id> then: <id> else: (b: <id>) = (((b) do))) | |
(<self> when: (b: <id>) do: (action: <id>) = ((<top> if: (b) then: (action) else: {}))) | |
(<self> if: <id> then: (a: <id>) else: <id> = (((a) do))) | |
(<self> if: <id> then: <id> else: (b: <id>) = (((b) do))) | |
(<self> when: (b: <id>) do: (action: <id>) = ((<top> if: (b) then: (action) else: {}))) | |
(<self> Bool = <reference>) | |
(<self> True = <reference>) | |
(<self> False = <reference>) | |
(<self> if: <id> then: (a: <id>) else: <id> = (((a) do))) | |
(<self> if: <id> then: <id> else: (b: <id>) = (((b) do))) | |
(<self> when: (b: <id>) do: (action: <id>) = ((<top> if: (b) then: (action) else: {}))) | |
(<self> while: (test: <id>) do: (action: <id>) = ((<top> when: (((test) do)) do: {(((((action) scope)) do: (action))); | |
((<top> while: (test) do: (action)))}))) | |
(<self> action = {<self> a = (((a) + 1)); (((a) print))}) | |
(<self> a = 1) | |
> | |
> a | |
1 | |
> -- that big dump is because @do: returns the new object, but you can see a = 1 at the bottom there too | |
> -- this works too: | |
> {} scope do: { b = 20; a = 42 } | |
<prototype (delegates to <bottom>) | |
(<self> Object = <reference>) | |
(<self> Block = <reference>) | |
(<self> Char = <reference>) | |
(<self> Double = <reference>) | |
(<self> Integer = <reference>) | |
(<self> List = <reference>) | |
(<self> Message = <reference>) | |
(<self> Particle = <reference>) | |
(<self> Process = <reference>) | |
(<self> String = <reference>) | |
(<self> if: <id> then: (a: <id>) else: <id> = (((a) do))) | |
(<self> if: <id> then: <id> else: (b: <id>) = (((b) do))) | |
(<self> when: (b: <id>) do: (action: <id>) = ((<top> if: (b) then: (action) else: {}))) | |
(<self> if: <id> then: (a: <id>) else: <id> = (((a) do))) | |
(<self> if: <id> then: <id> else: (b: <id>) = (((b) do))) | |
(<self> when: (b: <id>) do: (action: <id>) = ((<top> if: (b) then: (action) else: {}))) | |
(<self> Bool = <reference>) | |
(<self> True = <reference>) | |
(<self> False = <reference>) | |
(<self> if: <id> then: (a: <id>) else: <id> = (((a) do))) | |
(<self> if: <id> then: <id> else: (b: <id>) = (((b) do))) | |
(<self> when: (b: <id>) do: (action: <id>) = ((<top> if: (b) then: (action) else: {}))) | |
(<self> while: (test: <id>) do: (action: <id>) = ((<top> when: (((test) do)) do: {(((((action) scope)) do: (action))); | |
((<top> while: (test) do: (action)))}))) | |
(<self> action = {<self> a = (((a) + 1)); (((a) print))}) | |
(<self> b = 20) | |
(<self> a = 42) | |
> | |
> [b, a] | |
[20, 42] | |
> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while: (test: Block) do: (action: Block) = | |
when: test do | |
do: { | |
action scope do: action | |
while: test do: action | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment