any trick to allow anonymous code blocks in python?

G

gabriele renzi

il Sat, 26 Jun 2004 10:54:27 GMT, "Paul McGuire"
Smalltalk supports inline anonymous code blocks, looking something like:

mylist sort: [ :a :b | b-a ]

invokes the sort message on mylist, using a code block with two arguments, a
and b, using b-a as the comparison (implements a descending order sort).

thank you, I knew this, but I was thinking about something else:

It seem to me that SmallTalk has singleton instance methods just like
ruby and python. Given that GUIs are tightly integrated with the ST
environment (while python uses toolkits that are mainly developed in
other languages like C ), It would be reasonable to see something on
the lines of what the OP was asking, like:

def b.onclick:
foo



Or do you mean that everything in ST gui code is done via

button when: #clicked do: [blockClosure]

?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top