primitiveTranslateStringWithTable

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

primitiveTranslateStringWithTable

Florin Mateoc-4
 
Hi,

While looking at some of the more exotic primitives, I stumbled upon this little gem.
I think it's bad enough that it modifies strings in place (some of those could be method literals), but it even modifies symbols in place, without adding them to the symbol table.

I would say this is a bug, I don't think symbols should be modified in place (other than by the #intern: method), but this does not look unintentional - apparently ByteSymbol class >> #translate:from:to:table: was added specifically to make the primitive work on symbols too.

Does anybody have any insight into this, is this functionality (modifying symbols in place) used anywhere?

Thank you,
Florin

Reply | Threaded
Open this post in threaded view
|

Re: primitiveTranslateStringWithTable

Nicolas Cellier
 
Hi Florin,
did you try it? It should fail if passing a literal (ModificationForbidden).
I see that it's only ever sent to copy asString, for case translation
or converting lineEndings...

Le mer. 21 avr. 2021 à 01:17, Florin Mateoc <[hidden email]> a écrit :

>
>
> Hi,
>
> While looking at some of the more exotic primitives, I stumbled upon this little gem.
> I think it's bad enough that it modifies strings in place (some of those could be method literals), but it even modifies symbols in place, without adding them to the symbol table.
>
> I would say this is a bug, I don't think symbols should be modified in place (other than by the #intern: method), but this does not look unintentional - apparently ByteSymbol class >> #translate:from:to:table: was added specifically to make the primitive work on symbols too.
>
> Does anybody have any insight into this, is this functionality (modifying symbols in place) used anywhere?
>
> Thank you,
> Florin
>
Reply | Threaded
Open this post in threaded view
|

Re: primitiveTranslateStringWithTable

Florin Mateoc-4
 
Hi Nicolas,

I did try it. After making sure a string was not interned, ( "Symbol findInterned: 'test123'" return nil ), I did

| s | s := #TEST123.
s translateToLowercase.
Symbol findInterned: s

and the resulting s is a Symbol and it is not interned

Florin

On Wed, Apr 21, 2021 at 2:06 AM Nicolas Cellier <[hidden email]> wrote:
 
Hi Florin,
did you try it? It should fail if passing a literal (ModificationForbidden).
I see that it's only ever sent to copy asString, for case translation
or converting lineEndings...

Le mer. 21 avr. 2021 à 01:17, Florin Mateoc <[hidden email]> a écrit :
>
>
> Hi,
>
> While looking at some of the more exotic primitives, I stumbled upon this little gem.
> I think it's bad enough that it modifies strings in place (some of those could be method literals), but it even modifies symbols in place, without adding them to the symbol table.
>
> I would say this is a bug, I don't think symbols should be modified in place (other than by the #intern: method), but this does not look unintentional - apparently ByteSymbol class >> #translate:from:to:table: was added specifically to make the primitive work on symbols too.
>
> Does anybody have any insight into this, is this functionality (modifying symbols in place) used anywhere?
>
> Thank you,
> Florin
>
Reply | Threaded
Open this post in threaded view
|

Re: primitiveTranslateStringWithTable

Nicolas Cellier
 
Hmm OK,
on a recently recompiled spur 64bits VM I've got errorNoModification,
maybe because the optional primitive is missing?
On 32 bits spur VM though, I get the behavior that you described.

Le mer. 21 avr. 2021 à 14:54, Florin Mateoc <[hidden email]> a écrit :

>
>
> Hi Nicolas,
>
> I did try it. After making sure a string was not interned, ( "Symbol findInterned: 'test123'" return nil ), I did
>
> | s | s := #TEST123.
> s translateToLowercase.
> Symbol findInterned: s
>
> and the resulting s is a Symbol and it is not interned
>
> Florin
>
> On Wed, Apr 21, 2021 at 2:06 AM Nicolas Cellier <[hidden email]> wrote:
>>
>>
>> Hi Florin,
>> did you try it? It should fail if passing a literal (ModificationForbidden).
>> I see that it's only ever sent to copy asString, for case translation
>> or converting lineEndings...
>>
>> Le mer. 21 avr. 2021 à 01:17, Florin Mateoc <[hidden email]> a écrit :
>> >
>> >
>> > Hi,
>> >
>> > While looking at some of the more exotic primitives, I stumbled upon this little gem.
>> > I think it's bad enough that it modifies strings in place (some of those could be method literals), but it even modifies symbols in place, without adding them to the symbol table.
>> >
>> > I would say this is a bug, I don't think symbols should be modified in place (other than by the #intern: method), but this does not look unintentional - apparently ByteSymbol class >> #translate:from:to:table: was added specifically to make the primitive work on symbols too.
>> >
>> > Does anybody have any insight into this, is this functionality (modifying symbols in place) used anywhere?
>> >
>> > Thank you,
>> > Florin
>> >
Reply | Threaded
Open this post in threaded view
|

Re: primitiveTranslateStringWithTable

Florin Mateoc-4
 
Yes, you are most likely getting the errorNoModification only because of the primitive fallback code

On Wed, Apr 21, 2021 at 1:52 PM Nicolas Cellier <[hidden email]> wrote:
 
Hmm OK,
on a recently recompiled spur 64bits VM I've got errorNoModification,
maybe because the optional primitive is missing?
On 32 bits spur VM though, I get the behavior that you described.

Le mer. 21 avr. 2021 à 14:54, Florin Mateoc <[hidden email]> a écrit :
>
>
> Hi Nicolas,
>
> I did try it. After making sure a string was not interned, ( "Symbol findInterned: 'test123'" return nil ), I did
>
> | s | s := #TEST123.
> s translateToLowercase.
> Symbol findInterned: s
>
> and the resulting s is a Symbol and it is not interned
>
> Florin
>
> On Wed, Apr 21, 2021 at 2:06 AM Nicolas Cellier <[hidden email]> wrote:
>>
>>
>> Hi Florin,
>> did you try it? It should fail if passing a literal (ModificationForbidden).
>> I see that it's only ever sent to copy asString, for case translation
>> or converting lineEndings...
>>
>> Le mer. 21 avr. 2021 à 01:17, Florin Mateoc <[hidden email]> a écrit :
>> >
>> >
>> > Hi,
>> >
>> > While looking at some of the more exotic primitives, I stumbled upon this little gem.
>> > I think it's bad enough that it modifies strings in place (some of those could be method literals), but it even modifies symbols in place, without adding them to the symbol table.
>> >
>> > I would say this is a bug, I don't think symbols should be modified in place (other than by the #intern: method), but this does not look unintentional - apparently ByteSymbol class >> #translate:from:to:table: was added specifically to make the primitive work on symbols too.
>> >
>> > Does anybody have any insight into this, is this functionality (modifying symbols in place) used anywhere?
>> >
>> > Thank you,
>> > Florin
>> >
Reply | Threaded
Open this post in threaded view
|

Re: primitiveTranslateStringWithTable

Nicolas Cellier
 
Florin, would you mind opening an issue here?
https://github.com/OpenSmalltalk/opensmalltalk-vm/issues

Le mer. 21 avr. 2021 à 19:59, Florin Mateoc <[hidden email]> a écrit :

>
>
> Yes, you are most likely getting the errorNoModification only because of the primitive fallback code
>
> On Wed, Apr 21, 2021 at 1:52 PM Nicolas Cellier <[hidden email]> wrote:
>>
>>
>> Hmm OK,
>> on a recently recompiled spur 64bits VM I've got errorNoModification,
>> maybe because the optional primitive is missing?
>> On 32 bits spur VM though, I get the behavior that you described.
>>
>> Le mer. 21 avr. 2021 à 14:54, Florin Mateoc <[hidden email]> a écrit :
>> >
>> >
>> > Hi Nicolas,
>> >
>> > I did try it. After making sure a string was not interned, ( "Symbol findInterned: 'test123'" return nil ), I did
>> >
>> > | s | s := #TEST123.
>> > s translateToLowercase.
>> > Symbol findInterned: s
>> >
>> > and the resulting s is a Symbol and it is not interned
>> >
>> > Florin
>> >
>> > On Wed, Apr 21, 2021 at 2:06 AM Nicolas Cellier <[hidden email]> wrote:
>> >>
>> >>
>> >> Hi Florin,
>> >> did you try it? It should fail if passing a literal (ModificationForbidden).
>> >> I see that it's only ever sent to copy asString, for case translation
>> >> or converting lineEndings...
>> >>
>> >> Le mer. 21 avr. 2021 à 01:17, Florin Mateoc <[hidden email]> a écrit :
>> >> >
>> >> >
>> >> > Hi,
>> >> >
>> >> > While looking at some of the more exotic primitives, I stumbled upon this little gem.
>> >> > I think it's bad enough that it modifies strings in place (some of those could be method literals), but it even modifies symbols in place, without adding them to the symbol table.
>> >> >
>> >> > I would say this is a bug, I don't think symbols should be modified in place (other than by the #intern: method), but this does not look unintentional - apparently ByteSymbol class >> #translate:from:to:table: was added specifically to make the primitive work on symbols too.
>> >> >
>> >> > Does anybody have any insight into this, is this functionality (modifying symbols in place) used anywhere?
>> >> >
>> >> > Thank you,
>> >> > Florin
>> >> >
Reply | Threaded
Open this post in threaded view
|

Re: primitiveTranslateStringWithTable

Florin Mateoc-4
 

On Wed, Apr 21, 2021 at 3:02 PM Nicolas Cellier <[hidden email]> wrote:
 
Florin, would you mind opening an issue here?
https://github.com/OpenSmalltalk/opensmalltalk-vm/issues

