Skip to content
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

Curry named functions #751

Closed
kkirby opened this issue Jul 9, 2015 · 4 comments
Closed

Curry named functions #751

kkirby opened this issue Jul 9, 2015 · 4 comments
Labels
bug

Comments

@kkirby
Copy link

@kkirby kkirby commented Jul 9, 2015

If you have a named function that curries (I think that's how you'd name it?), the function isn't scoped properly.

:abc (x,y) --> x + y

Expected:

var abc;
abc = (curry$(function(x, y){
  return x + y;
}));

Actual:

(curry$(function abc(x, y){
  return x + y;
}));
@vendethiel
Copy link
Contributor

@vendethiel vendethiel commented Jul 9, 2015

it's mostly because "labels" attach to "blocks", nothing else. (a for, a function, etc). You ought to use a = --> or

~function a(b, c)
  b

for curried functions anyway ;-).

@kkirby
Copy link
Author

@kkirby kkirby commented Jul 9, 2015

I agree to use a = -->, but is this considered expected functionality? I was just reading the code and saw that you can name a function using the label syntax and saw that currying doesn't work with this. If this is expected, should the parser maybe throw an error when this is occurred?

@vendethiel vendethiel added the bug label Jul 9, 2015
@waynedpj
Copy link

@waynedpj waynedpj commented Sep 18, 2015

also having an issue with creating a curried named function as suggested above ala

~function named (a, b)
  a + b

which compiles to a bound named function w/ 1.4.0 as expected

var this$ = this;
function named(a, b){
  return a + b;
}

all the other combinations i have tried (e.g. --function named, -function named) are giving compilation errors or not currying the named function.

perhaps it is not possible to create a curried named function as they are constants?

thanks.

@igl
Copy link
Contributor

@igl igl commented Sep 19, 2015

The problem is that you can't.
Wrapping a function statement in Javascript will make it a function expression.
Same as:

foo = :foo -->

The only fix i can think of would be to wrap the body of the function and not the declaration.

misterfish added a commit to misterfish/LiveScript that referenced this issue Jun 4, 2016
@misterfish misterfish mentioned this issue Jun 4, 2016
@gkz gkz closed this in #894 Jun 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

4 participants