D
David Mertz
Back over in that same endless Lisp thread, the idea of codeblocks came
up. Several variations were discussed, with some different opinions on
just how ugly or bearable the syntax was (I don't think any of them
registered as "wonderful" by anyone).
I think that codeblocks, a la Ruby, Smalltalk, xBase, would be kinda
nice to have. But the thing I like about them isn't really that they
can be inlined, but rather simply that the operate without defining a
new (nested) scope. Basically, codeblocks just amount to
boilerplate--except possibly paramaterized... and shorter, of course.
So for that, I would suggest a new scopeless pseudo-function syntax.
E.g.:
block foo(this, that, other):
x = this+that
y = this*other
z = x // (y-that)
Using this is like a function, but the names wind up in the calling
namespace:
def bar(someblock):
a, b, c = (4, 5, 6)
someblock(a,b,c)
return x,y,z
vals = bar(foo) #-> (9, 24, 0)
That is, I have no desire for blocks to be nameless, just for them to be
passable as first class objects.
Yours, David...
up. Several variations were discussed, with some different opinions on
just how ugly or bearable the syntax was (I don't think any of them
registered as "wonderful" by anyone).
I think that codeblocks, a la Ruby, Smalltalk, xBase, would be kinda
nice to have. But the thing I like about them isn't really that they
can be inlined, but rather simply that the operate without defining a
new (nested) scope. Basically, codeblocks just amount to
boilerplate--except possibly paramaterized... and shorter, of course.
So for that, I would suggest a new scopeless pseudo-function syntax.
E.g.:
block foo(this, that, other):
x = this+that
y = this*other
z = x // (y-that)
Using this is like a function, but the names wind up in the calling
namespace:
def bar(someblock):
a, b, c = (4, 5, 6)
someblock(a,b,c)
return x,y,z
vals = bar(foo) #-> (9, 24, 0)
That is, I have no desire for blocks to be nameless, just for them to be
passable as first class objects.
Yours, David...