Class names with underscores

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

Class names with underscores

mkobetic
I'm being told that Squeak doesn't like class names with underscores. I'm using those for ExternalStructures to keep their names in sync with their C-side counterparts and I didn't notice a problem in Pharo. Is that something that is a problem for Squeak ? If so is there some sort of convention on how to convert such names when writing external bindings with FFI ?

Thanks,

Martin

Reply | Threaded
Open this post in threaded view
|

Re: Class names with underscores

Igor Stasenko
On 21 January 2011 16:12,  <[hidden email]> wrote:
> I'm being told that Squeak doesn't like class names with underscores. I'm using those for ExternalStructures to keep their names in sync with their C-side counterparts and I didn't notice a problem in Pharo. Is that something that is a problem for Squeak ? If so is there some sort of convention on how to convert such names when writing external bindings with FFI ?
>

if you set  'use underscore for selectors' and disable 'underscore for
assignments' in preferences then class names should work as well,
AFAIK.

> Thanks,
>
> Martin
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Class names with underscores

mkobetic
In reply to this post by mkobetic
"Igor Stasenko"<[hidden email]> wrote:
> if you set  'use underscore for selectors' and disable 'underscore for
> assignments' in preferences then class names should work as well,
> AFAIK.

But if that's not how most people will run Squeak, then that's not a reasonable option for me. What are the default settings and are they likely to ever change ?

Reply | Threaded
Open this post in threaded view
|

Re: Class names with underscores

Levente Uzonyi-2
In reply to this post by Igor Stasenko
On Fri, 21 Jan 2011, Igor Stasenko wrote:

> On 21 January 2011 16:12,  <[hidden email]> wrote:
>> I'm being told that Squeak doesn't like class names with underscores. I'm using those for ExternalStructures to keep their names in sync with their C-side counterparts and I didn't notice a problem in Pharo. Is that something that is a problem for Squeak ? If so is there some sort of convention on how to convert such names when writing external bindings with FFI ?
>>
>
> if you set  'use underscore for selectors' and disable 'underscore for
> assignments' in preferences then class names should work as well,
> AFAIK.

In Squeak you can use both at the same time. The exact names are "Allow
underscore assignments" and "Allow underscore selectors".


Levente

>
>> Thanks,
>>
>> Martin
>>
>>
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Class names with underscores

Levente Uzonyi-2
In reply to this post by mkobetic
On Fri, 21 Jan 2011, [hidden email] wrote:

> "Igor Stasenko"<[hidden email]> wrote:
>> if you set  'use underscore for selectors' and disable 'underscore for
>> assignments' in preferences then class names should work as well,
>> AFAIK.
>
> But if that's not how most people will run Squeak, then that's not a reasonable option for me. What are the default settings and are they likely to ever change ?

