27 September 2008

Language developments.

Designing a complex language is quite hard :D

My language goes on... I'm working on code blocks right now, something like Ruby. But well, for other things I used C++-like iterators (actually, they're just a wrap), which are wonderful (but sometimes uncomfortable).

Thanks to my dear friend Andrea, who has been here for a couple of days helping me with this language. I really like to do pair-coding with him.

Anyway, here a snip of code showing how code block can be executed over any context (i.e. a space where variables are bound).
Don't care about the syntax, message names and so on... That's the last thing.

... And yes, ":)" is the prompt :D

$ bin/shell
:) context _instruct "block" []
Block 0 elements

:) context _instruct "myContext" {}
[Object#2758]
:) block pushBack "0"
Block 1 elements
0

:) block pushBack "result inc" "result inc" "result plus 5"
Block 4 elements
0
result inc
result inc
result plus 5

:) block execute myContext
Block 4 elements
0
result inc
result inc
result plus 5

:) myContext
[Object#2758]
:) myContext _methods
List 11 elements
_changeType
_find
_id
_instruct
_methods
_send
equal
exec
result
stringfy
type

:) myContext result
7


Stay --sync

0 commenti:

Post a Comment