Skip to content

Partial application should be bound (like bound functions) #634

@dead-claudia

Description

@dead-claudia

It's really confusing to have code like this constantly throw TypeErrors:

class Walker
    (@visitors) ->

    walkList: (list) !->
        list
        |> filter (.type of @visitors)
        |> each @walk

    # more methods

The problem is this partial function:

(.type of @visitors)

It looks like it should be bound to the current instance, equivalent to this code:

(node) ~> node.type of @visitors  # bound

It's really equivalent to this, which was a rather unexpected gotcha:

(node) -> node.type of @visitors  # not bound

This gotcha is a little misleading. It feels like a small fix, but I don't know a lot about the internal compiler structure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions