RBScanner>>#initializeClassificationTable

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

RBScanner>>#initializeClassificationTable

Benjamin Van Ryseghem (Pharo)
Hello guys,

Is there a reason this method use :

        (Scanner isLiteralSymbol: '_')
                ifTrue: [ self initializeChars: '_' to: #alphabetic ]
                ifFalse: [ self initializeChars: '_' to: #special ].

and not

        (Scanner allowUnderscoreAsAssignment)
                ifTrue: [ self initializeChars: '_' to: #special ]
                ifFalse:[ self initializeChars: '_' to: #alphabetic ]

?


Cheers,

Ben

Reply | Threaded
Open this post in threaded view
|

Re: RBScanner>>#initializeClassificationTable

Henrik Sperre Johansen

On Nov 25, 2010, at 10:58 44AM, Benjamin wrote:

> Hello guys,
>
> Is there a reason this method use :
>
> (Scanner isLiteralSymbol: '_')
> ifTrue: [ self initializeChars: '_' to: #alphabetic ]
> ifFalse: [ self initializeChars: '_' to: #special ].
>
> and not
>
> (Scanner allowUnderscoreAsAssignment)
> ifTrue: [ self initializeChars: '_' to: #special ]
> ifFalse:[ self initializeChars: '_' to: #alphabetic ]
>
> ?
>
>
> Cheers,
>
> Ben

Compatibility I would guess.
In Squeak, allowUnderscoreAsAssignment is still a Preferences method.

Cheers,
Henry

Reply | Threaded
Open this post in threaded view
|

Re: RBScanner>>#initializeClassificationTable

Henrik Sperre Johansen

On Nov 25, 2010, at 11:12 59AM, Henrik Johansen wrote:

>
> On Nov 25, 2010, at 10:58 44AM, Benjamin wrote:
>
>> Hello guys,
>>
>> Is there a reason this method use :
>>
>> (Scanner isLiteralSymbol: '_')
>> ifTrue: [ self initializeChars: '_' to: #alphabetic ]
>> ifFalse: [ self initializeChars: '_' to: #special ].
>>
>> and not
>>
>> (Scanner allowUnderscoreAsAssignment)
>> ifTrue: [ self initializeChars: '_' to: #special ]
>> ifFalse:[ self initializeChars: '_' to: #alphabetic ]
>>
>> ?
>>
>>
>> Cheers,
>>
>> Ben
>
> Compatibility I would guess.
> In Squeak, allowUnderscoreAsAssignment is still a Preferences method.
>
> Cheers,
> Henry
>

P.S. At the very least it could be changed to Scanner isLiteralSymbol: #_
:)

Reply | Threaded
Open this post in threaded view
|

Re: RBScanner>>#initializeClassificationTable

Levente Uzonyi-2
In reply to this post by Henrik Sperre Johansen
On Thu, 25 Nov 2010, Henrik Johansen wrote:

>
> On Nov 25, 2010, at 10:58 44AM, Benjamin wrote:
>
>> Hello guys,
>>
>> Is there a reason this method use :
>>
>> (Scanner isLiteralSymbol: '_')
>> ifTrue: [ self initializeChars: '_' to: #alphabetic ]
>> ifFalse: [ self initializeChars: '_' to: #special ].
>>
>> and not
>>
>> (Scanner allowUnderscoreAsAssignment)
>> ifTrue: [ self initializeChars: '_' to: #special ]
>> ifFalse:[ self initializeChars: '_' to: #alphabetic ]
>>
>> ?
>>
>>
>> Cheers,
>>
>> Ben
>
> Compatibility I would guess.
> In Squeak, allowUnderscoreAsAssignment is still a Preferences method.

No, it never was a method of Preferences. It's a pragma preference, but in
Squeak 4.1 it has a different name, IIRC prefAllowUnderscoreAssignment.


Levente

>
> Cheers,
> Henry
>
>

Reply | Threaded
Open this post in threaded view
|

Re: RBScanner>>#initializeClassificationTable

Levente Uzonyi-2
In reply to this post by Henrik Sperre Johansen
On Thu, 25 Nov 2010, Henrik Johansen wrote:

>
> On Nov 25, 2010, at 11:12 59AM, Henrik Johansen wrote:
>
>>
>> On Nov 25, 2010, at 10:58 44AM, Benjamin wrote:
>>
>>> Hello guys,
>>>
>>> Is there a reason this method use :
>>>
>>> (Scanner isLiteralSymbol: '_')
>>> ifTrue: [ self initializeChars: '_' to: #alphabetic ]
>>> ifFalse: [ self initializeChars: '_' to: #special ].
>>>
>>> and not
>>>
>>> (Scanner allowUnderscoreAsAssignment)
>>> ifTrue: [ self initializeChars: '_' to: #special ]
>>> ifFalse:[ self initializeChars: '_' to: #alphabetic ]
>>>
>>> ?
>>>
>>>
>>> Cheers,
>>>
>>> Ben
>>
>> Compatibility I would guess.
>> In Squeak, allowUnderscoreAsAssignment is still a Preferences method.
>>
>> Cheers,
>> Henry
>>
>
> P.S. At the very least it could be changed to Scanner isLiteralSymbol: #_

I guess not. There was a bug in Squeak (and probably Pharo too), because
the compiler replaced #_ to #':=' during compilation. See
http://bugs.squeak.org/view.php?id=7571 .


Levente

> :)
>
>

Reply | Threaded
Open this post in threaded view
|

Re: RBScanner>>#initializeClassificationTable

Henrik Sperre Johansen
In reply to this post by Levente Uzonyi-2

On Nov 25, 2010, at 11:41 07AM, Levente Uzonyi wrote:

On Thu, 25 Nov 2010, Henrik Johansen wrote:


On Nov 25, 2010, at 10:58 44AM, Benjamin wrote:

Hello guys,

Is there a reason this method use :

(Scanner isLiteralSymbol: '_')
ifTrue: [ self initializeChars: '_' to: #alphabetic ]
ifFalse: [ self initializeChars: '_' to: #special ].

and not

(Scanner allowUnderscoreAsAssignment)
ifTrue: [ self initializeChars: '_' to: #special ]
ifFalse:[ self initializeChars: '_' to: #alphabetic ]

?


Cheers,

Ben

Compatibility I would guess.
In Squeak, allowUnderscoreAsAssignment is still a Preferences method.

No, it never was a method of Preferences. It's a pragma preference, but in Squeak 4.1 it has a different name, IIRC prefAllowUnderscoreAssignment.


Levente

My bad, in the 4.1 image there's 
Preferences >> allowUnderscoreAssignment
^ self
valueOfFlag: #allowUnderscoreAssignment
ifAbsent: [false]
(Added by Parser class>>#initialize), I didn't check if it was actually in use anymore.

Compatibility seems the be the reason anyways though, as you said the Scanner pragma preference has a different name.


On Nov 25, 2010, at 11:42 56AM, Levente Uzonyi wrote:

On Thu, 25 Nov 2010, Henrik Johansen wrote:

P.S. At the very least it could be changed to Scanner isLiteralSymbol: #_

I guess not. There was a bug in Squeak (and probably Pharo too), because the compiler replaced #_ to #':=' during compilation. See http://bugs.squeak.org/view.php?id=7571 .

:(
Can't reproduce it in Pharo 1.0 onwards, with allowUnderscore on/off, though.

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

Re: RBScanner>>#initializeClassificationTable

Levente Uzonyi-2
On Thu, 25 Nov 2010, Henrik Johansen wrote:

> My bad, in the 4.1 image there's
> Preferences >> allowUnderscoreAssignment
> ^ self
> valueOfFlag: #allowUnderscoreAssignment
> ifAbsent: [false]
> (Added by Parser class>>#initialize), I didn't check if it was actually in use anymore.
>
> Compatibility seems the be the reason anyways though, as you said the Scanner pragma preference has a different name.

I doubt there was any effort to write compatible code, there are countless
packages that were originally written in Squeak, but now they are
incompatble with it.
In Squeak the pragma preference in Scanner was renamed recently to
allowUnderscoreAsAssignment to resolve the incompatibility.

>
>
> On Nov 25, 2010, at 11:42 56AM, Levente Uzonyi wrote:
>
>> On Thu, 25 Nov 2010, Henrik Johansen wrote:
>>
>>> P.S. At the very least it could be changed to Scanner isLiteralSymbol: #_
>>
>> I guess not. There was a bug in Squeak (and probably Pharo too), because the compiler replaced #_ to #':=' during compilation. See http://bugs.squeak.org/view.php?id=7571 .
>
> :(
> Can't reproduce it in Pharo 1.0 onwards, with allowUnderscore on/off, though.

That's fair, because you can't use underscores in selectors in Pharo.


Levente

>
> Cheers,
> Henry

Reply | Threaded
Open this post in threaded view
|

Re: RBScanner>>#initializeClassificationTable

Stéphane Ducasse
In reply to this post by Henrik Sperre Johansen
>
> That's fair, because you can't use underscores in selectors in Pharo.

Strange because I was sure that we integrate it that behavior to help people calling C function.

Stef
Reply | Threaded
Open this post in threaded view
|

Re: RBScanner>>#initializeClassificationTable

Lukas Renggli
>> That's fair, because you can't use underscores in selectors in Pharo.
>
> Strange because I was sure that we integrate it that behavior to help people calling C function.

The above statement is wrong. Of course underscores can be used in
selectors and variables for a long time already.

Lukas

--
Lukas Renggli
www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

Re: RBScanner>>#initializeClassificationTable

Stéphane Ducasse
In reply to this post by Stéphane Ducasse

On Nov 25, 2010, at 9:36 PM, Lukas Renggli wrote:

>>> That's fair, because you can't use underscores in selectors in Pharo.
>>
>> Strange because I was sure that we integrate it that behavior to help people calling C function.
>
> The above statement is wrong. Of course underscores can be used in
> selectors and variables for a long time already.

Thanks lukas. I was surprised and I was starting to look in the bugentry. So you saved me some time.
Apparently there is no setting to control it. Do you know how to configure it so that I enter a bug entry to make sure that we get a setting?


>
> Lukas
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
>


Reply | Threaded
Open this post in threaded view
|

Re: RBScanner>>#initializeClassificationTable

Levente Uzonyi-2
In reply to this post by Lukas Renggli
On Thu, 25 Nov 2010, Lukas Renggli wrote:

>>> That's fair, because you can't use underscores in selectors in Pharo.
>>
>> Strange because I was sure that we integrate it that behavior to help people calling C function.
>
> The above statement is wrong. Of course underscores can be used in
> selectors and variables for a long time already.

My statement is wrong (I forgot to turn off the setting when I checked),
but yours is also wrong. If underscore assignments are allowed, then you
can't use underscore selectors and vica versa.


Levente

>
> Lukas
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
>
>

Reply | Threaded
Open this post in threaded view
|

Re: RBScanner>>#initializeClassificationTable

Lukas Renggli
In reply to this post by Stéphane Ducasse
The setting is Compiler > Allow underscore as assignment.

Lukas

On 25 November 2010 17:42, Stéphane Ducasse <[hidden email]> wrote:

>
> On Nov 25, 2010, at 9:36 PM, Lukas Renggli wrote:
>
>>>> That's fair, because you can't use underscores in selectors in Pharo.
>>>
>>> Strange because I was sure that we integrate it that behavior to help people calling C function.
>>
>> The above statement is wrong. Of course underscores can be used in
>> selectors and variables for a long time already.
>
> Thanks lukas. I was surprised and I was starting to look in the bugentry. So you saved me some time.
> Apparently there is no setting to control it. Do you know how to configure it so that I enter a bug entry to make sure that we get a setting?
>
>
>>
>> Lukas
>>
>> --
>> Lukas Renggli
>> www.lukas-renggli.ch
>>
>
>
>



--
Lukas Renggli
www.lukas-renggli.ch

Reply | Threaded
Open this post in threaded view
|

Re: RBScanner>>#initializeClassificationTable

Stéphane Ducasse
In reply to this post by Stéphane Ducasse

On Nov 25, 2010, at 11:12 PM, Lukas Renggli wrote:

> The setting is Compiler > Allow underscore as assignment.

Ok I was confused. This is more a toggle and we should change the description of the setting to convey that.


Stef


>>>>> That's fair, because you can't use underscores in selectors in Pharo.
>>>>
>>>> Strange because I was sure that we integrate it that behavior to help people calling C function.
>>>
>>> The above statement is wrong. Of course underscores can be used in
>>> selectors and variables for a long time already.
>>
>> Thanks lukas. I was surprised and I was starting to look in the bugentry. So you saved me some time.
>> Apparently there is no setting to control it. Do you know how to configure it so that I enter a bug entry to make sure that we get a setting?
>>
>>
>>>
>>> Lukas
>>>
>>> --
>>> Lukas Renggli
>>> www.lukas-renggli.ch
>>>
>>
>>
>>
>
>
>
> --
> Lukas Renggli
> www.lukas-renggli.ch
>


Reply | Threaded
Open this post in threaded view
|

Re: RBScanner>>#initializeClassificationTable

Lukas Renggli
>> The setting is Compiler > Allow underscore as assignment.
>
> Ok I was confused. This is more a toggle and we should change the description of the setting to convey that.

In Pharo 1.0 we added the option (underscore assignments).

In Pharo 1.1 we disabled the option (underscore assignments) by default.

In Pharo 1.2 we hopefully remove the option (underscore assignments)
to get rid of them for all and forever.

Lukas

--
Lukas Renggli
www.lukas-renggli.ch