[m-dev.] making cfloat__init/1 implicit

Peter Schachte pets at students.cs.mu.oz.au
Tue Sep 16 11:16:17 AEST 1997


Hi again,

> Currently you cannot pass a variable with inst `free' to a
> procedure that expects an argument of inst `any'; instead
> you must explicitly initialize it with a call to cfloat__init/1
> or the like.

Aside:  it might be good to use for this a similar syntax to you the one you
use for specifying a unification procedure for a type.  It seems nicer to me
to make the user specify the `any initialization' procedure for a type, if
there is to be one, than to use some convention about naming predicates.
Also, having a custom unification predicate is somewhat similar to having an
initialization predicate.

> The patch below would fix this.  However, it turns out to
> cause more problems than it solves.  The reason is that
> mode analsis ends up picking the wrong modes -- it prefers
> the semidet ones above the det ones.  This causes determinism
> errors...

I don't understand this.  Picking the semidet mode sounds like a good thing:
you fail earlier.  Surely it's better to pick a real mode than an implied
mode?  I can't see how you could have a call that allows you to pick either 
a det or a semidet mode where the mode of the call, counting any postponed
argument unifications, wouldn't be semidet anyway.  Unless the user is just
being silly and declaring a mode semidet when it's really det.  And I'd
expect the compiler to at least warn about that.  I'd expect the best way to
choose among several possible modes for a call would be:

	1.  Prioritize them by determinism, in this order (best first):
		erroneous	% should be first for errors, last for loops
		failure
		semidet
		nondet		% not sure about the
		det		% order of these two
		multi.
	2.  Remove any modes that are strictly less instantiated on input
	    than other valid modes; eg, prefer an (in, in, out) mode over an
	    (out, in, out) mode, but not necessarily over an (out, out, in)
	    mode.  This is a partial order.
	3.  If there are still multiple possibilities, take them in 
	    declaration order.

-Peter Schachte      URL:  http://www.cs.mu.oz.au/~pets/
pets at cs.mu.OZ.AU     PGP:  finger pets at 128.250.37.150 for key
    Do insects spend hours demammaling their programs?




More information about the developers mailing list