Probably a bug

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

Probably a bug

Göran Krampe
Hi!

Just wanted to mention this, stumbled over it:

        Character separators asString

...doesn't seem to do give us the right thing :) along the way there.

Perhaps Sean stumbled over this too with Todd's HTML parser, that is
where I saw the issue at least. So obviously something is different in
Pharo these days.

regards, Göran

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Probably a bug

Nicolas Cellier
Maybe try

    Character separators as: String

Nicolas

2010/8/19 Göran Krampe <[hidden email]>:

> Hi!
>
> Just wanted to mention this, stumbled over it:
>
>        Character separators asString
>
> ...doesn't seem to do give us the right thing :) along the way there.
>
> Perhaps Sean stumbled over this too with Todd's HTML parser, that is where I
> saw the issue at least. So obviously something is different in Pharo these
> days.
>
> regards, Göran
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Probably a bug

Henrik Sperre Johansen
In reply to this post by Göran Krampe
What would you say the right thing is?

Cheers,
Henry

On Aug 19, 2010, at 1:39 14PM, Göran Krampe wrote:

> Hi!
>
> Just wanted to mention this, stumbled over it:
>
> Character separators asString
>
> ...doesn't seem to do give us the right thing :) along the way there.
>
> Perhaps Sean stumbled over this too with Todd's HTML parser, that is where I saw the issue at least. So obviously something is different in Pharo these days.
>
> regards, Göran
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Probably a bug

Göran Krampe
On 08/19/2010 02:03 PM, Henrik Johansen wrote:
> What would you say the right thing is?

Well, intuitively I would say that converting an Array of Character
instances (say 5 instances) using "asString" would give me a String of
size 5. Also, "Character space asString" does NOT give me 'Character
space' but actually ' '.

Having a fallback on printString is of course fine, in Object. But...
well, I haven't thought *deeply* on this, but a sequencable collection
of Characters should IMHO be able to produce a String, and not a
"printString" so to speak.

regards, Göran

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Probably a bug

Stéphane Ducasse
did you check the senders of asString?
Because I would like to assess the cost of changing asString from its printString semantics.

Stef

On Aug 19, 2010, at 3:09 PM, Göran Krampe wrote:

> On 08/19/2010 02:03 PM, Henrik Johansen wrote:
>> What would you say the right thing is?
>
> Well, intuitively I would say that converting an Array of Character instances (say 5 instances) using "asString" would give me a String of size 5. Also, "Character space asString" does NOT give me 'Character space' but actually ' '.
>
> Having a fallback on printString is of course fine, in Object. But... well, I haven't thought *deeply* on this, but a sequencable collection of Characters should IMHO be able to produce a String, and not a "printString" so to speak.
>
> regards, Göran
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Probably a bug

Henrik Sperre Johansen
In reply to this post by Göran Krampe


On Aug 19, 2010, at 3:09 42PM, Göran Krampe wrote:

> On 08/19/2010 02:03 PM, Henrik Johansen wrote:
>> What would you say the right thing is?
>
> Well, intuitively I would say that converting an Array of Character instances (say 5 instances) using "asString" would give me a String of size 5. Also, "Character space asString" does NOT give me 'Character space' but actually ' '.
Maybe its just me, but I'd rather not have
SequenceableCollection >> asString mean "If I contain only elements which may represent characters, return a string containing those, if not, return my printString"

>
> Having a fallback on printString is of course fine, in Object. But... well, I haven't thought *deeply* on this, but a sequencable collection of Characters should IMHO be able to produce a String
> regards, Göran

And it is, using either
collection as: String, or
String withAll: collection
In both cases you then explicitly specify that this collection will contain only elements which can be converted to a string, rather than have a later reader of the code have to question "hmmm, does the use of asString here mean he'll be using the collections printString, or the string with its elements?"

Cheers,
Henry
_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Probably a bug

Sean P. DeNigris
Administrator
In reply to this post by Göran Krampe
Göran Krampe wrote
Perhaps Sean stumbled over this too with Todd's HTML parser.
I just made some basic syntax fixes and removed underscore assignments.  I never executed anything (except class-side initialization)!

Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Probably a bug

Stéphane Ducasse
In reply to this post by Henrik Sperre Johansen
>>> What would you say the right thing is?
>>
>> Well, intuitively I would say that converting an Array of Character instances (say 5 instances) using "asString" would give me a String of size 5. Also, "Character space asString" does NOT give me 'Character space' but actually ' '.
> Maybe its just me, but I'd rather not have
> SequenceableCollection >> asString mean "If I contain only elements which may represent characters, return a string containing those, if not, return my printString"


yes you are not the only one. Thanks I was thinking about that after my post :)

>> Having a fallback on printString is of course fine, in Object. But... well, I haven't thought *deeply* on this, but a sequencable collection of Characters should IMHO be able to produce a String
>> regards, Göran
>
> And it is, using either
> collection as: String, or
> String withAll: collection
> In both cases you then explicitly specify that this collection will contain only elements which can be converted to a string, rather than have a later reader of the code have to question "hmmm, does the use of asString here mean he'll be using the collections printString, or the string with its elements?"