The default is: underscore assignments are allowed, underscore selectors
are not. This is fully backwards compatible.
You can enable underscore selectors for your classes (both senders and
implementors) in Squeak by implementing the class side method
#allowUnderscoreSelectors as ^true.
Browsing the source code has some problems due to a bug
(http://bugs.squeak.org/view.php?id=7547 ), but the code will work.


Levente

>
>



Reply | Threaded
Open this post in threaded view
|

Re: Class names with underscores

Igor Stasenko
On 21 January 2011 17:39, Levente Uzonyi <[hidden email]> wrote:

> On Fri, 21 Jan 2011, [hidden email] wrote:
>
>> "Igor Stasenko"<[hidden email]> wrote:
>>>
>>> if you set  'use underscore for selectors' and disable 'underscore for
>>> assignments' in preferences then class names should work as well,
>>> AFAIK.
>>
>> But if that's not how most people will run Squeak, then that's not a
>> reasonable option for me. What are the default settings and are they likely
>> to ever change ?
>
> The default is: underscore assignments are allowed, underscore selectors are
> not. This is fully backwards compatible.
> You can enable underscore selectors for your classes (both senders and
> implementors) in Squeak by implementing the class side method
> #allowUnderscoreSelectors as ^true.
> Browsing the source code has some problems due to a bug
> (http://bugs.squeak.org/view.php?id=7547 ), but the code will work.
>
No only that.

You can't safely recompile source at will, like:
Compiler recompileAll
because parts of code could be filed in using one setting, and other
code loaded when setting is different.
So, you have to live with worst possible solution between:
  - having cake, but can't eat it
  - not having cake, but attempt to eat it
:)

>
> Levente
>




--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Class names with underscores

mkobetic
In reply to this post by mkobetic
"Levente Uzonyi"<[hidden email]> wrote:
> The default is: underscore assignments are allowed, underscore selectors
> are not. This is fully backwards compatible.
> You can enable underscore selectors for your classes (both senders and
> implementors) in Squeak by implementing the class side method
> #allowUnderscoreSelectors as ^true.
> Browsing the source code has some problems due to a bug
> (http://bugs.squeak.org/view.php?id=7547 ), but the code will work.

OK, just to make sure, since this all talks about selectors. It is OK to have a class with the *class name* with underscores if I add #allowUnderscoreSelectors ^true to it ?

Thanks for your help,

Martin

Reply | Threaded
Open this post in threaded view
|

Re: Class names with underscores

Levente Uzonyi-2
In reply to this post by Igor Stasenko
On Fri, 21 Jan 2011, Igor Stasenko wrote:

> On 21 January 2011 17:39, Levente Uzonyi <[hidden email]> wrote:
>> On Fri, 21 Jan 2011, [hidden email] wrote:
>>
>>> "Igor Stasenko"<[hidden email]> wrote:
>>>>
>>>> if you set  'use underscore for selectors' and disable 'underscore for
>>>> assignments' in preferences then class names should work as well,
>>>> AFAIK.
>>>
>>> But if that's not how most people will run Squeak, then that's not a
>>> reasonable option for me. What are the default settings and are they likely
>>> to ever change ?
>>
>> The default is: underscore assignments are allowed, underscore selectors are
>> not. This is fully backwards compatible.
>> You can enable underscore selectors for your classes (both senders and
>> implementors) in Squeak by implementing the class side method
>> #allowUnderscoreSelectors as ^true.
>> Browsing the source code has some problems due to a bug
>> (http://bugs.squeak.org/view.php?id=7547 ), but the code will work.
>>
> No only that.
>
> You can't safely recompile source at will, like:
> Compiler recompileAll
> because parts of code could be filed in using one setting, and other
> code loaded when setting is different.
> So, you have to live with worst possible solution between:
>  - having cake, but can't eat it
>  - not having cake, but attempt to eat it
> :)
I disagree with you. All code in the Squeak Trunk image can be compiled
with the preference turned on or off. If you load code that requires the
preference to be turned on _and_ you load code at some other time that
requires it to be off, then it will be problem. But it's very easy to
solve it, just remove the ambiguity of your methods. (Only ambiguous
underscore assignments cause problems.)


Levente

>
>>
>> Levente
>>
>
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>

Reply | Threaded
Open this post in threaded view
|

Re: Class names with underscores

Levente Uzonyi-2
In reply to this post by mkobetic
On Fri, 21 Jan 2011, [hidden email] wrote:

> "Levente Uzonyi"<[hidden email]> wrote:
>> The default is: underscore assignments are allowed, underscore selectors
>> are not. This is fully backwards compatible.
>> You can enable underscore selectors for your classes (both senders and
>> implementors) in Squeak by implementing the class side method
>> #allowUnderscoreSelectors as ^true.
>> Browsing the source code has some problems due to a bug
>> (http://bugs.squeak.org/view.php?id=7547 ), but the code will work.
>
> OK, just to make sure, since this all talks about selectors. It is OK to have a class with the *class name* with underscores if I add #allowUnderscoreSelectors ^true to it ?

You can create classes with underscores in their name, but if you want to
reference such class from another class, then the other class has to
implement #allowUnderscoreSelectors as returning true, or the preference
has to be turned on.
The class side method doesn't affect the Metaclass, so if you want to
reference a class or send a method with an underscore in it's name from a
class side method, then you have to turn the preference on.


Levente

>
> Thanks for your help,
>
> Martin
>

Reply | Threaded
Open this post in threaded view
|

Re: Class names with underscores

Andreas.Raab
In reply to this post by Igor Stasenko
On 1/21/2011 5:50 PM, Igor Stasenko wrote:

> On 21 January 2011 17:39, Levente Uzonyi<[hidden email]>  wrote:
>> On Fri, 21 Jan 2011, [hidden email] wrote:
>>
>>> "Igor Stasenko"<[hidden email]>  wrote:
>>>>
>>>> if you set  'use underscore for selectors' and disable 'underscore for
>>>> assignments' in preferences then class names should work as well,
>>>> AFAIK.
>>>
>>> But if that's not how most people will run Squeak, then that's not a
>>> reasonable option for me. What are the default settings and are they likely
>>> to ever change ?
>>
>> The default is: underscore assignments are allowed, underscore selectors are
>> not. This is fully backwards compatible.
>> You can enable underscore selectors for your classes (both senders and
>> implementors) in Squeak by implementing the class side method
>> #allowUnderscoreSelectors as ^true.
>> Browsing the source code has some problems due to a bug
>> (http://bugs.squeak.org/view.php?id=7547 ), but the code will work.
>>
> No only that.
>
> You can't safely recompile source at will, like:
> Compiler recompileAll
> because parts of code could be filed in using one setting, and other
> code loaded when setting is different.
> So, you have to live with worst possible solution between:
>    - having cake, but can't eat it
>    - not having cake, but attempt to eat it
> :)

The global preference is intended to make fileIns work for the first
time. To keep your underscore preferences consistent within your code
see Behavior>>allowUnderscoreSelectors and
Behavior>>allowUnderscoreAssignments.

It's not perfect since it should be on a package-basis but it's better
than nothing.

Cheers,
   - Andreas