[cduce-users] Transformation d'une liste
Giuseppe.Castagna at ens.fr
Sat Jul 26 15:06:00 CEST 2003
> Maybe we tried to follow OCaml syntax too closely (OCaml has the same
> issue about ;;), and we should use a more "delimited" syntax (for
> instance, using explicit notation to close pattern matching-like
> constructions or function bodies), which would eliminate such problems.
> Well, any comment or suggestion on the syntax is welcome, this is the kind
> of thing which is difficult to decide without feedback from users !
Personally I would like to avoid a syntax for ending pattern. Just let me add a
sentence to explain why we have both map and transform. The idea is that map is the
the classical map operator of functional languages while transform must be understood
like a sieve or a filter for sequences. The point is then why shall we require
transform braqnches to return a sequences and map brnaches return values of any type?
We longly discussed this point among the disigner. Personnally I was in favour to use
the map syntax also for transform, however this would not without consequences. The
most evident consequence is that if this solution where used then the sequence
returned by transform would have a lenght smaller or equal than the lenght of the
transformed sequence. So for instance we could not "flatten" a sequence of pair.
[(1,2) (2,3) (4,5)] |-> [ 1 2 2 3 4 5 ]
the transformation above can be programmed with transform as
transform [(1,2) (2,3) (4,5)] with (x,y) -> [x y]
while this would not be possible if we had used the same convention as map. However
not that we could have obtained it in two steps: map + flatten
flatten (map [(1,2) (2,3) (4,5)] with (x,y) -> [x y])
Personnally I not fully convinced that the advantages are worth the more complicated
syntax. I would (and I did) defend, the elimination of transform and the use of the
default branch for map, but I'd like to have some user feedback on the issue.
More information about the Cduce-users