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

Comments

Projects
None yet
4 participants
@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

This comment has been minimized.

Contributor

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Contributor

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 referenced this issue Jun 4, 2016

Merged

Issue 751 #894

@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