question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In addition to implicit lambdas, also add implicit partial application for operator functions

See original GitHub issue

Broken off of #36. From that issue:

@evhub: In addition to implicit lambdas as was implemented here, I think it would also be a good idea to add implicit operator functions using the (? + 5) syntax, which would be equivalent to (+)$(?, 5), since I think the former is a lot easier to read. Reopening this issue to add that syntax. @fredcallaway: I don’t love the idea of a special syntax restricted to operator expressions. Can you come up with a syntax that works cleanly for both (? + 5) and (foo(?) + 5)? For example, something like option 3 above. @evhub: @fredcallaway The syntax (-> _ + 5) or (-> foo(_) + 5) was already added and handles those use cases. The rationale for (? + 5) is that it would generate a partially-applied operator function instead of a lambda, which is significantly better for pickling, casting to a str, profiling, etc. @evhub: Maybe the right solution is just to detect implicit lambdas of the form (-> _ + 5) and automatically compile them to partially-applied operator functions, but that seems too implicit and weird to me, so I’m wary to do it.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yggdrcommented, Jun 19, 2018

I would prefer some variation of Elixir’s syntax: &(&1 + &2). Maybe substituting $ for & since that’s already associated with partial functions.

0reactions
evhubcommented, Nov 7, 2021

New proposed syntax is to use a single dot in place of the missing argument. The implicit partial must be contained in parentheses, just like operator functions, and the implicit argument can only be a single atom. Examples of valid syntax:

(.-1)
(a+.)
(f() .. .)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Lambda expressions and anonymous functions | Microsoft Learn
C# lambda expressions that are used to create anonymous functions and expression bodied members.
Read more >
Coconut v2.1.1 documentation
Lambdas. Partial Application. Pipes. Function Composition ... Additionally, Coconut also supports an implicit usage of the -> operator of the form ...
Read more >
2.4. Functions — OCaml Programming - GitHub Pages
A method is a component of an object , and it implicitly has a receiver that is usually accessed with a keyword like...
Read more >
6. Functions - Q for Mortals - Documentation for KX products
The number of formal input parameters (implicit or explicit) is the function valence. Most common are unary (valence 1) and binary (valence 2)....
Read more >
OCaml for the Skeptical: Defining and Applying Functions
Fear not: OCaml has substantial syntactic sugar for function definitions that ... First note that (most) any infix operator in OCaml can also...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found