Re: "" : List[String]

Mark Miller <[email protected]>
Newsgroups gmane.comp.lang.e.general
Message-ID <[email protected]>
On Tue, Apr 27, 2010 at 10:21 AM, Kevin Reid <kpreid-M/[email protected]> wrote:

> On Apr 27, 2010, at 11:03, Thomas Leonard wrote:
>
> > This surprised me:
> >
> > ? "" : List[String]
> > # value: ""
> >
> > ? "" : List[int]
> > # value: []
> >
> > I was calling TreeItem.setText(str). When str is the empty string it
> > coerces to a list of strings and you get "Ambiguous overload on class
> > org.eclipse.swt.widgets.TableItem: setText(String) vs
> > setText(String[])".
> >
> > Is this intentional?
>
> It isn deliberate that String is a subtype of ConstList.
>
> I do not care for this choice, because things which want lists usually
> don't want strings-of-characters, and because it breaks the property
> we would otherwise have that if a :List and b :List have the same
> elements, they are ==.
>
> The list guard returning "" is evidently because the "cheap success"
> case in ListGuard passed, because the element guard is a ClassDesc.
> That this code has this behavior in one optimization-based case and
> not in another seems to me more evidence that "" being a ConstList is
> a bad idea.
>
> (Having String be a subtype of EList, the mutable-or-immutable-list
> type, would seem to me to serve the same acknowledge-the-protocol-
> inheritance purpose and be safer.)
>
> But, I wouldn't want to make this kind of significant change without
> consulting MarkM.
>

I have no objection to trying to make this change. Once we try and see what
breaks, we'll have much better information. If there are no surprises, I
have no objection to making this change permanent.



>
> --
> Kevin Reid                                  <http://switchb.org/kpreid/>
>
>
>
>
> _______________________________________________
> e-lang mailing list
> [email protected]
> http://www.eros-os.org/mailman/listinfo/e-lang
>



-- 
Text by me above is hereby placed in the public domain

   Cheers,
   --MarkM

_______________________________________________
e-lang mailing list
[email protected]
http://www.eros-os.org/mailman/listinfo/e-lang
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.