Skip to content

Ambiguity from nested anonymous functions #233

@Merlin04

Description

@Merlin04

Is your feature request related to a problem? Please describe.
I came across Clio and it looks really cool, I'm excited to try using it for some projects! One issue I ran into is that in nested anonymous functions I can't figure out how to specify which parameters belong to which function.

For example, here's a function in JavaScript:

const thing = (m) => [...Array(5).keys()].map(item => item * m).forEach(item => console.log(item));

I'm not sure how I'd write this in Clio due to the nested anonymous functions creating ambiguity (I can't specify that item is a parameter of the inner function and m is a parameter of the outer function):

thing = (0..5 -> .toArray -> * (@item * @m) -> console.log)

Describe the solution you'd like
I'm not sure how this could be resolved while keeping Clio's implicit parameter syntax. Maybe there could be some sort of new syntax like JavaScript's function() {} that keeps the fn and explicit arguments but still returns an anonymous function? Something like:

thing = fn m: (0..5 -> .toArray -> * (@item * m) -> console.log)

Describe alternatives you've considered
I could just write thing as a regular function:

fn thing m:
  0..5 -> .toArray -> * (@item * m) -> console.log

But this doesn't return an anonymous function so it wouldn't be a valid workaround in all cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions