Fwd: Misc primitives & read-only objects

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

Fwd: Misc primitives & read-only objects

Clément Béra
 

Hi all,

I'm trying to set literals as read-only in Pharo. I've got this problem with this Misc primitive:

translate: aString from: start  to: stop  table: table
"translate the characters in the string by the given table, in place"
<primitive: 'primitiveTranslateStringWithTable' module: 'MiscPrimitivePlugin'>
<var: #table  declareC: 'unsigned char *table'>
<var: #aString  declareC: 'unsigned char *aString'>

start to: stop do: [ :i |
aString at: i put: (table at: (aString basicAt: i) + 1) ]

The primitive mutates aString without checking if it's read-only.

What is the right way in Smart syntax plugin to add the read-only check ?

Best,

--
Clément Béra
Bâtiment B 40, avenue Halley 59650 Villeneuve d'Ascq
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Misc primitives & read-only objects

Eliot Miranda-2
 
Hi Clément,


On Feb 21, 2018, at 4:01 AM, Clément Bera <[hidden email]> wrote:


Hi all,

I'm trying to set literals as read-only in Pharo. I've got this problem with this Misc primitive:

translate: aString from: start  to: stop  table: table
"translate the characters in the string by the given table, in place"
<primitive: 'primitiveTranslateStringWithTable' module: 'MiscPrimitivePlugin'>
<var: #table  declareC: 'unsigned char *table'>
<var: #aString  declareC: 'unsigned char *aString'>

start to: stop do: [ :i |
aString at: i put: (table at: (aString basicAt: i) + 1) ]

The primitive mutates aString without checking if it's read-only.

What is the right way in Smart syntax plugin to add the read-only check ?

I think the right way is to rewrite the primitive as a SmartSyntaxPlugin.  I will do this today.  These translated primitives are a cute idea but fundamentally problematic.


Best,

--
Clément Béra
Bâtiment B 40, avenue Halley 59650 Villeneuve d'Ascq