-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implicit objects and arrays as first function argument #50
Comments
for implicit objects or arrays as the first arguments, you need to use someone do
name: "foo"
age: 20
, callback
someone do
"foo"
20
, callback |
That doesn't work. You can't have ", callback". That will generate a compilation error. Sent from my iPad On 21 jun 2012, at 18:49, Adrian Sinclairreply@reply.github.com wrote:
|
An example of what I dislike: From this in CoffeeScript:
To this in LiveScript:
It feels like a major drawback. I execute functions passing an implicit object everywhere throughout my app and it gives me a bloated feel. |
The following compile as you wish. Note that when calling against blocks starting with implicit objects/array you must start off with
Notice the indentation - it needs to be correct. Also, you don't need the comma.
Notice the star to show that the first two items are a list, not seperate arguments.
|
Why does it force us to use do? Is it to create a new scope? Also, the 2nd example with the array doesn't work. I have tried it in the compiler on the doc website but it compiles to arguments passed instead of an array. Johnny Sent from my iPad On 21 jun 2012, at 22:59, George Zaharievreply@reply.github.com wrote:
|
No new scope is created. Think of
is the same as
also
compiles for me to
Why is the use of |
Mostly because it forces to see an implicit call, where coffeescript would fail to read after the implicit object, I think. (but, yeah, @satyr obviously has reasons) |
CoffeeScript's implicit call generally doesn't work against blocks, but has a specialcase for implicit objects:
which causes problems:
Coco removed the specialcase and instead made |
What are the reasons for:
and not
|
I guess it's not that big deal with do. But I think LiveScript should be targeting 0 compromises to create the perfect language.
Cons:
Please reopen this issue. |
This is an unambiguous case. The
This is ambiguous due to constructions like
Incorrect. |
The if statement was good to describe the problem. But could another word or a symbol perhaps be used?
Doesn't this mean it is creating a new scope? |
That scope is from
|
@satyr this is one of my problems with such syntactically stripped-down languages, often consistency is sacrificed for the sake of syntactic unambiguity, where I think the former is more important (obviously unambiguity is required for the compiler to work, but the syntax should not have so few landmarks that it happens often at all) I mean the language is nice and all, and I plan to use it in the next project that I see fit, but I don't see the point of such a syntax with so few non-whitespace landmarks; I have nothing against parenthesis, coming from lisp and all. |
In that case I'd recommend sticking with lispy variants, in which you have many better choices (ClojureScript, Slip to name a few) with unlimited possibilities via macros. |
@adrusi, you can use parentheses instead of
|
In case of
Perhaps we can do:
In that way we don't have to be forced typing do everywhere when we don't have to. Just like executing a function with ! when we have to use it, and ignoring it when we don't. Even when we have to use do I feel that we can use:
indicating that it's a new line. Just like in unix. Having do standing for 2 different things is not good practice. |
@johnnywengluu +1 for backslash. As ugly as it is, it's what's used in other languages (python, shell) and is in fact 1 less character @satyr I tried clojurescript, and I like it. The thing is, I'm also a big javascript fan, and js is my main language, so I also really like these language projects that are closer to js. I'm not saying that clojurescript doesn't have fantastic interop, but coffeescript derivatives don't have a need for interop at all. |
@adrusi yes, also, it will only be used when needed, which is perhaps never. I think people would like to do:
instead of the earlier mentioned one. Let our code be cleaner without all these do keywords. It's an downgrade from CoffeeScript in this case |
@johnnywengluu:
Then we'd have to type
Pretty sure there are JS lisps that are. How about Sibilant? |
@satyr if the following becomes a legal syntax:
(it might already be) then I think And Sibilant is just bad, at one point I was interested and even forked the project and messed around with the source, but it's really quite bad. Really, Coffeescript-like languages are fine for me, I'm just saying that it can get frustrating when avoiding parenthesis and braces becomes such a big deal to people that they come up with new syntaxes to avoid them, even when the new syntaxes mean more overall characters. Why can't we just be content with:
which IMO is easier to mentally parse than
because it provides visual landmarks separating the 2 arguments. |
actually, I'd like to point out that:
does not compile because the end of the argument list would be ambiguous, for example:
is that
or
|
Python does this with requiring
Ritht, that
|
@satyr oh, so having a block in the predicate requires |
Yeah, since you need to somehow dedent and then indent again. Coco's
|
Why isn't it allowed to do:
One of the selling point with LiveScript is that it removes the need for a closing character.
The only exception is:
This makes the code more verbose than the CoffeeScript version (the array syntax stays the same).
Can't we just remove the "pyramid effect" in all eternity just like Jade, Haml and Stylus have done but for HTML and CSS.
The text was updated successfully, but these errors were encountered: