|
|
|
|
|
by pmontra
3648 days ago
|
|
I was describing a syntax I'd like starting from the idea that the compiler should bend to developers and not viceversa. Let's see if we can make it work. func (n)to(m)do(blk) could be syntactic sugar for to:do: funci (n, m, blk). I saw funci in the examples, I didn't investigate if there are other type of function definitions. However, if the definition starts with (arg) it should be easy to map it into a funci. This either solves the problem of name clashes with other libraries, or the problem is unsolved right now. The block passing is more serious. Maybe we could mark blk in such a way we know it's a block. Ruby uses & as in func (n)to(m)do(&blk)
Maybe Spry uses & in an incompatible way and I don't like it much anyway. It's developers bending to the compiler, but let's be realistic: we don't want slow compilers.What Ruby also does is having a yield keyword that calls an anonymous block passed at the invocation point of the function (a method in Ruby's world). The block is not declared as argument of the function/method. Maybe: func (n)to(m)do() { # an empty arg is a block
x = n
...
do x
...
}
1 to 5 do { echo x }
But I think this is getting far away from the way of Spry. |
|