by beaumartinez · 15y ago · 0 comments
hello = ^{ "Hello " + name }
does. I (and my grandmother as well, for that matter) would understand that a lot better if it was a lot more explicit, like function hello(name) do
"Hello " + nameWhether to write:
hello = lambda (name) { "Hello " + name }
hello = ^ (name) { "Hello " + name }
hello = function (name) { "Hello " + name }
is just a color of the bike shed decision.
You might say that significant whitespace (i.e. the indentation level signifies structure) is a more natural way, but when you think about it there's no where else in these peoples lives where indentation of text determines it's function or effect. When you e.g. in Word indent text it's a purely visual effect (which might imply or give greater meaning to structure, but not define it). Thus, significant whitespace is not as natural as parenthesis and -- it turns out -- curly braces.
Now, I only did qualitative research and have yet to see a large uptake in usage. I personally use Move for 95% of everything I write nowadays and I have colleagues and friends who are also writing things in Move, so I guess time will tell if this is actually a more "natural" programming language than, say, JavaScript.
I recently wrote this update on the Move language. A sort of retrospect: http://rsms.me/2011/07/30/an-update-on-move.html
If they wanted "smaller" lambdas, why not use e.g. C#'s syntax? Or Scala's?
Also, implicit scoping => yet an other broken language. Not worth looking at.
What other solution do you propose? Demanding all variables are declared? That's a very good idea, but it goes against the spirit of javascript and other dynamic languages.
After extensive experience with it in Python and Ruby, I don't. It's just too prone to typos and broken scoping to be worth it.
> What other solution do you propose? Demanding all variables are declared?
yes.
> That's a very good idea, but it goes against the spirit of javascript and other dynamic languages.
No it does not.
* Javascript has explicit scoping, it's mandatory in strict mode (ES5) and extensions add even more flexible scoping methods (e.g. `let` in Mozilla's JS 1.7[0])
* Likewise with Perl under `use strict`
* Or even in VB and VBScript using Option Explicit
* Smalltalk mandates declaring local variables
* Scheme (and more generally lisps) make extensive use of `let`-type blocks
Dynamic typing and implicit scoping are entirely orthogonal, and I truly find no value whatsoever in implicit scoping: it's a hindrance in every situation, and it helps in none.
[0] https://developer.mozilla.org/en/New_in_javascript_1.7#Block...
int (^aBlock)(int) = ^(int a) {
return a;
}; hello = \name -> putStrLn ("Hello, " + name)
That said, Haskell doesn't end up needing no-arg functions the way JavaScript does, but I think "\-> { }" wouldn't be too bad. At the least it does a slightly better job of resembling a lambda than the caret.