[m-dev.] ground >> dead

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Jan 15 22:42:22 AEDT 2007


On Mon, 15 Jan 2007, Mark Brown wrote:

> On 15-Jan-2007, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
>>
>> On Mon, 15 Jan 2007, Ian MacLarty wrote:
>>
>>> Hi,
>>>
>>> Is the mode ground >> dead legal?  My intuition tells me it shouldn't
>>> be, since you shouldn't be able to clobber something that's not unique.
>>> The compiler doesn't complain about this mode however, so is this a bug
>>> in the mode system?
>>
>> It looks like the compiler doesn't check the modes for sensibility,
>> e.g.
>>
>> 	:- mode foo == dead >> ground.
>> 	:- mode bar == clobbered >> any.
>>
>> For the ground >> dead mode can you actually get clauses that use
>> this mode to compile?
>
> There's no problem with:
>
> 	main(!IO) :-
> 		p("foo", X),
> 		write_string(X, !IO),
> 		nl(!IO).
>
> 	:- pred p(string::ground >> dead, string::out) is det.
>
> 	p(X, X).
>
> It's hard to see that this mode is useful, however, since it imposes a
> restriction on the caller for which there is no corresponding gain (that
> I can see).

I think that it was an attempt to disallow further forward references to the
argument (it makes more sense if you change the argument in your example
to a variable).

At the very least the compiler should give you a warning with modes like
this.

Julien.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list