Can i has underscores? :)

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

Can i has underscores? :)

Igor Stasenko
I checked, that in Pharo image i could simply use:

foo_bar

        a_b := 5.
        FOO_BAR := 10.
       
        ^ FOO_BAR

and it works!

It would be cool to have similar in squeak, even if it may require to
define something like:

MyClass class>>canIHasUnderscores
  ^ true

It would be really nice to have, especially for things like OpenGL
API, which using underscores in constant names.
Exterminating underscores in those identifiers makes them really hard
to read , and awkward to use, because
every time you going to code something, first you usually refer to
docs, where you see these names with underscores,
but then once you going to type this name it costs you an additional
mental effort - don't forget to skip underscores.

--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Can i has underscores? :)

Derek O'Connell-2
On 14/04/10 10:39, Igor Stasenko wrote:

> I checked, that in Pharo image i could simply use:
>
> foo_bar
>
> a_b := 5.
> FOO_BAR := 10.
>
> ^ FOO_BAR
>
> and it works!
>
> It would be cool to have similar in squeak, even if it may require to
> define something like:
>
> MyClass class>>canIHasUnderscores
>    ^ true
>
> It would be really nice to have, especially for things like OpenGL
> API, which using underscores in constant names.
> Exterminating underscores in those identifiers makes them really hard
> to read , and awkward to use, because
> every time you going to code something, first you usually refer to
> docs, where you see these names with underscores,
> but then once you going to type this name it costs you an additional
> mental effort - don't forget to skip underscores.
>

+1

Reply | Threaded
Open this post in threaded view
|

Re: Can i has underscores? :)

laza
In reply to this post by Igor Stasenko
After setting the "Allow underscore selectors" preference to true in
4.1.1 I just created a class MyClass with the method foo_bar and
MyClass new foo_bar returns 10?!

I can't say why the note about the new sources file pops up on this though.

Alex

2010/4/14 Igor Stasenko <[hidden email]>:

> I checked, that in Pharo image i could simply use:
>
> foo_bar
>
>        a_b := 5.
>        FOO_BAR := 10.
>
>        ^ FOO_BAR
>
> and it works!
>
> It would be cool to have similar in squeak, even if it may require to
> define something like:
>
> MyClass class>>canIHasUnderscores
>  ^ true
>
> It would be really nice to have, especially for things like OpenGL
> API, which using underscores in constant names.
> Exterminating underscores in those identifiers makes them really hard
> to read , and awkward to use, because
> every time you going to code something, first you usually refer to
> docs, where you see these names with underscores,
> but then once you going to type this name it costs you an additional
> mental effort - don't forget to skip underscores.
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Can i has underscores? :)

Igor Stasenko
On 14 April 2010 13:25, Alexander Lazarević <[hidden email]> wrote:
> After setting the "Allow underscore selectors" preference to true in
> 4.1.1 I just created a class MyClass with the method foo_bar and
> MyClass new foo_bar returns 10?!
>
> I can't say why the note about the new sources file pops up on this though.
>
Oh, so, i could use underscores in trunk?
I just missed the notice that it is adopted already.

Is there an option to use a per-class setting, instead/in addition of
a system-wide one?

> Alex
>
> 2010/4/14 Igor Stasenko <[hidden email]>:
>> I checked, that in Pharo image i could simply use:
>>
>> foo_bar
>>
>>        a_b := 5.
>>        FOO_BAR := 10.
>>
>>        ^ FOO_BAR
>>
>> and it works!
>>
>> It would be cool to have similar in squeak, even if it may require to
>> define something like:
>>
>> MyClass class>>canIHasUnderscores
>>  ^ true
>>
>> It would be really nice to have, especially for things like OpenGL
>> API, which using underscores in constant names.
>> Exterminating underscores in those identifiers makes them really hard
>> to read , and awkward to use, because
>> every time you going to code something, first you usually refer to
>> docs, where you see these names with underscores,
>> but then once you going to type this name it costs you an additional
>> mental effort - don't forget to skip underscores.
>>
>> --
>> Best regards,
>> Igor Stasenko AKA sig.
>>
>>
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Can i has underscores? :)

laza
2010/4/14 Igor Stasenko <[hidden email]>:
> Is there an option to use a per-class setting, instead/in addition of
> a system-wide one?

