Skip to content

Curry named functions #751

Closed
Closed

Description

@kkirby

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;
}));

Activity

  1. vendethiel commented on Jul 9, 2015

    @vendethiel
    Contributor

    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 ;-).

  2. kkirby commented on Jul 9, 2015

    @kkirby
    Author

    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?

  3. waynedpj commented on Sep 18, 2015

    @waynedpj

    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.

  4. igl commented on Sep 19, 2015

    @igl
    Contributor

    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.

  5. added a commit that references this issue on Jun 4, 2016
    ad03579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions