[m-dev.] Freeze the compiler

schachte at cs.mu.OZ.AU schachte at cs.mu.OZ.AU
Tue Nov 14 00:54:41 AEDT 2000


On 13 Nov, Ralph Becket wrote:
> Okay.  But it's not clear to me why I would want to write
> 
> 	X ^ foo(A, B, C)
> 
> rather than
> 
> 	foo(A, B, C, X)

Three reasons.  1)  It chains better:  "X ^ foo(Y) ^ bar" looks clearer
(to me) than  "bar(foo(X,Y))" or "foo(X,Y) ^ bar".  2)  It has the nice
':=' syntax to go with it.  You don't have to wonder or remember how
to change an attribute of a term that has a '^' accessor for it, you
just use ':='.  3) Chained '^' works a lot better with ':=' than nested
functions.  "X ^ foo(Y) ^ bar := Z" looks clearer (to me) than
"set_foo(X, Y, set_bar(foo(X, Y), Z))" (I think I've got it right now)
or set_foo(X, Y, foo(X,Y) ^ bar := Z).

> (or should that be `foo(X, A, B, C)'?  This seems more natural.)

I don't mind either way.

> Sorry, but `Map ^ @Key' is awful!  It's almost worthy of Perl.

I don't care for it either, but it is concise.

> While it would be nice to be able to write
> 
> 	X @ I := (X @ I) + 1
> 
> I'm not sure it's worth it.  The alternative
> 
> 	set(X, I, (X @ I) + 1)
> 
> is almost as concise.

It's not conciseness I'm after, it's clarity (being able to read and
understand it quickly) and reduced (human) memory load.

> In a nutshell, I think simplicity of syntax is a Good Thing.

Absolutely.  In this case, though, I'm just looking for a linguistically
small generalization of the existing special '^' and ':=' syntax.  If I
can say X ^ y, why can't I say X ^ y(Z)?  It's an obvious
generalization, it's quite useful, and I can't see any reason not to
support it.  I guess that's where we differ.

I suppose I should say I put a similar (but not as nice) feature in an
object-oriented Prolog extension I wrote, and I found it very
comfortable.  It's documented in 

@InCollection{sch-saa-95,
  author =       "Peter Schachte and Georges Saab",
  title =        "Efficient Object-Oriented Programming in {Prolog}",
  chapter =      7,
  booktitle =    "Logic Programming: Formal Methods and Practical
                  Applications",
  publisher =    "Elsevier Science B.V./North-Holland",
  year =         1995,
  editor =       "Christoph Beierle and Lutz Pl{\"u}mer",
  pages =        "205--243",
  series =       "Studies in Computer Science and Artificial
                  Intelligence",
  number =      11,
  address =      "Amsterdam"
}

-- 
Peter Schachte                     The use of COBOL cripples the mind; its
mailto:schachte at cs.mu.OZ.AU        teaching should, therefore, be regarded
http://www.cs.mu.oz.au/~schachte/  as a criminal offense.
PGP: finger schachte at 128.250.37.3      -- E. W. Dijkstra 

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list