Re: [vwnc] Squeak-Extensions' #(begins|ends)With:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Squeak-Extensions' #(begins|ends)With:

Eliot Miranda-2
Hi Folks,

    Boris raised a fun one.  See below.  If y'all agree find a fix attached.

On Thu, Nov 19, 2009 at 4:23 AM, Boris Popov, DeepCove Labs (YVR) <[hidden email]> wrote:

Am I alone thinking these answers should be a bit more consistent?

 

'' beginsWith: '' true

'' endsWith: '' false

'abc' beginsWith: '' true

'abc' endsWith: '' false

 

Specifically, any string should end with an empty substring just like any string begins with an empty substring IMHO.

 

-Boris


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc





endsWithFixes.st (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Re: [vwnc] Squeak-Extensions' #(begins|ends)With:

David T. Lewis
On Thu, Nov 19, 2009 at 09:25:30AM -0800, Eliot Miranda wrote:

> Hi Folks,
>
>     Boris raised a fun one.  See below.  If y'all agree find a fix attached.
>
> On Thu, Nov 19, 2009 at 4:23 AM, Boris Popov, DeepCove Labs (YVR) <
> [hidden email]> wrote:
>
> >  Am I alone thinking these answers should be a bit more consistent?
> >
> > '' beginsWith: '' true
> >
> > '' endsWith: '' false
> >
> > 'abc' beginsWith: '' true
> >
> > 'abc' endsWith: '' false
> >
> > Specifically, any string should end with an empty substring just like any
> > string begins with an empty substring IMHO.
> >

On Squeak we currently have this:

  '' beginsWith: '' ==> false
  '' endsWith: '' ==> false
  'abc' beginsWith: '' ==> false
  'abc' endsWith: '' ==> false

And your patch would change it to this:
 
  '' beginsWith: '' ==> false
  '' endsWith: '' ==> true
  'abc' beginsWith: '' ==> false
  'abc' endsWith: '' ==> true
 
Which is clearly not the intended result.

The current Squeak behavior is quite well established, going back to at
least Squeak 2.8 (I checked on old image). Also, in Squeak we have this:

  #(1 2 3 4) beginsWith: #() ==> false
  #(1 2 3 4) endsWith: #() ==> false

So Squeak is internally consistent, and has not changed its behavior
in many years. Given that VW is not internally consistent, wouldn't it
be better to change VW to match Squeak?
 
Dave