Closures python,scheme,ruby

Jacek Generowicz jacek.generowicz at cern.ch
Fri Jul 16 03:26:34 EDT 2004


bokr at oz.net (Bengt Richter) writes:

> What if
>     x <= expr
> meant evaluate expr and then find x (as if to do a read access) and
> rebind it, whatever name space it's found in?

I suspect that it's too Perlish for Python, but that sort of approach
is probably the simplest, clearest, most extensible ...

[Aside:

 It's in situations like this that sexpr-based languages are very
 adavantageous: you don't have to invent fancy syntax, you don't have
 to come up with new keywords that break old code ... you just say what
 you mean in the usual fashion:
 
     (find-and-rebind x expr)
 
 [Of course, you can still argue endlessly over how it should be spelt
 (rebind, set!, setq, lexical-set ...) but at least the mechanism is
 clear and uncontroversial.]

]

> (Might be dangerous if you include searching builtins though)

Yes, you'd probably want to keep builtins out of it.

> Hm, ... not sure about rebinding a binding discovered by attribute
> name access -- i.e.,
>      x.y <= expr
> might rebind a class variable somewhere or an instance variable, depending.
> Don't know how useful that might be.

Could be fun !  :-)



More information about the Python-list mailing list