https://github.com/anko/eslisp-fancy-function
eslisp macro: function expression with argument-splats and implicit return
https://github.com/anko/eslisp-fancy-function
Last synced: 3 months ago
JSON representation
eslisp macro: function expression with argument-splats and implicit return
- Host: GitHub
- URL: https://github.com/anko/eslisp-fancy-function
- Owner: anko
- Created: 2015-09-17T21:38:43.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-07-16T02:40:10.000Z (almost 8 years ago)
- Last Synced: 2025-02-04T19:14:41.429Z (over 1 year ago)
- Language: Makefile
- Size: 161 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# eslisp-fancy-function [][1] [][2] [][3]
An [eslisp][4] macro that works like an the usual `lambda` expression macro but
also
- parses *splats* (atoms starting with `...`) in the arguments and turns them
into appropriate variable assignments prepended to the function body, and
- implicitly returns the last thing in the body if it's an expression.
Note that despite the name, this module is strictly a *function expressions*
(`lambda`-ish) macro, not a function declaration. I'll rearrange that
eventually.
## Example
(macro fun (require "eslisp-fancy-function"))
(fun (a b ...c d) (* a b d))
↓
(function (a, b) {
var c = Array.prototype.slice.call(arguments, 2, -1);
var d = arguments[arguments.length - 1];
return a * (b * d);
});
See [the tests][5] for fuller usage.
## License
[ISC][6].
[1]: https://www.npmjs.com/package/eslisp-fancy-function
[2]: https://travis-ci.org/anko/eslisp-fancy-function
[3]: https://gitter.im/anko/eslisp
[4]: https://www.npmjs.com/package/eslisp
[5]: test.esl
[6]: http://opensource.org/licenses/ISC