[dylan] ^known-disjoint? and singleton / union subtyping

Bruce Mitchener <[email protected]> Sat, 7 Jun 2014 11:58:19 +0700
Newsgroups gmane.comp.lang.dylan.gwydion.devel
Message-ID <CA+esKjN6b25F261Om1p+d9gX3VQLu079x0y-5EvnbmXPJN0rvQ@mail.gmail.com>
--===============2083677584==
Content-Type: multipart/alternative; boundary=001a11c3a99aaa5aa504fb37d366

--001a11c3a99aaa5aa504fb37d366
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hello all (and especially hannes and housel):

I've been working (among other things) on fixing some of the warnings we
get from the runtime about ambiguous methods.

As a result, I added these tiebreakers to dfmc/modeling the other day:

  // Tiebreaker methods

  define method ^known-disjoint? (t1 :: <&singleton>, t2 :: <&union>)
   =3D> (known-disjoint? :: <boolean>)
    ^known-disjoint?(t1.^singleton-object, t2)
  end method ^known-disjoint?;

  define method ^known-disjoint? (t1 :: <&union>, t2 :: <&singleton>)
   =3D> (known-disjoint? :: <boolean>)
    ^known-disjoint?(t1, t2.^singleton-object)
  end method ^known-disjoint?;

Interestingly, these are fine on the C backend, but in HARP, we now get a
build failure when building tests due to a No-Applicable-Methods from
invoking ^known-disjoint?(#f, <union>)

Now, the rules for singleton subtyping:

    subtype? on singletons is defined by object type and identity. If x is
an
    object and t is a type, subtype?(singleton(x), t) will be true only
    if instance?(x, t) is true.

And the rules for union subtyping:

subtype?(type-union*(t*1*=E2=80=A6t*n*), s*1*) will be true if and only if =
subtype?(
t, s*1*) is true for every t in t*1*=E2=80=A6t*n*.

subtype?(s*1*, type-union*(t*1*=E2=80=A6t*n*)) will be true if and only if =
subtype?(
s*1*, t) is true for some t in t*1*=E2=80=A6t*n*.

subtype?(type-union*(s*1*=E2=80=A6s*m*), type-union*(t*1*=E2=80=A6t*n*)) wi=
ll be true if
and only if every s in s*1*=E2=80=A6s*m* is a subtype of some t in t*1*=E2=
=80=A6t*n*.

It looks like I need better definitions of ^known-disjoint? for my
tiebreakers.

Anyone have some thoughts on this? (I'm rather busy with some other things
this weekend.)

 - Bruce

--001a11c3a99aaa5aa504fb37d366
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hello all (and especially hannes and housel):</div><d=
iv><br></div><div>I&#39;ve been working (among other things) on fixing some=
 of the warnings we get from the runtime about ambiguous methods.</div><div=
>
<br></div><div>As a result, I added these tiebreakers to dfmc/modeling the =
other day:</div><div><br></div><div><div>=C2=A0 // Tiebreaker methods</div>=
<div><br></div><div>=C2=A0 define method ^known-disjoint? (t1 :: &lt;&amp;s=
ingleton&gt;, t2 :: &lt;&amp;union&gt;)</div>
<div>=C2=A0 =C2=A0=3D&gt; (known-disjoint? :: &lt;boolean&gt;)</div><div>=
=C2=A0 =C2=A0 ^known-disjoint?(t1.^singleton-object, t2)</div><div>=C2=A0 e=
nd method ^known-disjoint?;</div><div><br></div><div>=C2=A0 define method ^=
known-disjoint? (t1 :: &lt;&amp;union&gt;, t2 :: &lt;&amp;singleton&gt;)</d=
iv>
<div>=C2=A0 =C2=A0=3D&gt; (known-disjoint? :: &lt;boolean&gt;)</div><div>=
=C2=A0 =C2=A0 ^known-disjoint?(t1, t2.^singleton-object)</div><div>=C2=A0 e=
nd method ^known-disjoint?;</div></div><div><br></div><div>Interestingly, t=
hese are fine on the C backend, but in HARP, we now get a build failure whe=
n building tests due to a No-Applicable-Methods from invoking ^known-disjoi=
nt?(#f, &lt;union&gt;)</div>
<div><br></div><div>Now, the rules for singleton subtyping:</div><div><br><=
/div><div>=C2=A0 =C2=A0=C2=A0<a name=3D"IX-548" style=3D"color:black;font-f=
amily:Times;font-size:medium;background-color:rgb(221,238,255)"><code>subty=
pe?</code>=C2=A0on singletons</a><span style=3D"color:rgb(0,0,0);font-famil=
y:Times;font-size:medium">=C2=A0</span><span style=3D"color:rgb(0,0,0);font=
-family:Times;font-size:medium">is defined by object type and identity. If<=
/span><span style=3D"color:rgb(0,0,0);font-family:Times;font-size:medium">=
=C2=A0</span><var style=3D"color:rgb(0,0,0);font-size:medium;font-family:se=
rif">x</var><span style=3D"color:rgb(0,0,0);font-family:Times;font-size:med=
ium">=C2=A0</span><span style=3D"color:rgb(0,0,0);font-family:Times;font-si=
ze:medium">is an</span></div>
<div><span style=3D"color:rgb(0,0,0);font-family:Times;font-size:medium">=
=C2=A0 =C2=A0 object and</span><span style=3D"color:rgb(0,0,0);font-family:=
Times;font-size:medium">=C2=A0</span><var style=3D"color:rgb(0,0,0);font-si=
ze:medium;font-family:serif">t</var><span style=3D"color:rgb(0,0,0);font-fa=
mily:Times;font-size:medium">=C2=A0</span><span style=3D"color:rgb(0,0,0);f=
ont-family:Times;font-size:medium">is a type,</span><span style=3D"color:rg=
b(0,0,0);font-family:Times;font-size:medium">=C2=A0</span><code style=3D"co=
lor:rgb(0,0,0)">subtype?(singleton(<var style=3D"font-family:serif">x</var>=
),=C2=A0<var style=3D"font-family:serif">t</var>)</code><span style=3D"colo=
r:rgb(0,0,0);font-family:Times;font-size:medium">=C2=A0</span><span style=
=3D"color:rgb(0,0,0);font-family:Times;font-size:medium">will be true only<=
/span></div>
<div><span style=3D"color:rgb(0,0,0);font-family:Times;font-size:medium">=
=C2=A0 =C2=A0 if</span><span style=3D"color:rgb(0,0,0);font-family:Times;fo=
nt-size:medium">=C2=A0</span><code style=3D"color:rgb(0,0,0)">instance?(<va=
r style=3D"font-family:serif">x</var>,=C2=A0<var style=3D"font-family:serif=
">t</var>)</code><span style=3D"color:rgb(0,0,0);font-family:Times;font-siz=
e:medium">=C2=A0</span><span style=3D"color:rgb(0,0,0);font-family:Times;fo=
nt-size:medium">is true.</span></div>
<div><br></div><div>And the rules for union subtyping:</div><div><br></div>=
<div><p style=3D"color:rgb(0,0,0);font-family:Times;font-size:medium"><code=
>subtype?(type-union*(<var style=3D"font-family:serif">t<em><sub>1</sub></e=
m></var>=E2=80=A6<var style=3D"font-family:serif">t<em><sub>n</sub></em></v=
ar>),=C2=A0<var style=3D"font-family:serif">s<em><sub>1</sub></em></var>)</=
code>=C2=A0will be true if and only if=C2=A0<code>subtype?(<var style=3D"fo=
nt-family:serif">t</var>,=C2=A0<var style=3D"font-family:serif">s<em><sub>1=
</sub></em></var>)</code>=C2=A0is true for every=C2=A0<var style=3D"font-fa=
mily:serif">t</var>=C2=A0in=C2=A0<var style=3D"font-family:serif">t<em><sub=
>1</sub></em></var>=E2=80=A6<var style=3D"font-family:serif">t<em><sub>n</s=
ub></em></var>.</p>
<p style=3D"color:rgb(0,0,0);font-family:Times;font-size:medium"><code>subt=
ype?(<var style=3D"font-family:serif">s<em><sub>1</sub></em></var>, type-un=
ion*(<var style=3D"font-family:serif">t<em><sub>1</sub></em></var>=E2=80=A6=
<var style=3D"font-family:serif">t<em><sub>n</sub></em></var>))</code>=C2=
=A0will be true if and only if=C2=A0<code>subtype?(<var style=3D"font-famil=
y:serif">s<em><sub>1</sub></em></var>,=C2=A0<var style=3D"font-family:serif=
">t</var>)</code>=C2=A0is true for some=C2=A0<var style=3D"font-family:seri=
f">t</var>=C2=A0in=C2=A0<var style=3D"font-family:serif">t<em><sub>1</sub><=
/em></var>=E2=80=A6<var style=3D"font-family:serif">t<em><sub>n</sub></em><=
/var>.</p>
<p style=3D"color:rgb(0,0,0);font-family:Times;font-size:medium"><code>subt=
ype?(type-union*(<var style=3D"font-family:serif">s<em><sub>1</sub></em></v=
ar>=E2=80=A6<var style=3D"font-family:serif">s<em><sub>m</sub></em></var>),=
 type-union*(<var style=3D"font-family:serif">t<em><sub>1</sub></em></var>=
=E2=80=A6<var style=3D"font-family:serif">t<em><sub>n</sub></em></var>))</c=
ode>=C2=A0will be true if and only if every=C2=A0<var style=3D"font-family:=
serif">s</var>=C2=A0in=C2=A0<var style=3D"font-family:serif">s<em><sub>1</s=
ub></em></var>=E2=80=A6<var style=3D"font-family:serif">s<em><sub>m</sub></=
em></var>=C2=A0is a subtype of some=C2=A0<var style=3D"font-family:serif">t=
</var>=C2=A0in=C2=A0<var style=3D"font-family:serif">t<em><sub>1</sub></em>=
</var>=E2=80=A6<var style=3D"font-family:serif">t<em><sub>n</sub></em></var=
>.</p>
</div><div><br></div><div>It looks like I need better definitions of ^known=
-disjoint? for my tiebreakers.</div><div><br></div><div>Anyone have some th=
oughts on this? (I&#39;m rather busy with some other things this weekend.)<=
/div>
<div><br></div><div>=C2=A0- Bruce</div><div><br></div></div>

--001a11c3a99aaa5aa504fb37d366--

--===============2083677584==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
hackers mailing list
[email protected]
https://lists.opendylan.org/mailman/listinfo/hackers

--===============2083677584==--