<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote"><span class="q">The problem is that may not be uniquely defined. If you have<br> :- mode foo(out,out) is multi.
<br> :- mode foo(in, out) is det.<br> :- mode foo(out, in) is det.<br>and call it in mode (in,in), which mode "most closely matches" the state of the<br>variables? The only thing you can be sure of is that it's not the first one.
</span></blockquote><div><br>You have a point there.<br><br>I see a couple of options:<br><ol><li>Change nothing and very explicitly document the behavior. This doesn't take much time but might confuse those that don't get that far in the documentation.
</li><li>Call using foo(in, in) an error if foo(in, out) and foo(out, in) are defined and foo(in, in) isn't explicitly defined. This would break old code. I wouldn't be surprised if it broke the compiler. On the other hand, the fix is reasonably easy.
</li><li>From Nick: Call it an error if foo(in, in) is not defined and both foo(in, out) and foo(out, in) are defined. This has the advantage of catching the situation early but it may generate more errors and code then is needed.
<br></li><li>#2 but substitute the word warning for error and default using the order in the file, the overall mode (probably the wrong term, what I mean is det, semidet, multi, nondet, etc), or something else.<br></li><li>
#3 but substitute the word warning for error and default using the order in the file, the overall mode, or something else.</li><li>Default using the overall mode ala Peter.<br></li></ol></div>Any other ideas?<br><br>--Nik
<br><br><div><span class="gmail_quote">On 06/08/07, <b class="gmail_sendername">Nicholas Nethercote</b> <<a href="mailto:njn@csse.unimelb.edu.au" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">njn@csse.unimelb.edu.au
</a>> wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Mon, 6 Aug 2007, Peter Schachte wrote:<br><br>> The problem is that may not be uniquely defined. If you have
<br>><br>> :- mode foo(out,out) is multi.<br>> :- mode foo(in, out) is det.<br>> :- mode foo(out, in) is det.<br>><br>> and call it in mode (in,in), which mode "most closely matches" the state of the
<br>> variables? The only thing you can be sure of is that it's not the first one.<br>> If you instead have<br>><br>> :- mode foo(out,out) is multi.<br>> :- mode foo(in, out) is nondet.<br>
> :- mode foo(out, in) is semidet.<br>><br>> would you expect Mercury to prefer the semidet mode over the nondet one, and<br>> choose the third? That'd be nice.<br><br>We have a similar thing in Zinc with overloading, and solve it by requiring
<br>that there be a version that is the glb of all the different signatures.<br><br>Eg. if you have<br><br> f(int, float) -> float<br> f(float, int) -> float<br><br>you also have to provide<br><br> f(int, int) -> float
<br><br>which is the glb of the other two. (Zinc has automatic int-to-float<br>coercions, which is why this is required.)<br><br>The question for Mercury then becomes: what is the glb mean over modes and<br>determinisms? For 'foo' above, I would guess:
<br><br> :- mode foo(in, in) is det.<br><br>But maybe there are other complications I'm unaware of.<br><br>Nick<br>--------------------------------------------------------------------------<br>mercury-users mailing list
<br>Post messages to: <a href="mailto:mercury-users@csse.unimelb.edu.au" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">mercury-users@csse.unimelb.edu.au</a><br>Administrative Queries: <a href="mailto:owner-mercury-users@csse.unimelb.edu.au" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
owner-mercury-users@csse.unimelb.edu.au
</a><br>Subscriptions: <a href="mailto:mercury-users-request@csse.unimelb.edu.au" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">mercury-users-request@csse.unimelb.edu.au</a><br>--------------------------------------------------------------------------
<br></blockquote>
</div><br>