[mercury-users] list functor style functions
David Overton
dmo at cat.cs.mu.OZ.AU
Fri Nov 12 16:19:24 AEDT 1999
On Fri, 12 Nov, 1999 at 02:41:55PM EST, Peter Schachte wrote:
> 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).
>
You can do some neat syntactic tricks by overloading []/0 and '.'/2 as
well. For example, I once overloaded these functions to work with
Fergus's lazy_list module and was then able to to use DCG syntax for
parsing lazy lists. Adding a lazy read predicate (ala Haskell's readFile)
meant I could parse input without reading it all into a list first.
The only problem was that the compiler didn't have enough information
about the relationship between the two functions to do any sort of
decent determinism analysis. But this problem has already been
discussed on this list.
David
--
David Overton Department of Computer Science & Software Engineering
PhD Student The University of Melbourne, Australia
+61 3 9344 9159 http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
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