[Edu-sig] Visual Programming in Python?

Ian Bicking ianb at colorstudy.com
Tue Apr 18 02:34:57 CEST 2006


kirby urner wrote:
>>An interesting exercise might be translating some parts of Computer
>>Science Logo Style (http://www.cs.berkeley.edu/~bh/logo.html) into
>>Python, to get a feel for how much of a text like that is related to the
>>language, and how much to the environment.
>>
>>
>>--
>>Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org
> 
> 
> One thing that was new was Alan Kay, representing Seymour Papert's
> views to the best of his ability, suggested that Seymour no longer
> regards "suppressing the receiver" as an important feature, meaning
> he's paving the way for explicity mention of the turtle as a message
> receiver, e.g. via Python notation:
> 
> So this isn't Logo, but it's probably where we're headed with the turtle stuff:
> 
> t1 = Turtle()
> t1.forward(10)
> 
> I can imagine a big commercial company contributing a colorful
> professional grade edition to the education community, via GNU or
> whatever.  Making the syntax consistently Pythonic would be an
> attractive feature (implement bindings for both Python *and*
> traditional Logo why not?).

I've struggled a little with how this would work in Logo, and looked 
some at how different dialects do it.  I have it something like this in 
PyLogo:

   make :t newturtle
   tell :t forward 10

And then I was thinking of extending OO in the same way dynamic scope 
works, which is sloppy but amused me, and maybe an OK kind of sloppy.  So:

   forward 10

Means "ask all the active objects if they know how to 'forward'", where 
there is a stack of active objects, ending with the global namespace 
(where plain functions are kept).  Then you do:

   tell :t [forward 10]

Which puts :t onto the end of that stack, then executes the block.  You 
can use it like:

   make :s (open "filename "w)
   tell :s [write "hi]

Which will write "hi" to the filename, since the file object will be on 
the object stack.  However, the plain "tell :t forward 10" would still 
work as a special syntax, which would require that :t actually implement 
a forward method.

Incidentally, all of this works off the Python object model (to the 
degree I have it implemented -- it's not quite complete yet), so you 
really could share a single Turtle implementation between the two.

I have yet to figure out how to implement keyword arguments in Logo, 
though.  I was trying to figure out how I might run VPython from PyLogo, 
and the keyword arguments were a real kicker there.

-- 
Ian Bicking  /  ianb at colorstudy.com  /  http://blog.ianbicking.org


More information about the Edu-sig mailing list