I'm curious about the senders of asString, especially to collection.

Stef
_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Probably a bug

Göran Krampe
On 08/19/2010 09:53 PM, Stéphane Ducasse wrote:

>>>> What would you say the right thing is?
>>>
>>> Well, intuitively I would say that converting an Array of Character instances (say 5 instances) using "asString" would give me a String of size 5. Also, "Character space asString" does NOT give me 'Character space' but actually ' '.
>> Maybe its just me, but I'd rather not have
>> SequenceableCollection>>  asString mean "If I contain only elements which may represent characters, return a string containing those, if not, return my printString"
>
>
> yes you are not the only one. Thanks I was thinking about that after my post :)
>
>>> Having a fallback on printString is of course fine, in Object. But... well, I haven't thought *deeply* on this, but a sequencable collection of Characters should IMHO be able to produce a String
>>> regards, Göran
>>
>> And it is, using either
>> collection as: String, or
>> String withAll: collection
>> In both cases you then explicitly specify that this collection will contain only elements which can be converted to a string, rather than have a later reader of the code have to question "hmmm, does the use of asString here mean he'll be using the collections printString, or the string with its elements?"
>
> I'm curious about the senders of asString, especially to collection.
>
> Stef

I am all in agreement I think, my gut reaction was that, darn, something
is broken. But perhaps sending asString to a Collection of objects
should... well, what *should* it return?

I think possibly one of the problems in all this is the fallback on
printString - that has clearly muddled the waters IMHO. #printString is
for the tools, it should give a "readable representation". But #asString
is a conversion method - it should give me IMHO the most reasonable
conversion for further "use".

I agree that #as: etc might be a "better" protocol, but let's say we
still want #asString to work for Collections and NOT fall back on
#printString - then what should it do?

regards, Göran

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Probably a bug

Eliot Miranda-2


2010/8/19 Göran Krampe <[hidden email]>
On 08/19/2010 09:53 PM, Stéphane Ducasse wrote:
What would you say the right thing is?

Well, intuitively I would say that converting an Array of Character instances (say 5 instances) using "asString" would give me a String of size 5. Also, "Character space asString" does NOT give me 'Character space' but actually ' '.
Maybe its just me, but I'd rather not have
SequenceableCollection>>  asString mean "If I contain only elements which may represent characters, return a string containing those, if not, return my printString"


yes you are not the only one. Thanks I was thinking about that after my post :)

Having a fallback on printString is of course fine, in Object. But... well, I haven't thought *deeply* on this, but a sequencable collection of Characters should IMHO be able to produce a String
regards, Göran

And it is, using either
collection as: String, or
String withAll: collection
In both cases you then explicitly specify that this collection will contain only elements which can be converted to a string, rather than have a later reader of the code have to question "hmmm, does the use of asString here mean he'll be using the collections printString, or the string with its elements?"

I'm curious about the senders of asString, especially to collection.

Stef

I am all in agreement I think, my gut reaction was that, darn, something is broken. But perhaps sending asString to a Collection of objects should... well, what *should* it return?

I think possibly one of the problems in all this is the fallback on printString - that has clearly muddled the waters IMHO. #printString is for the tools, it should give a "readable representation". But #asString is a conversion method - it should give me IMHO the most reasonable conversion for further "use".

I agree that #as: etc might be a "better" protocol, but let's say we still want #asString to work for Collections and NOT fall back on #printString - then what should it do?

If aCollection asArray = (aCollection as: Array) then surely aCollection asString = (aCollection as: String)
If ([aCollection as: String. nil] on: Error do: [:ex| ex]) notNil then surely
    ([aCollection as: String. nil] on: Error do: [:ex| ex messageText]) = ([aCollection asString. nil] on: Error do: [:ex| ex messageText])
i.e. if aCollection doesn't include characters both forms should return errors.

I find the Object implementation of asString distasteful, but that's juts my taste.  However, I find Collection's inheriting of that definition badly broken.
my 2¢

best
Eliot


regards, Göran

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Probably a bug

Stéphane Ducasse
I checked a bit the senders of asString and the problem is that they often confused printString and asString.

Like kent beck I do not like conversion methods between object that do not have the same API
        ie aBag asSet is ok but aString asUrl is not good for me.

I understand aText asString
but not really aColor asString, I would prefer a Color printString especially since asString seems inherited from
Object and calling printString.

Stef
_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Probably a bug

Alexandre Bergel
+1

On 19 Aug 2010, at 18:03, Stéphane Ducasse wrote:

> I checked a bit the senders of asString and the problem is that they often confused printString and asString.
>
> Like kent beck I do not like conversion methods between object that do not have the same API
> ie aBag asSet is ok but aString asUrl is not good for me.
>
> I understand aText asString
> but not really aColor asString, I would prefer a Color printString especially since asString seems inherited from
> Object and calling printString.
>
> Stef
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.






_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project