Le mer. 21 avr. 2021 à 19:59, Florin Mateoc <[hidden email]> a écrit :
>
>
> Yes, you are most likely getting the errorNoModification only because of the primitive fallback code
>
> On Wed, Apr 21, 2021 at 1:52 PM Nicolas Cellier <[hidden email]> wrote:
>>
>>
>> Hmm OK,
>> on a recently recompiled spur 64bits VM I've got errorNoModification,
>> maybe because the optional primitive is missing?
>> On 32 bits spur VM though, I get the behavior that you described.
>>
>> Le mer. 21 avr. 2021 à 14:54, Florin Mateoc <[hidden email]> a écrit :
>> >
>> >
>> > Hi Nicolas,
>> >
>> > I did try it. After making sure a string was not interned, ( "Symbol findInterned: 'test123'" return nil ), I did
>> >
>> > | s | s := #TEST123.
>> > s translateToLowercase.
>> > Symbol findInterned: s
>> >
>> > and the resulting s is a Symbol and it is not interned
>> >
>> > Florin
>> >
>> > On Wed, Apr 21, 2021 at 2:06 AM Nicolas Cellier <[hidden email]> wrote:
>> >>
>> >>
>> >> Hi Florin,
>> >> did you try it? It should fail if passing a literal (ModificationForbidden).
>> >> I see that it's only ever sent to copy asString, for case translation
>> >> or converting lineEndings...
>> >>
>> >> Le mer. 21 avr. 2021 à 01:17, Florin Mateoc <[hidden email]> a écrit :
>> >> >
>> >> >
>> >> > Hi,
>> >> >
>> >> > While looking at some of the more exotic primitives, I stumbled upon this little gem.
>> >> > I think it's bad enough that it modifies strings in place (some of those could be method literals), but it even modifies symbols in place, without adding them to the symbol table.
>> >> >
>> >> > I would say this is a bug, I don't think symbols should be modified in place (other than by the #intern: method), but this does not look unintentional - apparently ByteSymbol class >> #translate:from:to:table: was added specifically to make the primitive work on symbols too.
>> >> >
>> >> > Does anybody have any insight into this, is this functionality (modifying symbols in place) used anywhere?
>> >> >
>> >> > Thank you,
>> >> > Florin
>> >> >
Reply | Threaded
Open this post in threaded view
|

Re: primitiveTranslateStringWithTable

Nicolas Cellier
 
thanks!

Le mer. 21 avr. 2021 à 21:54, Florin Mateoc <[hidden email]> a écrit :

>
>
> Done
> https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/561
>
> On Wed, Apr 21, 2021 at 3:02 PM Nicolas Cellier <[hidden email]> wrote:
>>
>>
>> Florin, would you mind opening an issue here?
>> https://github.com/OpenSmalltalk/opensmalltalk-vm/issues
>>
>> Le mer. 21 avr. 2021 à 19:59, Florin Mateoc <[hidden email]> a écrit :
>> >
>> >
>> > Yes, you are most likely getting the errorNoModification only because of the primitive fallback code
>> >
>> > On Wed, Apr 21, 2021 at 1:52 PM Nicolas Cellier <[hidden email]> wrote:
>> >>
>> >>
>> >> Hmm OK,
>> >> on a recently recompiled spur 64bits VM I've got errorNoModification,
>> >> maybe because the optional primitive is missing?
>> >> On 32 bits spur VM though, I get the behavior that you described.
>> >>
>> >> Le mer. 21 avr. 2021 à 14:54, Florin Mateoc <[hidden email]> a écrit :
>> >> >
>> >> >
>> >> > Hi Nicolas,
>> >> >
>> >> > I did try it. After making sure a string was not interned, ( "Symbol findInterned: 'test123'" return nil ), I did
>> >> >
>> >> > | s | s := #TEST123.
>> >> > s translateToLowercase.
>> >> > Symbol findInterned: s
>> >> >
>> >> > and the resulting s is a Symbol and it is not interned
>> >> >
>> >> > Florin
>> >> >
>> >> > On Wed, Apr 21, 2021 at 2:06 AM Nicolas Cellier <[hidden email]> wrote:
>> >> >>
>> >> >>
>> >> >> Hi Florin,
>> >> >> did you try it? It should fail if passing a literal (ModificationForbidden).
>> >> >> I see that it's only ever sent to copy asString, for case translation
>> >> >> or converting lineEndings...
>> >> >>
>> >> >> Le mer. 21 avr. 2021 à 01:17, Florin Mateoc <[hidden email]> a écrit :
>> >> >> >
>> >> >> >
>> >> >> > Hi,
>> >> >> >
>> >> >> > While looking at some of the more exotic primitives, I stumbled upon this little gem.
>> >> >> > I think it's bad enough that it modifies strings in place (some of those could be method literals), but it even modifies symbols in place, without adding them to the symbol table.
>> >> >> >
>> >> >> > I would say this is a bug, I don't think symbols should be modified in place (other than by the #intern: method), but this does not look unintentional - apparently ByteSymbol class >> #translate:from:to:table: was added specifically to make the primitive work on symbols too.
>> >> >> >
>> >> >> > Does anybody have any insight into this, is this functionality (modifying symbols in place) used anywhere?
>> >> >> >
>> >> >> > Thank you,
>> >> >> > Florin
>> >> >> >