From: Vesa Karvonen (vesa_karvonen_at_[hidden])
Date: 2002-10-03 08:27:29
From: "David Abrahams":
>How sophisticated is the pattern-matching for function arguments?
It is rather simple. It can currently match any expression composed of
symbols and pair<>s (list<>s are composed of pair<>s). The match is done by
recursively inspecting the pattern looking for a symbol (during
The language is modelled after ML so that all "native" functions take a
single parameter and return a single value. Pattern matching is used for
supporting multiple parameters and multiple return values.
The current prototype interpreter also defines the following expressions
(which I forgot to introduce in the previous e-mail (well, they were not
used in any of the examples)):
expr : let< pattern-expr, value-expr, body-expr >
| q< C++-TYPE >
`let<>' is useful for factoring out computations. It binds the value of
value-expr to the symbols in pattern-expr and then evaluates body-expr in an
environment augmented with the pattern.
`q<>' is like `(quote expr)' in Lisp, and is currently used for introducing
"foreign" data to the code, but it might be possible to get rid of it, by
making it so that expressions can be identified and only expressions are
compiled and evaluated.
Currently there is no mechanism to call "foreign" template metafunctions,
but it should not be difficult to introduce such a feature.
While I was building the interpreter, I realized that it would also be
possible to make an imperative language, where it would be possible to
rebind the values in the environment. For example, it is possible to make a
template based interpreter for a language that supports the following kind
of programming (but I wouldn't go there):
let<pair< I0, I1 >, pair< i<0>, i<1> >,
set<I0, I1>, // rebind I0
set<I1, plus<I0,TMP> >, // rebind I1
set<N, minus<N,i<1> > > > >, // rebind N
I0> > fib_fn;
Chat with friends online, try MSN Messenger: http://messenger.msn.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk