Smerl breakthough: metacurrying
Yariv Sadan
yarivvv@REDACTED
Mon Aug 21 04:59:30 CEST 2006
Fascinating stuff, David. Thanks for the link. I only know Lisp on a
basic level and although I know Lisp has great metaprogramming
capabilities I didn't know about this specific feature. I guess I have
some homework to do :)
Best,
Yariv
On 8/19/06, David Hopwood <david.nospam.hopwood@REDACTED> wrote:
> Yariv Sadan wrote:
> > Hi,
> >
> > I added a new capability to Smerl, allowing you to curry parameters
> > for function forms in runtime, finally freeing us from having to know
> > the Erlang abstract form!
> >
> [...]
> > http://yarivsblog.com/articles/2006/08/19/erlang-metaprogramming-breakthrough-metacurrying
>
> This functionality is similar to Lisp's quasiquoting. It is generalized
> by quasipatterns in E:
> <http://www.erights.org/elang/grammar/quasi-overview.html>
>
> (That page unfortunately assumes a lot of context that might be opaque
> to people not familiar with E, but hopefully the main ideas will come
> through.)
>
> Quasipatterns are more general because, as well as being able to make
> substitutions (what you call metacurrying), they also allow pattern
> matching on programs without having to know the abstract form. For
> example:
>
> /**
> * What's the derivative of expr with respect to var? I.e. what's
> * "d(expr)/d(var)"?
> */
> def deriv(expr, var) :any {
> switch (expr) {
> # ** means "to the power"
> match e`$var ** @exp` ? (isConst(exp)) {
> e`$exp * $var ** ($exp - 1)`
> }
> match e`@a + @b` {
> e`${deriv(a, var)} + ${deriv(b, var)}`
> }
> ... # other differentiable expressions
> }
> }
>
> Also, quasipatterns are designed to be able to process multiple languages,
> and even mixtures of languages, while still being able to express simple
> cases simply.
>
> --
> David Hopwood <david.nospam.hopwood@REDACTED>
>
>
>
>
More information about the erlang-questions
mailing list