[Oz] Loop extensions
Denys Duchier
Denys.Duchier at ps.uni-sb.de
Sun Feb 11 22:07:45 CET 2001
Hi Peter,
thanks for the appreciation.
> 1. It would be nice to be able to say:
>
> for A|B in L..H do ... end
>
> instead of:
>
> for X in L..H do A|B in ... end
I don't understand what you mean here. If you meant to write:
for A|B in L do ... end
then you can already write this (assuming L is a list whose elements
are conses). You can use an arbitrary pattern instead of just a
running variable.
> 2. It might be nice to have a difference list version
> of the 'append' accumulator. This is faster and
> consumes less memory.
The implementation of the `append' accumulator already uses a
difference list technique. I assume you mean that you would like to
accummulate by directly handing it a difference list. I could easily
add support for this, but is it worth the trouble for so little gain?
The two approaches have the same worst case complexity.
> Neither is needed for the upcoming release, of course. There are other
> possible extensions, but I don't feel the need right now:
This time around, my design guidelines for the for loop have been to
provide simple convenient support for its common applications. On the
first try I was much too ambitious and implemented a complete macro
system for Oz: you could program arbitrary extensions with it just
like you could in Lisp. But, as you'll recall, everybody hated it,
including me. So, on this second try, I tried to provide the
additional functionality through the much simpler idea of loop
`features'.
This is still a bit experimental because there has been very little
user exposure and feedback. The feedback is starting to come in, and
it's encouragingly positive (uf! that mean's I probably won't have to
come up with a 3rd design :-). However, this `feature' based approach
cannot be taken very far (on purpose).
The limitation that most aggravates me at the moment is that I have no
convenient syntax for iterating over the tails of a list. It's
possible to use the extended (C-like) syntax to achieve the same
effect, but that's nowhere as convenient as I would have it. I.e., I
can write something like:
for T in L;T\=nil;T.2 do ... end
but that's really not nice. I toyed once with ideas like:
for T in tails(L) do ... end
but when you start this way, people immediately want the more general:
for T in {Tails L} do ... end
which they can already use today; and, together with the support for
laziness, that's not such a bad idea at all (unless you want extreme
performance :-) Still, the shortcoming is vexing.
Cheers,
--
Dr. Denys Duchier Denys.Duchier at ps.uni-sb.de
Forschungsbereich Programmiersysteme (Programming Systems Lab)
Universitaet des Saarlandes, Geb. 45 http://www.ps.uni-sb.de/~duchier
Postfach 15 11 50 Phone: +49 681 302 5618
66041 Saarbruecken, Germany Fax: +49 681 302 5615
-
Please send submissions to users at mozart-oz.org
and administriva mail to users-request at mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.
More information about the mozart-users
mailing list