[mercury-users] Why is --infer-all not the deafult?

Peter Schachte schachte at cs.mu.OZ.AU
Thu Jul 15 10:16:10 AEST 2004


On Tue, Jul 13, 2004 at 12:01:00PM +0100, David Overton wrote:
> On Tue, Jul 13, 2004 at 11:51:51AM -0700, Maurizio Colucci wrote:
> > IMHO type declarations make the code 
> > heavier to read, while giving little (or no) insight regarding the meaning of 
> > the code --- because the meaning of a variable is the way it is used, not its 
> > type.
> 
> I disagree strongly.  I find that type declarations often provide a very
> valuable insight into the meaning of the code.

One factor that may lead to this difference of opinion is the
abstraction level of the types you are using (or contemplating).  If I
declare an argument to be a list of ints, for example, that gives very
little insight into what information they carry.  If it's declared to
be a set (represented as a sorted list) of timestamps, that gives much
more information.  Another advantage of choosing higher level types is
they make type checking more useful:  you'll probably pass fewer sets
of timestamps in a predicate call than lists of ints.  Unfortunately,
the cost of using higher level abstractions like this is a lot of
casting throughout your code between set as sorted list and list, and
between timestamp and int (using no-tag constructors).

All that said, you don't lose much of the benefit of type checking by
omitting declarations and using --infer-all.  It's unfortunate that we
assume that all you get to see when you read a program is the
characters written by the original author.  Assembly language
programmers don't assume that:  assemblers produce listings with lots
of extra information.  The Mercury compiler could similarly produce a
listing containing all the inferred types, modes, and determinisms of
their code.  The problem is really our tool set, not using
--infer-all.

-- 
Peter Schachte              Any Idiot can face a crisis; it is this day-to-day
schachte at cs.mu.OZ.AU        living that wears you out.
www.cs.mu.oz.au/~schachte/      -- Anton Chekhov 
Phone: +61 3 8344 1338      
--------------------------------------------------------------------------
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