Haven't tested this but Behavior>>allowUnderscoreSelectors suggests so:

        "Return true if the receiver and its subclasses should be allowed to
use underscore in selectors. Returning nil here means that the
compiler should use the system-wide default preference. Also see
#allowUnderscoreAssignments.

        Combinations: If both preferences are false, underscore is illegal.
If both preferences are true, underscore assignment needs the be
surrounded by spaces and a single underscore cannot be used as
selector."
        ^nil

Alex

Reply | Threaded
Open this post in threaded view
|

Re: Can i has underscores? :)

Igor Stasenko
On 14 April 2010 13:44, Alexander Lazarević <[hidden email]> wrote:

> 2010/4/14 Igor Stasenko <[hidden email]>:
>> Is there an option to use a per-class setting, instead/in addition of
>> a system-wide one?
>
> Haven't tested this but Behavior>>allowUnderscoreSelectors suggests so:
>
>        "Return true if the receiver and its subclasses should be allowed to
> use underscore in selectors. Returning nil here means that the
> compiler should use the system-wide default preference. Also see
> #allowUnderscoreAssignments.
>
>        Combinations: If both preferences are false, underscore is illegal.
> If both preferences are true, underscore assignment needs the be
> surrounded by spaces and a single underscore cannot be used as
> selector."
>        ^nil
>

Oh , well it seems works only for selectors, but not for ivars/classvars :(
i put the
MyClass class>>allowUnderscoreSelectors
        ^ true

on previously defined MyClass, and then tried to add ivar with underscores:

Object subclass: #MyClass
        instanceVariableNames: 'a_b_c'
        classVariableNames: ''
        poolDictionaries: ''
        category: 'OpenGL-Specs'

after accepting it, i got no error (what is strange), but instead ,
the class having 3 ivars:

Object subclass: #MyClass
        instanceVariableNames: 'a b c'
        classVariableNames: ''
        poolDictionaries: ''
        category: 'OpenGL-Specs'


This is inconsistent. It should either throw an error or accept the
variable name with underscore, but not silently turn
'a_b_c' into 3 separate ivars.

> Alex
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Can i has underscores? :)

laza
I think there are two problems here. First that the Scanner returns a
b instVars on reading a_b when "Allow underscore selectors" is false
and second that it just honors the global setting for "allow
underscore selectors" in the Prefs. The Parser also checks for a class
side method allowUnderscoreSelectors.

Alex

2010/4/14 Igor Stasenko <[hidden email]>:

> On 14 April 2010 13:44, Alexander Lazarević <[hidden email]> wrote:
>> 2010/4/14 Igor Stasenko <[hidden email]>:
>>> Is there an option to use a per-class setting, instead/in addition of
>>> a system-wide one?
>>
>> Haven't tested this but Behavior>>allowUnderscoreSelectors suggests so:
>>
>>        "Return true if the receiver and its subclasses should be allowed to
>> use underscore in selectors. Returning nil here means that the
>> compiler should use the system-wide default preference. Also see
>> #allowUnderscoreAssignments.
>>
>>        Combinations: If both preferences are false, underscore is illegal.
>> If both preferences are true, underscore assignment needs the be
>> surrounded by spaces and a single underscore cannot be used as
>> selector."
>>        ^nil
>>
>
> Oh , well it seems works only for selectors, but not for ivars/classvars :(
> i put the
> MyClass class>>allowUnderscoreSelectors
>        ^ true
>
> on previously defined MyClass, and then tried to add ivar with underscores:
>
> Object subclass: #MyClass
>        instanceVariableNames: 'a_b_c'
>        classVariableNames: ''
>        poolDictionaries: ''
>        category: 'OpenGL-Specs'
>
> after accepting it, i got no error (what is strange), but instead ,
> the class having 3 ivars:
>
> Object subclass: #MyClass
>        instanceVariableNames: 'a b c'
>        classVariableNames: ''
>        poolDictionaries: ''
>        category: 'OpenGL-Specs'
>
>
> This is inconsistent. It should either throw an error or accept the
> variable name with underscore, but not silently turn
> 'a_b_c' into 3 separate ivars.
>
>> Alex
>>
>>
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Can i has underscores? :)

Ian Trudel-2
Reply | Threaded
Open this post in threaded view
|

Re: Can i has underscores? :)

