Add lambdas for Go#85
Merged
Merged
Conversation
jabley
added a commit
to jabley/mustache
that referenced
this pull request
Jan 4, 2015
See mustache/spec#85 for how the tests were generated. If / when that pull request is merged, I will also update the submodule reference in this project. “Lambdas are a special-cased data type for use in interpolations and sections. “When used as the data value for an Interpolation tag, the lambda MUST be treatable as an arity 0 function, and invoked as such. The returned value MUST be rendered against the default delimiters, then interpolated in place of the lambda. When used as the data value for a Section tag, the lambda MUST be treatable as an arity 1 function, and invoked as such (passing a String containing the unprocessed section contents). The returned value MUST be rendered against the current delimiters, then interpolated in place of the section.”
Contributor
Author
|
How can I help this progress? |
Member
|
@jabley I'm going to help you get this merged. Would you like to update your branch first? |
jgonggrijp
reviewed
Oct 26, 2023
| clojure: '(def g (atom 0)) (fn [] (swap! g inc))' | ||
| lisp: '(let ((g 0)) (lambda () (incf g)))' | ||
| pwsh: 'if (($null -eq $script:calls) -or ($script:calls -ge 3)){$script:calls=0}; ++$script:calls; $script:calls' | ||
| go: 'func() func()(string) { g := 0; return func() string { g++; return strconv.Itoa(g); } } ()' |
Member
There was a problem hiding this comment.
Why convert the integer to string? If possible, I would prefer that you declare that the function returns an integer.
Contributor
Author
There was a problem hiding this comment.
Requiring a string was a limitation of the mustache implementation that I originally wrote, but there's no reason to enforce that limitation, and I changed my version to happily handle other types.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.