[m-rev.] field syntax (was: smart recompilation)
Peter Schachte
schachte at cs.mu.OZ.AU
Tue Jul 3 17:32:18 AEST 2001
On Tue, Jul 03, 2001 at 03:58:29PM +1000, Simon Taylor wrote:
> On 03-Jul-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > On 23-Jun-2001, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > > `Object ^ Field' is just a synonym for `Field(Object)'. I think the
> > > only argument was that the `Object ^ Field' syntax was a bit redundant.
> >
> > Can I add the note that the redundancy also makes it very explicit.
> >
> > Field(Object) is pretty difficult to tell apart from NotField(Object),
> > but Object ^ Field is impossible to confuse with NotField(Object).
Ah, but part of the design is to allow you to create pseudo-fields by
writing a function or two. This means that you can use field access
functions (and field access syntax) outside the defining module without
forcing yourself to always have that field (as long as you can extract and
maybe set equivalent information somehow). So Object ^ field may or may not
be a real field.
> > That is a round-about way of saying -- it would be nice to get rid of
> > Field(Object) and just use Object ^ Field. This way you always know
> > whether a function is intended to be used as a field accessor or not.
>
> I don't understand how you're going to "get rid of" `Field(Object)'.
> It's useful as a convention to use `Object ^ Field' for field references,
> but I don't see how the compiler is going to enforce that.
It could be done, if you're a masochist. With some declaration that a
function is a field access or setter function, you could prevent people from
using ordinary function application syntax. But why would you want to?
> 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.
Agreed. It's also nice to think of field access as just function
application. This makes it seem quite natural to pass a field name where a
closure is expected, eg mapping over a list of "structures" extracting their
foo member by doing map(foo, List, Foolist). (Or do I need a lambda there?)
So Tyson, why do you want to make this distinction so strongly?
--
Peter Schachte <schachte at cs.mu.OZ.AU> People call me feminist whenever I
http://www.cs.mu.oz.au/~schachte/ express sentiments that differentiate
Phone: +61 3 8344 9166 me from a doormat or a prostitute.
Fax: +61 3 9348 1184 -- Rebecca West
--------------------------------------------------------------------------
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