[Pharo-project] Optimisation / Simplification ...
While implementing Redline Smalltalk it occurred to me that methods and blocks are the same things, making the use of blocks to represent methods a possible optimisation or simplification to the internal of any Smalltalk implementation. For example, at: key put: value <statements here> Is not that different to: at:put: [ :key :value | <statements here> ] Just saying.
I think we all noticed that :) With the exception that blocks return the value of the last statement, and methods return self by default. I would love if you could make an explicit local return from a block too. On 10 January 2012 01:52, James Ladd <james_ladd@hotmail.com> wrote:
While implementing Redline Smalltalk it occurred to me that methods and blocks are the same things, making the use of blocks to represent methods a possible optimisation or simplification to the internal of any Smalltalk implementation.
For example,
at: key put: value <statements here>
Is not that different to:
at:put: [ :key :value | <statements here> ]
Just saying.
-- Milan Mimica http://sparklet.sf.net
Hi, With the exception of any return statement in <statements here>, which should do a non-local return instead of returning from the block. I just read an interesting post on why functions (or methods) are not blocks: http://yehudakatz.com/2012/01/10/javascript-needs-blocks/ best, Johan On 10 Jan 2012, at 01:52, James Ladd wrote:
While implementing Redline Smalltalk it occurred to me that methods and blocks are the same things, making the use of blocks to represent methods a possible optimisation or simplification to the internal of any Smalltalk implementation.
For example,
at: key put: value <statements here>
Is not that different to:
at:put: [ :key :value | <statements here> ]
Just saying.
And a method closes over the instvars of the object. Even if you said that at: key put: value <statements here> was equivalent to [:self :key :value | <statements here>] you'd still need to qualify that <statements here> has privileged access to the interior of self. So the equivalent block is more like [:self :key :value <insert all of the object's instvars> | <statements here>] (modulo non-local returns, of course) frank On 12 January 2012 13:23, Johan Brichau <johan@inceptive.be> wrote:
Hi,
With the exception of any return statement in <statements here>, which should do a non-local return instead of returning from the block. I just read an interesting post on why functions (or methods) are not blocks: http://yehudakatz.com/2012/01/10/javascript-needs-blocks/
best, Johan
On 10 Jan 2012, at 01:52, James Ladd wrote:
While implementing Redline Smalltalk it occurred to me that methods and blocks are the same things, making the use of blocks to represent methods a possible optimisation or simplification to the internal of any Smalltalk implementation.
For example,
at: key put: value  <statements here>
Is not that different to:
at:put: [ :key :value | <statements here> ]
Just saying.
http://live.exept.de/doc/online/english/programming/humor.html :) 2012/1/10 James Ladd <james_ladd@hotmail.com>
While implementing Redline Smalltalk it occurred to me that methods and blocks are the same things, making the use of blocks to represent methods a possible optimisation or simplification to the internal of any Smalltalk implementation.
For example,
at: key put: value <statements here>
Is not that different to:
at:put: [ :key :value | <statements here> ]
Just saying.
-- Dennis Schetinin
participants (5)
-
Dennis Schetinin -
Frank Shearar -
James Ladd -
Johan Brichau -
Milan Mimica