Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

User-defined functions? #484

Answered by myitcv
zombiezen asked this question in General
Aug 13, 2020 · 4 comments · 9 replies
Discussion options

You must be logged in to vote

The current best answer is:

foo: {#a: int, #b: int, #a + #b } // struct with embedded scalar
call: foo&{_, #a: 1, #b: 2}         // 3

(a change from the previously marked answer because we now have full support for embedded scalars)

There is a proposal to support a syntactic sugar based on this:

foo: { #a: int, #b: int, #a + #b } // struct with embedded scalar
call: foo(#a: 1, #b: 2) // 3

Replies: 4 comments 9 replies

Comment options

You must be logged in to vote
4 replies
@mpvl
Comment options

@mpvl
Comment options

@myitcv
Comment options

@PierreR
Comment options

Comment options

You must be logged in to vote
4 replies
@codewithcheese
Comment options

@myitcv
Comment options

@morlay
Comment options

@myitcv
Comment options

Answer selected by myitcv
Comment options

You must be logged in to vote
1 reply
@myitcv
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
8 participants