[m-dev.] Re: assertions (was: Assocative predicates)

David Glen JEFFERY dgj at cs.mu.OZ.AU
Thu Apr 23 17:58:16 AEST 1998


On 23-Apr-1998, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> David Jeffery wrote:
> > but I don't see how you can have an output constraint that is 
> > different to an input constraint.
> 
> The idea is that (e.g.) you can call p/2 with the first argument
> being of the form f(_) or g(_, _), but p/2 can succeed when the first
> argument is of the form f(_) only; when called with a first argument
> of the form g(_, _), it must fail.

Ah yes, I see what you mean. I guess the distinction that I missed was between
which terms are in the success set and which ones are not, but are still
"mode correct". Now that I think about it, this is a very important distintion.
Rather than having a constraint on every mode declaration, you could simply
have two kinds of assertions: one kind are concerned with which terms end
up succeeding, and the other are concerned with which terms you are 
``allowed'' to use. Basically this corresponds to:
	- *Descriptive* assertions, which tell you properties of the predicate
	  that you are able to take advantage of. (eg. if the first list is
	  sorted, then so is the second).
	- *Prescriptive* assertions, which say that it is illegal to call the
	  predicate unless the condition is known to be satisfied.

I realise that this basically corresponds to input and output assertions, but
I think that this may be a better scheme because the assertion language winds
up being more powerful (in some sense). Rather than having to make a
prescriptive assertion about the input arguments for each mode, you do it
once for the pred as a whole. (and similarly for outputs). This also stops the
programmer from making assertions in one mode but forgetting to do so in
another. This is also a more declarative approach.

Then again, it may be too complicated to be useful.


love and cuddles,
dgj
-- 
David Jeffery (dgj at cs.mu.oz.au) |  Marge: Did you just call everyone "chicken"?
MEngSc student,                 |  Homer: Noooo.  I swear on this Bible!
Department of Computer Science  |  Marge: That's not a Bible; that's a book of
University of Melbourne         |         carpet samples!
Australia                       |  Homer: Ooooh... Fuzzy.



More information about the developers mailing list