Selectors with underscores

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

Selectors with underscores

Torsten Bergmann
>Can code with underscore assignment still
>be loaded?

Dont know ... at least it should since this works:

foo_bar
   | foo |
   foo _ 1

although i would go here with Sam about readability ;)

Attached is a changeset for latest trunk (3.11alpha#9676)
so you can try yourself.

It has a Preference (see PrefBrowser -> compiler -> allowSelectorsWithUnderscores) which is false by default.

If true an underscore is accepted and any code with underscores
is loadable without patching the image/Scanner class.

Does that satisfy anybody?

Please feel free to review and integrate if accepted.

Thanks to Ian Piumarta for the original idea/changeset...

Thx
T.

P.S: Typically the pref is included/initialized in
     Parser class>>initialize but I dont call this method
     in the postscript. The postscripts adds the preference
     directly. This will preserve existing compiler settings.


--
GMX DSL: Internet, Telefon und Entertainment für nur 19,99 EUR/mtl.!
http://portal.gmx.net/de/go/dsl02



UnderscoresInSelectors.1.cs (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Andreas.Raab
On 3/11/2010 9:10 AM, Torsten Bergmann wrote:
> If true an underscore is accepted and any code with underscores
> is loadable without patching the image/Scanner class.
>
> Does that satisfy anybody?
>
> Please feel free to review and integrate if accepted.

I did a quick adoption of your code to print out all sites that would be
compiled differently and run it in trunk where it resulted in only one
site needing change (PNGReadWritre>>test1). Then I ran it in an
Etoys-dev image and the result was significantly different. There's a
lot of code that uses at least x_ foo (i.e., no space between var name
and underscore).

I'm wondering: I don't really know how the people who want underscores
plan to use this, but would it make sense to scope this differently,
i.e., either on a per-class or even a per-method basis?

Per class would be my favorite because in a system where you'd like to
use underscores globally you'd just have Object
class>>allowUnderscoreSelectors return true. And in other systems you
could still have MyGlorpConnector>>allowUnderscoreSelectors enabling it
for the cases you care about.

Cheers,
   - Andreas

Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Stéphane Rollandin
> Per class would be my favorite because in a system where you'd like to
> use underscores globally you'd just have Object
> class>>allowUnderscoreSelectors return true. And in other systems you
> could still have MyGlorpConnector>>allowUnderscoreSelectors enabling it
> for the cases you care about.

+1

Stef




Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Nicolas Cellier
2010/3/11 Stéphane Rollandin <[hidden email]>:

>> Per class would be my favorite because in a system where you'd like to
>> use underscores globally you'd just have Object
>> class>>allowUnderscoreSelectors return true. And in other systems you
>> could still have MyGlorpConnector>>allowUnderscoreSelectors enabling it
>> for the cases you care about.
>
> +1
>
> Stef
>
>

Guess what, the hook did exist in st-80.
It's a method called compilerClass.

Nicolas

Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Josh Gargus
In reply to this post by Andreas.Raab
I like the per-class scoping idea.

I don't personally have any method-selectors that I want to use underscores in, but I do have lots of constants that I'd like underscores in.  For example, OpenCL has hundreds of constants along the lines of CL_MEM_READ_WRITE (and OpenGL has even more).

It would be inconvenient if every class using the pool dictionary OpenCLConstants had to explicitly enable the use of underscores.  Ideal, the user's intent would be implicit in the choice to use that pool dictionary.

Cheers,
Josh



On Mar 11, 2010, at 9:59 AM, Andreas Raab wrote:

> On 3/11/2010 9:10 AM, Torsten Bergmann wrote:
>> If true an underscore is accepted and any code with underscores
>> is loadable without patching the image/Scanner class.
>>
>> Does that satisfy anybody?
>>
>> Please feel free to review and integrate if accepted.
>
> I did a quick adoption of your code to print out all sites that would be compiled differently and run it in trunk where it resulted in only one site needing change (PNGReadWritre>>test1). Then I ran it in an Etoys-dev image and the result was significantly different. There's a lot of code that uses at least x_ foo (i.e., no space between var name and underscore).
>
> I'm wondering: I don't really know how the people who want underscores plan to use this, but would it make sense to scope this differently, i.e., either on a per-class or even a per-method basis?
>
> Per class would be my favorite because in a system where you'd like to use underscores globally you'd just have Object class>>allowUnderscoreSelectors return true. And in other systems you could still have MyGlorpConnector>>allowUnderscoreSelectors enabling it for the cases you care about.
>
> Cheers,
>  - Andreas
>