[boo]
towards a boo interactive shell
[ bamboo ] 16:37, Wednesday, 6 October 2004

Interactive language shells are cool. If you don't agree go read something else.

An interactive boo shell is probably the number one request I receive and finally the good news is that yesterday as I was leaving the elevator I had this very clear vision on how I could implement it. The great news is that it won't be too hard. In fact, if you compile boo from the subversion repository you can already take a look at the initial design of the InteractiveInterpreter class in the src/booish directory.

Sample code? ok. Here it goes:

interpreter = InteractiveInterpreter()
interpreter.SetValue("name", "boo")
interpreter.SetValue("age", 3)

interpreter.Eval("""
print(name)
print(age)
age += 1
""")

assert 4 == interpreter.GetValue("age")

interpreter.Eval("age = 42")
assert 42 == interpreter.GetValue("age")

interpreter.Eval("""
value = 3
print(value*2)
""")

assert 3 == interpreter.GetValue("value")

interpreter.Eval("x2 = { return value }")

x2 as callable = interpreter.GetValue("x2")
assert 3 == x2()

cool, eh?
Maybe you'll start using boo now, hammett? ;-)

TrackBack
Comments
Post a comment









Remember personal info?