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

Pass anonymous function as a last argument #34

Closed
alari opened this issue Apr 5, 2021 · 1 comment
Closed

Pass anonymous function as a last argument #34

alari opened this issue Apr 5, 2021 · 1 comment
Labels
enhancement New feature or request syntax Syntax additions & changes

Comments

@alari
Copy link
Member

alari commented Apr 5, 2021

Syntax sugar to simplify the composition.

Without sugar:

func shouldBeAnonymous(x: u32) -> bool:
   true

-- Imagine a complex library function, like onKademliaNeighborhood(key, cb)
func foo(xs: []u32, cb: u32 -> bool):
   for x <- xs:
       cb(x)

func actuallyUsed():
   xs <- Discovery.getXs()
   foo(xs, shouldBeAnonymous)

With sugar:


func foo(xs: []u32, cb: u32 -> bool):
   for x <- xs:
       cb(x)

func actuallyUsed():
   xs <- Discovery.getXs()
   foo(xs) do x: -- x is the local parameter, type is derived from the foo definition
      true

@alari alari added enhancement New feature or request syntax Syntax additions & changes labels Apr 5, 2021
@alari alari mentioned this issue Jun 28, 2021
@alari
Copy link
Member Author

alari commented Aug 2, 2021

Depends on #183

@DieMyst DieMyst closed this as completed Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request syntax Syntax additions & changes
Projects
None yet
Development

No branches or pull requests

2 participants