STR-47: List should behave as if represented by Cons/Nil
Revert the list changes introduced in 0.7.
The children of a non-empty list should be the head element and the tail, which is a list. The empty list has no children.
Generic term deconstruction should result in “Cons” and two children, or “Nil” and no children. Vice versa for term construction.
The generic term traversal primitives all(s), one(s) and some(s) should be defined in terms of Cons/Nil: all(s) must not traverse a list.
Note that the ATerm list can still be used. The introduction of this representation accompanied by the semantics changes in 0.7.
Small generic term (de)construction test that might be useful:
————————————————
module foo
imports list-cons tuple-cons iostrategies
main =
[1, 2]
; []
; ([], [1,2])
; (“Cons”, [1,[]])
; (“Nil”, [])deconstruct =
?l
; ?f#(xs)
; say(!“———————————–”)
; <debug(!"List : ")> l
; <debug(!"Deconstructed : ")> (f, xs)construct =
Submitted on 11 April 2004 at 21:57
?(f, xs)
; !f#(xs)
; ?l
; say(!“———————————–”)
; <debug(!"Deconstructed : ")> (f, xs)
; <debug(!"Constructed : ")> l
—————————————————-
Issue Log
STR-47, martin:
See also these emails:https://mail.cs.uu.nl/pipermail/stratego-dev/2003q4/000660.html
https://mail.cs.uu.nl/pipermail/stratego-dev/2003q4/000661.html
STR-47, martin:
I’m still not sure if we should actually ‘fix’ this.
Log in to post comments