[mercury-users] list functor style functions

Peter Schachte schachte at cs.mu.OZ.AU
Fri Nov 12 14:41:55 AEDT 1999


On Fri, Nov 12, 1999 at 12:38:23PM +1100, Michael Day wrote:
> I'm thinking I might play around with versions of these functions that
> look less like lists, to avoid confusion if they have a very different
> meaning. Making lists a special case of something else could be more
> fruitful than making everything else a special case of lists?

It doesn't really matter, you're going to implement the same things
anyway, the only question is what to call them.  I figured it would be
nice if I could just change some predicate declarations, and have all
my existing code that works on lists magically now work on any sort of
sequence.  Besides, the list-like notation is comfortable (at least to
me).

> > This idiom in the library has always irked me because it discourages
> > reuse-through-reversibility.
> 
> The one case where it appears justified is in the graph module:
> 
>         % graph__init(Graph) binds Graph to an empty graph
>         % containing no nodes and no arcs. (The graph contains
>         % a counter of the number of nodes allocated in it, so
>         % it is possible for a graph to contain no nodes or arcs
>         % and still fail to unify with the binding of Graph from
>         % graph__init.)

Hmmmmm.  This sounds like a good place for user-defined equality.  To
me, an empty graph is an empty graph.

But anyway, it's really not clear to me how you want to interpret a
graph as a sequence.  Is it a sequence of nodes or arcs?

> As to whether you could create two completely different relations with the
> same name but different modes, I guess you could :) Would that break any
> declarative semantics that Mercury programs must uphold, or would it just
> mess with the programmer's mind if there is a bug in one mode of a
> multiple moded predicate and they try to track it down?

Both, in a big way.

-- 
Peter Schachte                     All truth goes through three stages.
mailto:schachte at cs.mu.OZ.AU        First it is ridiculed. Then it is
http://www.cs.mu.oz.au/~schachte/  violently opposed. Finally, it is
PGP: finger schachte at 128.250.37.3  accepted as self-evident.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list