List Constructor
Stratego -- Strategies for Program Transformation
In the ATerm representation lists are represented as terms of the form
[t1,...,tn]
. This is also the syntax for lists in Stratego; extended with the notation
[t1,...,tn|tl]
for indicating a tail
of the list. This extension is necessary to take construct and deconstruct lists of arbitrary length.
In the current implementation (upto
StrategoRelease064) lists are represented internally by means of the contructors
Cons
and
Nil
. Thus
[t1,...,tn]
is represented internally as
Cons(t1,...,Cons(tn,Nil))
. As a consequence ATerms are translated at every interface between internal and external representation (reading and writing).
In the new
ImplementationScheme introduced in
StrategoRelease06 it has become feasible to directly
use the ATerm representation for lists. This should be beneficial for performance.
This requires that lists are only constructed using the ATerm
Cons
and
Nil
operations. In the old representation it is possible to use other constructors for constructing lists, such as
Conc
, which can be useful.
--
EelcoVisser - 04 Jan 2002
Starting with
StrategoRelease07 lists will be constructed according to the scheme described above.
An attempt to construct a term of the form
[x | xs]
where
xs
is not a proper list results in
failures.
The special status of lists affects all generic term manipulation operations such as generic
traversal operators and term explosion/implosion. This special status makes it possible to
adapt the semantics of
ListTraversal, treating lists as varyadic constructors instead of as
constructed with
Nil
and
Cons
.
--
EelcoVisser - 06 Jan 2002
CategoryToDo? |
ToDo |
CompilerImprovements
Stratego.ListConstructor moved from Stratego.ListConstructors on 06 Jan 2002 - 16:31 by EelcoVisser -
put it back