Juan Vuletich-4
In reply to this post by laza
Alexander Lazarević wrote:
> After setting the "Allow underscore selectors" preference to true in
> 4.1.1 I just created a class MyClass with the method foo_bar and
> MyClass new foo_bar returns 10?!
>
> I can't say why the note about the new sources file pops up on this though.
>
> Alex
>  

Hi Folks,

I recently integrated Andreas' last changes to Cuis. Today I tried
Igor's example and found a few problems, that the attached changes
address. This stuff was done for Cuis, but should be easy to integrate
in Squeak (and I guess Pharo too). Everybody feel free to integrate and
test.

0489-ConfigurableUnderscoreShoutSupport-jmv.5.cs - Adds Shout support
for #allowUnderscoreAssignments and #allowUnderscoreSelectos preference
0490-ConfigurableUnderscoreFixes-jmv.3.cs - Fixes some issues when
parsing underscores in identifiers in .cs files. Does so by simplifying
Scanner. Also makes #a_b to print correctly. With these fixes, such
weird stuff as TestUnderscores.cs can be parser and installed.
0491-ConfigurableUnderscoreElsewhere-jmv.1.cs Fixes senders of #isLetter
and #isAlphaNumeric that should also consider underscores.

Enjoy!
Juan Vuletich



CuisUnderscoresStuff.zip (12K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Can i has underscores? :)

Igor Stasenko
On 14 April 2010 20:10, Juan Vuletich <[hidden email]> wrote:

> Alexander Lazarević wrote:
>>
>> After setting the "Allow underscore selectors" preference to true in
>> 4.1.1 I just created a class MyClass with the method foo_bar and
>> MyClass new foo_bar returns 10?!
>>
>> I can't say why the note about the new sources file pops up on this
>> though.
>>
>> Alex
>>
>
> Hi Folks,
>
> I recently integrated Andreas' last changes to Cuis. Today I tried Igor's
> example and found a few problems, that the attached changes address. This
> stuff was done for Cuis, but should be easy to integrate in Squeak (and I
> guess Pharo too). Everybody feel free to integrate and test.
>
> 0489-ConfigurableUnderscoreShoutSupport-jmv.5.cs - Adds Shout support for
> #allowUnderscoreAssignments and #allowUnderscoreSelectos preference
> 0490-ConfigurableUnderscoreFixes-jmv.3.cs - Fixes some issues when parsing
> underscores in identifiers in .cs files. Does so by simplifying Scanner.
> Also makes #a_b to print correctly. With these fixes, such weird stuff as
> TestUnderscores.cs can be parser and installed.
> 0491-ConfigurableUnderscoreElsewhere-jmv.1.cs Fixes senders of #isLetter and
> #isAlphaNumeric that should also consider underscores.
>

Juan, i tried to file-in your changesets into a Squeak and got some errors:

In  0490-ConfigurableUnderscoreFixes-jmv.3.cs
- classDefinition: #Scanner category: #'Compiler-Kernel'
is not a valid smalltalk expression
next i tried to install things selectively and stumbled upon:
Parser>>DNU: #classEncoding
in debugger, somehow an encoder ivar holds an instance of Parser:

allowUnderscoreAssignments
        "Query class + preference"
        ^encoder classEncoding allowUnderscoreAssignments
                ifNil:[super allowUnderscoreAssignments]

my guess this is because of reshaping the Scanner class, which leads
to a mess in existing Parser
instances ivars.

So, i think for a correct filein, it should create a separate
NewScanner and NewParser classes,
file them in, and only then , atomically rename them  to Scanner and Parser.


> Enjoy!
> Juan Vuletich
>
>
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Can i has underscores? :)

Juan Vuletich-4
Igor Stasenko wrote:

