[m-dev.] for review: new predicates in map.m

Andrew Bromage bromage at cs.mu.OZ.AU
Tue Oct 20 22:19:20 AEST 1998


G'day all.

I wrote:

> > There are already parts of the compiler which assume that map__keys/2
> > returns the keys in sorted order.  (I know because I wrote one or two
> > of them; after asking, of course. <g>)  Perhaps it would be better to
> > make that the default behaviour of map__keys/2.

Peter Schachte wrote:

> I don't think that's a good idea.  Other implementations of maps (eg,
> hash talbes) might not find it natural to return the list sorted, so I
> don't think map__keys/2 should be specified to return a sorted list.

Yes, I thought someone may bring this up. :-)  Thankfully, we do have a
precedent.

It's not natural to return solutions (i.e. solutions/2) in sorted order,
either, but we seem to live with this performance hit, plus we even give
the programmer a way to avoid it if they want to by using cc_multi.

I personally don't buy the argument that "it's the natural way to
implement it" should determine the semantics of our library operations.

> My knee-jerk reaction to adding a map__sorted_keys/2 predicate is that
> it's unnecessary and would tend to lead to library bloat.

That was mine too, I must admit.  Gotta control that knee.

Cheers,
Andrew Bromage



More information about the developers mailing list