generic function with structural types questions
# Yuh-Ruey Chen (18 years ago)
By "fixed", do you mean an RI bug or a spec issue? If it's just an RI bug, can you tell me what those exprs are supposed to evaluate to?
-Yuh-Ruey Chen
By "fixed", do you mean an RI bug or a spec issue? If it's just an RI bug, can you tell me what those exprs are supposed to evaluate to? -Yuh-Ruey Chen Lars T Hansen wrote: > At present, generic functions do not discriminate on structural types. > This probably needs to be fixed, but I've not looked into it. > > --lars > > On 11/12/07, Yuh-Ruey Chen <maian330 at gmail.com> wrote: > > Given the following definitions: > > > > class C {var p: int}; > > type S1 = {p: int}; > > type S2 = {p: int, p2: double}; > > generic function foo(x); > > generic function foo(x: *) 0 > > generic function foo(x: C) 1 > > generic function foo(x: S1) 2 > > generic function foo(x: S2) 3 > > generic function foo(x: like S1) 4 > > generic function foo(x: like S2) 5 > > var o1: C = new C(); > > var o2: S1 = {p: 10}; > > var o3: S2 = {p: 10, p2: 3.14}; > > var o4 = {p: 10}; > > var o5 = {p: 10, p2: 3.14}; > > var o6 = {p: 10, p2: 3.14, p3: "hi"}; > > > > What do the following exprs evaluate to? > > foo(o1); > > foo(o2); > > foo(o3); > > foo(o4); > > foo(o5); > > foo(o6); > > > > Also, I know that S1 <: Object, but is S2 <: S1? I've looked at > > http://wiki.ecmascript.org/doku.php?id=clarification:type_system and > > it's not clear to me. Is it still true that C <: S1? > > > > -Yuh-Ruey Chen > > _______________________________________________ > > Es4-discuss mailing list > > Es4-discuss at mozilla.org > > https://mail.mozilla.org/listinfo/es4-discuss > > > >
# Lars Hansen (18 years ago)
It's a spec issue.
It's a spec issue. --lars > -----Original Message----- > From: es4-discuss-bounces at mozilla.org > [mailto:es4-discuss-bounces at mozilla.org] On Behalf Of Yuh-Ruey Chen > Sent: 15. november 2007 01:53 > To: Lars T Hansen > Cc: es4-discuss > Subject: Re: generic function with structural types questions > > By "fixed", do you mean an RI bug or a spec issue? If it's > just an RI bug, can you tell me what those exprs are supposed > to evaluate to? > > -Yuh-Ruey Chen > > Lars T Hansen wrote: > > At present, generic functions do not discriminate on > structural types. > > This probably needs to be fixed, but I've not looked into it. > > > > --lars > > > > On 11/12/07, Yuh-Ruey Chen <maian330 at gmail.com> wrote: > > > Given the following definitions: > > > > > > class C {var p: int}; > > > type S1 = {p: int}; > > > type S2 = {p: int, p2: double}; > > > generic function foo(x); > > > generic function foo(x: *) 0 > > > generic function foo(x: C) 1 > > > generic function foo(x: S1) 2 > > > generic function foo(x: S2) 3 > > > generic function foo(x: like S1) 4 > > > generic function foo(x: like S2) 5 > > > var o1: C = new C(); > > > var o2: S1 = {p: 10}; > > > var o3: S2 = {p: 10, p2: 3.14}; > > > var o4 = {p: 10}; > > > var o5 = {p: 10, p2: 3.14}; > > > var o6 = {p: 10, p2: 3.14, p3: "hi"}; > > > > > > What do the following exprs evaluate to? > > > foo(o1); > > > foo(o2); > > > foo(o3); > > > foo(o4); > > > foo(o5); > > > foo(o6); > > > > > > Also, I know that S1 <: Object, but is S2 <: S1? I've looked at > > > > http://wiki.ecmascript.org/doku.php?id=clarification:type_system and > > > it's not clear to me. Is it still true that C <: S1? > > > > > > -Yuh-Ruey Chen > > > _______________________________________________ > > > Es4-discuss mailing list > > > Es4-discuss at mozilla.org > > > https://mail.mozilla.org/listinfo/es4-discuss > > > > > > > > _______________________________________________ > Es4-discuss mailing list > Es4-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es4-discuss >
Given the following definitions:
class C {var p: int}; type S1 = {p: int}; type S2 = {p: int, p2: double}; generic function foo(x); generic function foo(x: *) 0 generic function foo(x: C) 1 generic function foo(x: S1) 2 generic function foo(x: S2) 3 generic function foo(x: like S1) 4 generic function foo(x: like S2) 5 var o1: C = new C(); var o2: S1 = {p: 10}; var o3: S2 = {p: 10, p2: 3.14}; var o4 = {p: 10}; var o5 = {p: 10, p2: 3.14}; var o6 = {p: 10, p2: 3.14, p3: "hi"};
What do the following exprs evaluate to? foo(o1); foo(o2); foo(o3); foo(o4); foo(o5); foo(o6);
Also, I know that S1 <: Object, but is S2 <: S1? I've looked at clarification:type_system and it's not clear to me. Is it still true that C <: S1?
-Yuh-Ruey Chen