> On 14 April 2010 20:10, Juan Vuletich <[hidden email]> wrote:
>  
>> Alexander Lazarević wrote:
>>    
>>> After setting the "Allow underscore selectors" preference to true in
>>> 4.1.1 I just created a class MyClass with the method foo_bar and
>>> MyClass new foo_bar returns 10?!
>>>
>>> I can't say why the note about the new sources file pops up on this
>>> though.
>>>
>>> Alex
>>>
>>>      
>> Hi Folks,
>>
>> I recently integrated Andreas' last changes to Cuis. Today I tried Igor's
>> example and found a few problems, that the attached changes address. This
>> stuff was done for Cuis, but should be easy to integrate in Squeak (and I
>> guess Pharo too). Everybody feel free to integrate and test.
>>
>> 0489-ConfigurableUnderscoreShoutSupport-jmv.5.cs - Adds Shout support for
>> #allowUnderscoreAssignments and #allowUnderscoreSelectos preference
>> 0490-ConfigurableUnderscoreFixes-jmv.3.cs - Fixes some issues when parsing
>> underscores in identifiers in .cs files. Does so by simplifying Scanner.
>> Also makes #a_b to print correctly. With these fixes, such weird stuff as
>> TestUnderscores.cs can be parser and installed.
>> 0491-ConfigurableUnderscoreElsewhere-jmv.1.cs Fixes senders of #isLetter and
>> #isAlphaNumeric that should also consider underscores.
>>
>>    
>
> Juan, i tried to file-in your changesets into a Squeak and got some errors:
>
> In  0490-ConfigurableUnderscoreFixes-jmv.3.cs
> - classDefinition: #Scanner category: #'Compiler-Kernel'
> is not a valid smalltalk expression
> next i tried to install things selectively and stumbled upon:
> Parser>>DNU: #classEncoding
> in debugger, somehow an encoder ivar holds an instance of Parser:
>
> allowUnderscoreAssignments
> "Query class + preference"
> ^encoder classEncoding allowUnderscoreAssignments
> ifNil:[super allowUnderscoreAssignments]
>
> my guess this is because of reshaping the Scanner class, which leads
> to a mess in existing Parser
> instances ivars.
>
> So, i think for a correct filein, it should create a separate
> NewScanner and NewParser classes,
> file them in, and only then , atomically rename them  to Scanner and Parser.
>
>  

Note that that file also includes definitions of
#allowUnderscoreAssignments and #allowUnderscoreSelectors to deal with
that situation. So, load them first.

Cheers,
Juan Vuletich

Reply | Threaded
Open this post in threaded view
|

Re: Can i has underscores? :)

Igor Stasenko
On 15 April 2010 15:09, Juan Vuletich <[hidden email]> wrote:

> Igor Stasenko wrote:
>>
>> On 14 April 2010 20:10, Juan Vuletich <[hidden email]> wrote:
>>
>>>
>>> Alexander Lazarević wrote:
>>>
>>>>
>>>> After setting the "Allow underscore selectors" preference to true in
>>>> 4.1.1 I just created a class MyClass with the method foo_bar and
>>>> MyClass new foo_bar returns 10?!
>>>>
>>>> I can't say why the note about the new sources file pops up on this
>>>> though.
>>>>
>>>> Alex
>>>>
>>>>
>>>
>>> Hi Folks,
>>>
>>> I recently integrated Andreas' last changes to Cuis. Today I tried Igor's
>>> example and found a few problems, that the attached changes address. This
>>> stuff was done for Cuis, but should be easy to integrate in Squeak (and I
>>> guess Pharo too). Everybody feel free to integrate and test.
>>>
>>> 0489-ConfigurableUnderscoreShoutSupport-jmv.5.cs - Adds Shout support for
>>> #allowUnderscoreAssignments and #allowUnderscoreSelectos preference
>>> 0490-ConfigurableUnderscoreFixes-jmv.3.cs - Fixes some issues when
>>> parsing
>>> underscores in identifiers in .cs files. Does so by simplifying Scanner.
>>> Also makes #a_b to print correctly. With these fixes, such weird stuff as
>>> TestUnderscores.cs can be parser and installed.
>>> 0491-ConfigurableUnderscoreElsewhere-jmv.1.cs Fixes senders of #isLetter
>>> and
>>> #isAlphaNumeric that should also consider underscores.
>>>
>>>
>>
>> Juan, i tried to file-in your changesets into a Squeak and got some
>> errors:
>>
>> In  0490-ConfigurableUnderscoreFixes-jmv.3.cs
>> - classDefinition: #Scanner category: #'Compiler-Kernel'
>> is not a valid smalltalk expression
>> next i tried to install things selectively and stumbled upon:
>> Parser>>DNU: #classEncoding
>> in debugger, somehow an encoder ivar holds an instance of Parser:
>>
>> allowUnderscoreAssignments
>>        "Query class + preference"
>>        ^encoder classEncoding allowUnderscoreAssignments
>>                ifNil:[super allowUnderscoreAssignments]
>>
>> my guess this is because of reshaping the Scanner class, which leads
>> to a mess in existing Parser
>> instances ivars.
>>
>> So, i think for a correct filein, it should create a separate
>> NewScanner and NewParser classes,
>> file them in, and only then , atomically rename them  to Scanner and
>> Parser.
>>
>>
>
> Note that that file also includes definitions of #allowUnderscoreAssignments
> and #allowUnderscoreSelectors to deal with that situation. So, load them
> first.
>
489 loaded without problems.. but then 490 fails.

