5 ms·
The only thing i don't like so far, is `func` and `->` both expressing functions. I use Coffee a ton, and Golang, so oddly enough i love both syntaxes.. but i d
by fizzbatter 12y ago
The only thing i don't like so far, is `func` and `->` both expressing functions. I use Coffee a ton, and Golang, so oddly enough i love both syntaxes.. but i don't like multiple ways to declare a core feature like functions.
Just my 2c.
Fwiw, i'm going to be trying this out asap - I have high hopes for this replacing my very heavy CoffeeScript usage!
- alongub 12y agoI actually agree about this - two ways to do exactly the same thing is generally a bad thing when it comes to language design. But I think that a more important goal is to make the transition from Spider to JS as easy as possible.
- 14113 12y agoI think it's quite good - it allows a programmer to conceptually separate her "normal" functions from lambda expressions, even if they're essentially equivalent, and one is syntactic sugar for another.
- woah 12y agoES6 already has =>, I think that Spider should probably stay far away from trying to replicate existing language features with different syntax
- tomp 12y agoMany functional languages have shortcut syntax for inline functions, e.g. in OCaml: let f = fun x y -> x + y Haskell: let f = \x y -> x + y It looks that Spider uses a similar syntax, but uses uncurried form in line with function invocation syntax.
- rld 12y agoIt's not duplicate syntax. `func` adds a named function to the current environment, and `->` only describes an anonymous function. It's the equivalent of `function foo(...)` vs `function(...)` in JS.
- fizzbatter 12y agoCan you not `func(foo){}`? Because that is what would bother me. `func(foo){}` and `(foo) ->` seem too similar, for my taste at least. Sure, the difference is that one is always anonymous, where as one is sometimes anonymous.. but we've been using `function` as both named and anonymous for ages