|
|
|
|
|
by junke
3648 days ago
|
|
func (n)to(m)do(blk) {
x = n
...
do blk x
...
}
This looks ambiguous.
Your function does not have a name, how do you do if another library wants to do something different with the same keywords?
And how do you know when arguments should be evaluated? In your case, "blk" seems to be a set of statements to be executed when "do" is applied, is it right? shall we scan the body to detect if we use "do" on our arguments or does "do" in the signature have a special meaning? |
|
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
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:
But I think this is getting far away from the way of Spry.