> Cheers,
> Juan Vuletich
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Can i has underscores? :)

Juan Vuletich-4
Igor Stasenko wrote:

> On 15 April 2010 15:09, Juan Vuletich <[hidden email]> wrote:
>  
>> Igor Stasenko wrote:
>>    
>>> On 14 April 2010 20:10, Juan Vuletich <[hidden email]> wrote:
>>>
>>>      
>>>> Alexander Lazarević wrote:
>>>>
>>>>        
>>>>> After setting the "Allow underscore selectors" preference to true in
>>>>> 4.1.1 I just created a class MyClass with the method foo_bar and
>>>>> MyClass new foo_bar returns 10?!
>>>>>
>>>>> I can't say why the note about the new sources file pops up on this
>>>>> though.
>>>>>
>>>>> Alex
>>>>>
>>>>>
>>>>>          
>>>> Hi Folks,
>>>>
>>>> I recently integrated Andreas' last changes to Cuis. Today I tried Igor's
>>>> example and found a few problems, that the attached changes address. This
>>>> stuff was done for Cuis, but should be easy to integrate in Squeak (and I
>>>> guess Pharo too). Everybody feel free to integrate and test.
>>>>
>>>> 0489-ConfigurableUnderscoreShoutSupport-jmv.5.cs - Adds Shout support for
>>>> #allowUnderscoreAssignments and #allowUnderscoreSelectos preference
>>>> 0490-ConfigurableUnderscoreFixes-jmv.3.cs - Fixes some issues when
>>>> parsing
>>>> underscores in identifiers in .cs files. Does so by simplifying Scanner.
>>>> Also makes #a_b to print correctly. With these fixes, such weird stuff as
>>>> TestUnderscores.cs can be parser and installed.
>>>> 0491-ConfigurableUnderscoreElsewhere-jmv.1.cs Fixes senders of #isLetter
>>>> and
>>>> #isAlphaNumeric that should also consider underscores.
>>>>
>>>>
>>>>        
>>> Juan, i tried to file-in your changesets into a Squeak and got some
>>> errors:
>>>
>>> In  0490-ConfigurableUnderscoreFixes-jmv.3.cs
>>> - classDefinition: #Scanner category: #'Compiler-Kernel'
>>> is not a valid smalltalk expression
>>> next i tried to install things selectively and stumbled upon:
>>> Parser>>DNU: #classEncoding
>>> in debugger, somehow an encoder ivar holds an instance of Parser:
>>>
>>> allowUnderscoreAssignments
>>>        "Query class + preference"
>>>        ^encoder classEncoding allowUnderscoreAssignments
>>>                ifNil:[super allowUnderscoreAssignments]
>>>
>>> my guess this is because of reshaping the Scanner class, which leads
>>> to a mess in existing Parser
>>> instances ivars.
>>>
>>> So, i think for a correct filein, it should create a separate
>>> NewScanner and NewParser classes,
>>> file them in, and only then , atomically rename them  to Scanner and
>>> Parser.
>>>
>>>
>>>      
>> Note that that file also includes definitions of #allowUnderscoreAssignments
>> and #allowUnderscoreSelectors to deal with that situation. So, load them
>> first.
>>
>>    
> 489 loaded without problems.. but then 490 fails.
>
>  
>> Cheers,
>> Juan Vuletich
>>
>>
>>    
Well, I clearly stated that changes were done in Cuis, and encouraged
anybody to integrate them in Squeak (not just to 'load' them). So you
need to understand and fix. If the issues is the same as before, load
#allowUnderscoreAssignments and #allowUnderscoreSelectors before
whatever gives you that walkback.

Cheers,
Juan Vuletich