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

Add explicit currying to function calls #30

Open
eWert-Online opened this issue Mar 15, 2024 · 0 comments
Open

Add explicit currying to function calls #30

eWert-Online opened this issue Mar 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@eWert-Online
Copy link
Member

First suggestion for a syntax:

The definition of functions stays the same [1]. It should not care, if the application is "partial" or not.
In the application, the user may add _ to the parameters they do not want to provide yet [2]. In this case a new function is returned, which accepts the underscored parameters [3].

This has the side effect, that for example specialized "default" functions can be created and passed directly to tag transformers [4].

// [1]
let add = fn (a, b) -> a + b;
let default = fn (value, default) -> if (!value) default else value;

// [2]
let add5 = add(5, _);
let add3 = add(_, 3);
let default_empty_array = default(_, []);

// [3]
let result = add3(2); // 5
let result = add5(2); // 7

// [4]
let numbers = #Array(of: #Int) :: default_empty_array
@eWert-Online eWert-Online added the enhancement New feature or request label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant