|
|
|
|
|
by riffraff
3648 days ago
|
|
I think the problem is more the example than the syntax, it basically has keyword arguments (foo: bar), square brackets for lambda ([echo :x]) and :foo for block arguments. I.e. this 1 to: 5 do: [echo :x]
is pseudopython's loop(from=1, to=5, do=lambda x: echo x)
loop(1, 5, lambda x: echo x)
which have comparable punctuation, mostly trading "," for ":" .Being smalltalkish, you also get extra characters when a block is used for control structures, but that saves on the need to have two different syntaxes for single and multi-line/expression lambdas or N syntaxes for blocks and control structures. How do you see that handled in your ideal language? |
|
A Python indented Ruby would probably able to do without [ ] but I should think about whether there are some unresolvable ambiguities with that approach. I won't recommend that personally because syntactical spaces introduce bugs. I run into one a few days ago when I moved code around a file and forgot to fix the indentation of a few lines. Luckily this one cost me only five minutes. Many people like Python though.
Overall I like the terseness of
instead of the more verbose But all those : are annoying: they increase the noise/signal ratio. I'd even do without the | | in the multi line Ruby version. I wonder if the compiler could add the : automatically by matching what it sees with the signatures of the defined function. Then, why you need :x and couldn't use x without the : ? Furthermore, how do I know how the name of the block argument if I didn't write the function. Isn't that an unnecessary coupling between the name chosen by the developer of the library and my code? I probably didn't understand everything is going on here. Edit: it has been explained in another comment in the parent's thread.And there are so many commonly used languages that use { } to define code blocks and [ ] for arrays. I'd stick with the majority for an easier onboarding of developers.
The possibility of defining pseudo keywords thanks to the infix/suffix arguments is great. That's probably anathema in the Python world (only one way of doing things) and also in Go's. It should be acceptable in Ruby's.
I'd prefer something like this
The order of arguments and function names is clear because you read them from left to right without going through two different lists.Is anybody using Spry for real world programs?