[m-rev.] field syntax (was: smart recompilation)

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Jul 4 13:57:15 AEST 2001


On 04-Jul-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> On Wed, Jul 04, 2001 at 06:42:58AM +1000, Simon Taylor wrote:
> > On 03-Jul-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > > On 03-Jul-2001, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > > > The lack of distinction between fields and functions was deliberate.
> > > > It's useful to be able to redefine a field as a pair of functions
> > > > without changing any of the code that uses the field.
> > > 
> > > The proposal above preserves that property.  The advantage is that
> > > it makes it obvious when a function is intended to be used as a field
> > > accessor, and when a field accessor is used as a function.  It avoids
> > > accidental overloading between field names and functions or constructors
> > > that happen to have the same name.  If you want to refer to the field
> > > accessor as a function (e.g. to pass to a higher-order function such as
> > > `list__map'), you can still do so, you just have to use 'foo =' rather
> > > than 'foo'.
> > 
> > I still don't see the point.

> For me it is important when defining a mapping between dotnet objects
> and mercury type classes.

For me the factors are

	1.  Readability
	2.  Interoperability with .NET
	3.  Avoiding unnecessary overloading

in that order of importance, with #1 a lot more important than #2
and #2 a lot more important than #3.

> > Why is accidental overloading between
> > field accessors and functions worse than accidental overloading between
> > functions and constructors?

Who said it was worse?

I do think it is a little worse, because users normally use
a different syntax for calls to to field accessors than they do for
function calls, whereas they use the same syntax for constructor invocations
that they use for function calls.  As a result, they will be much more
suprised if and when ambiguity arises.

But this is a relatively minor issue, not the main motivation for the proposal.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list