[erlang-questions] Matthew Sackman's "cut" proposal
Mon Jul 11 05:45:35 CEST 2011
Typing this from phone, so forgive any terseness.
I have used his Erlang cut library, simplified code and made it more
readable, but the limitations above are pretty nasty. I recommend a style
copying that of Boost.Phoenix, a C++ library designed for heavy functional
usage, specifically it allows for what cut does, but also reordering of
parameters and skipping parameters (as well as much more that goes well
beyond the score of Erlang). It does it like this (in an Erlangish way):
fun(Arg1, _Arg2, Arg3) -> Arg1:aCall(Arg3), Arg3 end
(Arg1:aCall("test", Arg3), Arg3)
Probably use _ instead of Arg as the tag, or perhaps language support for
something else that is not sorted by the current grammar.
Phoenix only goes up to Arg9 by default I think, but you can specify all
others by templates: arg_<12>()
I do not really care what the tag is, but if it is followed by its
positional number, that fixes a lot.
P.S. The reason that Pheonix starts at Arg1 instead of Arg0 is because Arg0
is a tuple of all the args as I recall, excellent for debugging.
P.P.S Pheonix seems dynamically typed because it is. It is a template tree
that is evaluated, compiled, and even has optimization passes performed on
it (in many cases outperforming hand written code to do the same thing, at
worse matching it) by a template 'compiler', Boost.Proto, at the point that
it is called. Ingenious design. Hefty compile time. ;-)
On Jul 10, 2011 9:00 PM, "Richard O'Keefe" <ok@REDACTED> wrote:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions