Create a Block from a String
I was asked how to store a block from a string this morning, and store the result in an input field. It's actually pretty simple:
string := '[:a | a + 1]'. block := Compiler evaluate: string. block value: 10
Now, if you put that behind an input field in a UI, you would want to be extremely careful - you wouldn't want someone typing, say,
[Object := nil].
and just executing the result at some point. To go all Spiderman, "With Great Power Comes Great Responsibility" :)
Technorati Tags: compiler