Selectors with underscores

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

Selectors with underscores

Torsten Bergmann
Pharo allows you to use underscores in method selectors.
This is currently in Pharo 1.1 and not 1.0.

Does that makes sense to have in Squeak trunk/Cuis too?

Try:

(HTTPSocket httpGet: 'http://www.assembla.com/spaces/SqueakDBX/documents/dvVhPSvuCr3OqXeJe5aVNr/download/underscore.cs') readStream fileIn

And you can implement a method

   foo_test
      ^'Works'

Makes sense in conjunction with Glorp (when a database column
mapped to a class has underscores in it) or FFI (where one
can name methods like C constants, ...), ...

If it would be in all base images the Glorp loader wouldnt
have to patch these.

Thx
Bye




--
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Edgar De Cleene



On 3/11/10 12:36 PM, "Torsten Bergmann" <[hidden email]> wrote:

> Pharo allows you to use underscores in method selectors.
> This is currently in Pharo 1.1 and not 1.0.
>
> Does that makes sense to have in Squeak trunk/Cuis too?
>
> Try:
>
> (HTTPSocket httpGet:
> 'http://www.assembla.com/spaces/SqueakDBX/documents/dvVhPSvuCr3OqXeJe5aVNr/dow
> nload/underscore.cs')   readStream fileIn
>
> And you can implement a method
>
>    foo_test
>       ^'Works'
>
> Makes sense in conjunction with Glorp (when a database column
> mapped to a class has underscores in it) or FFI (where one
> can name methods like C constants, ...), ...
>
> If it would be in all base images the Glorp loader wouldnt
> have to patch these.
>
> Thx
> Bye
+1



Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Ian Trudel-2
In reply to this post by Torsten Bergmann
2010/3/11 Torsten Bergmann <[hidden email]>:
> Pharo allows you to use underscores in method selectors.
> This is currently in Pharo 1.1 and not 1.0.
>
> Does that makes sense to have in Squeak trunk/Cuis too?

No, this is *not* something I'd like to have in Squeak. It's a
potential disaster in the long run where either we will be forced to
standardize code in some way or live with a basic image/trunk/etc and
very weird variable names mixing camel_CameANd_whAtnot beyond the
usage of Glorp.

o_O
(how appropriate!)

Ian.
--
http://mecenia.blogspot.com/

Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Sam Adams-2

Please no!
That fundamentally changes the readability of Squeak code and makes all future code written that way incompatible with other Smalltalks.
And besides, some of us grey beards *like* our assignment arrows! ;-)
If you really want that then create your own language variant or maintain your own fork of Squeak. Its not that hard after all, I'm doing both at present myself!
Regards,
Sam


Sam S. Adams, IBM Distinguished Engineer, IBM Research
Mobile: 919-696-6064, email: [hidden email]
Asst: Kenndra K. Quiles. (732) 926-2292 Fax: (732) 926-2455, email: [hidden email]
<<Hebrews 11:6, Proverbs 3:5-6, Romans 1:16-17, I Corinthians 1:10>>


[hidden email] wrote on 03/11/2010 09:47:55 AM:

> Re: [squeak-dev] Selectors with underscores

>
> 2010/3/11 Torsten Bergmann <[hidden email]>:
> > Pharo allows you to use underscores in method selectors.
> > This is currently in Pharo 1.1 and not 1.0.
> >
> > Does that makes sense to have in Squeak trunk/Cuis too?
>
> No, this is *not* something I'd like to have in Squeak. It's a
> potential disaster in the long run where either we will be forced to
> standardize code in some way or live with a basic image/trunk/etc and
> very weird variable names mixing camel_CameANd_whAtnot beyond the
> usage of Glorp.
>
> o_O
> (how appropriate!)
>
> Ian.
> --
> http://mecenia.blogspot.com/
>


Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Tapple Gao
In reply to this post by Torsten Bergmann
On Thu, Mar 11, 2010 at 03:36:43PM +0100, Torsten Bergmann wrote:
> Pharo allows you to use underscores in method selectors.
> This is currently in Pharo 1.1 and not 1.0.
>
> Does that makes sense to have in Squeak trunk/Cuis too?

I say support it. Cobalt and Croquet have supported this for
years. I have an experimental patch to MC1.5 that converts
underscore assignments to := at load time, if the compiler
raises a SyntaxError about them. How it works:

- Parser throws a syntax error
- MC catches the error
- MC uses the parser to find underscore assignments (and not
  underscores in strings/comments/names) and replace them
- MC retries compiling the method
- If a syntax error is raised again, MC lets it thru and you see
  the Syntax Error dialog box
- If any methods were changed during load, MC tells you about
  them so you can review them and save the package

Note that it's triggered by a SyntaxError, so this will not be
done if the preference is to allow underscore assignments.

Also, it only fixes things the parser things are disallowed
underscore assignments, so it is quite conservative.


I use this to prepare packages for loading into Cobalt (where
underscores assignments are disallowed by default)

--
Matthew Fulmer (a.k.a. Tapple)

Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Andreas.Raab
On 3/11/2010 9:54 AM, Matthew Fulmer wrote:
> On Thu, Mar 11, 2010 at 03:36:43PM +0100, Torsten Bergmann wrote:
>> Pharo allows you to use underscores in method selectors.
>> This is currently in Pharo 1.1 and not 1.0.
>>
>> Does that makes sense to have in Squeak trunk/Cuis too?
>
> I say support it. Cobalt and Croquet have supported this for
> years.

Err, no :-) Underscores are illegal in Croquet. Anywhere.

Cheers,
   - Andreas

> I have an experimental patch to MC1.5 that converts
> underscore assignments to := at load time, if the compiler
> raises a SyntaxError about them. How it works:
>
> - Parser throws a syntax error
> - MC catches the error
> - MC uses the parser to find underscore assignments (and not
>    underscores in strings/comments/names) and replace them
> - MC retries compiling the method
> - If a syntax error is raised again, MC lets it thru and you see
>    the Syntax Error dialog box
> - If any methods were changed during load, MC tells you about
>    them so you can review them and save the package
>
> Note that it's triggered by a SyntaxError, so this will not be
> done if the preference is to allow underscore assignments.
>
> Also, it only fixes things the parser things are disallowed
> underscore assignments, so it is quite conservative.
>
>
> I use this to prepare packages for loading into Cobalt (where
> underscores assignments are disallowed by default)
>


Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

keith1y
In reply to this post by Ian Trudel-2

On 11 Mar 2010, at 14:47, Ian Trudel wrote:

> 2010/3/11 Torsten Bergmann <[hidden email]>:
>> Pharo allows you to use underscores in method selectors.
>> This is currently in Pharo 1.1 and not 1.0.
>>
>> Does that makes sense to have in Squeak trunk/Cuis too?
>
> No, this is *not* something I'd like to have in Squeak. It's a

Absolute necessity, has been second on my list for 5 years.

> potential disaster in the long run where either we will be forced to
> standardize code in some way or live with a basic image/trunk/etc and
> very weird variable names mixing camel_CameANd_whAtnot beyond the
> usage of Glorp.

I do not think that this follows at all.

Keith


 

Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

keith1y
In reply to this post by Sam Adams-2
> Please no!
> That fundamentally changes the readability of Squeak code
>
no it doesn't

It fundamentally gives you many ways to make code more readable. When  
you have a perform: ('scan_', aChoice) asSymbol this gives you methods  
#scan_Method #scan_Image #scan_Comment
> and makes all future code written that way incompatible with other  
> Smalltalks.
>
I don't think so, when I ported SSpec from VW the problem was the  
other way around, I had to use selectors like zMethod where z should  
have been an underscore.

Mapping to db fields is a pain
> And besides, some of us grey beards *like* our assignment arrows! ;-)
>
You can keep them, just make sure they have whitespace either side of  
them.
> If you really want that then create your own language variant or  
> maintain your own fork of Squeak. Its not that hard after all, I'm  
> doing both at present myself!
>
You dont have to use them if you dont want to.

Keith

 

Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Igor Stasenko
In reply to this post by Ian Trudel-2
On 11 March 2010 16:47, Ian Trudel <[hidden email]> wrote:

> 2010/3/11 Torsten Bergmann <[hidden email]>:
>> Pharo allows you to use underscores in method selectors.
>> This is currently in Pharo 1.1 and not 1.0.
>>
>> Does that makes sense to have in Squeak trunk/Cuis too?
>
> No, this is *not* something I'd like to have in Squeak. It's a
> potential disaster in the long run where either we will be forced to
> standardize code in some way or live with a basic image/trunk/etc and
> very weird variable names mixing camel_CameANd_whAtnot beyond the
> usage of Glorp.
>

I don't see any disaster with it. Take another languages, does a
presence of underscore in names makes them
more beatiful/horrible above anything else? I don't think so.

> o_O
> (how appropriate!)
>
> Ian.
> --
> http://mecenia.blogspot.com/
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Nicolas Cellier
2010/3/11 Igor Stasenko <[hidden email]>:

> On 11 March 2010 16:47, Ian Trudel <[hidden email]> wrote:
>> 2010/3/11 Torsten Bergmann <[hidden email]>:
>>> Pharo allows you to use underscores in method selectors.
>>> This is currently in Pharo 1.1 and not 1.0.
>>>
>>> Does that makes sense to have in Squeak trunk/Cuis too?
>>
>> No, this is *not* something I'd like to have in Squeak. It's a
>> potential disaster in the long run where either we will be forced to
>> standardize code in some way or live with a basic image/trunk/etc and
>> very weird variable names mixing camel_CameANd_whAtnot beyond the
>> usage of Glorp.
>>
>
> I don't see any disaster with it. Take another languages, does a
> presence of underscore in names makes them
> more beatiful/horrible above anything else? I don't think so.
>

To my understanding, there is no need of _ in selectors, BUT for
hooking external procedures.
It's painful to have to remember two different selectors when you
heaviily rely on FFI (OpenGL is a good example indeed).

Nicolas

>> o_O
>> (how appropriate!)
>>
>> Ian.
>> --
>> http://mecenia.blogspot.com/
>>
>>
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Igor Stasenko
On 11 March 2010 22:35, Nicolas Cellier
<[hidden email]> wrote:

> 2010/3/11 Igor Stasenko <[hidden email]>:
>> On 11 March 2010 16:47, Ian Trudel <[hidden email]> wrote:
>>> 2010/3/11 Torsten Bergmann <[hidden email]>:
>>>> Pharo allows you to use underscores in method selectors.
>>>> This is currently in Pharo 1.1 and not 1.0.
>>>>
>>>> Does that makes sense to have in Squeak trunk/Cuis too?
>>>
>>> No, this is *not* something I'd like to have in Squeak. It's a
>>> potential disaster in the long run where either we will be forced to
>>> standardize code in some way or live with a basic image/trunk/etc and
>>> very weird variable names mixing camel_CameANd_whAtnot beyond the
>>> usage of Glorp.
>>>
>>
>> I don't see any disaster with it. Take another languages, does a
>> presence of underscore in names makes them
>> more beatiful/horrible above anything else? I don't think so.
>>
>
> To my understanding, there is no need of _ in selectors, BUT for
> hooking external procedures.
> It's painful to have to remember two different selectors when you
> heaviily rely on FFI (OpenGL is a good example indeed).
>

First, i think we should answer to a simple question: why many other
computer languages allow underscores in their syntax as a
valid character for identifiers.
As to me, the answer is obvious: in natural languages we using space
to separate two words, and since parsers can't cope (or can, but its
highly impractical) with identifiers which having spaces:

my variable := foo.

an underscore is a good compromise between natural language and
computer language to separate two words,
while treat it as a single identifier:

my_variable := foo.

I came to smalltalk not long ago, and having over 15+ years of
programming experience.
I am always used underscores in this way, and never (or occasionally) like this:

_abdomination := foo.


Smalltalk spirit is a language which designed to remove unnecessary
barriers between humand and computer - easy to learn and easy to
express yourself, without need to be a highly educated
genius who can translate a natural human language to a cryptic sequece
of instructions which computer can understand.
And allowing underscores in identifiers, as to me, is highly coherent
with that spirit, because it this makes us easier to express
ourselves.

> Nicolas
>


--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Casey Ransberger
Does VW support underscores in selectors?

I'd worry about two things:

 - compatibility (which is already awful)

 - collision with assignment semantics when importing code that still
uses the underscore/arrow.

On Thursday, March 11, 2010, Igor Stasenko <[hidden email]> wrote:

> On 11 March 2010 22:35, Nicolas Cellier
> <[hidden email]> wrote:
>> 2010/3/11 Igor Stasenko <[hidden email]>:
>>> On 11 March 2010 16:47, Ian Trudel <[hidden email]> wrote:
>>>> 2010/3/11 Torsten Bergmann <[hidden email]>:
>>>>> Pharo allows you to use underscores in method selectors.
>>>>> This is currently in Pharo 1.1 and not 1.0.
>>>>>
>>>>> Does that makes sense to have in Squeak trunk/Cuis too?
>>>>
>>>> No, this is *not* something I'd like to have in Squeak. It's a
>>>> potential disaster in the long run where either we will be forced to
>>>> standardize code in some way or live with a basic image/trunk/etc and
>>>> very weird variable names mixing camel_CameANd_whAtnot beyond the
>>>> usage of Glorp.
>>>>
>>>
>>> I don't see any disaster with it. Take another languages, does a
>>> presence of underscore in names makes them
>>> more beatiful/horrible above anything else? I don't think so.
>>>
>>
>> To my understanding, there is no need of _ in selectors, BUT for
>> hooking external procedures.
>> It's painful to have to remember two different selectors when you
>> heaviily rely on FFI (OpenGL is a good example indeed).
>>
>
> First, i think we should answer to a simple question: why many other
> computer languages allow underscores in their syntax as a
> valid character for identifiers.
> As to me, the answer is obvious: in natural languages we using space
> to separate two words, and since parsers can't cope (or can, but its
> highly impractical) with identifiers which having spaces:
>
> my variable := foo.
>
> an underscore is a good compromise between natural language and
> computer language to separate two words,
> while treat it as a single identifier:
>
> my_variable := foo.
>
> I came to smalltalk not long ago, and having over 15+ years of
> programming experience.
> I am always used underscores in this way, and never (or occasionally) like this:
>
> _abdomination := foo.
>
>
> Smalltalk spirit is a language which designed to remove unnecessary
> barriers between humand and computer - easy to learn and easy to
> express yourself, without need to be a highly educated
> genius who can translate a natural human language to a cryptic sequece
> of instructions which computer can understand.
> And allowing underscores in identifiers, as to me, is highly coherent
> with that spirit, because it this makes us easier to express
> ourselves.
>
>> Nicolas
>>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
>

--
Casey Ransberger

Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

keith1y

On 11 Mar 2010, at 23:41, Casey Ransberger wrote:

> Does VW support underscores in selectors?

I believe so, since SSpec from Dave Astels was written with them

Keith
 

Reply | Threaded
Open this post in threaded view
|

Re: Selectors with underscores

Ralph Boland
In reply to this post by Torsten Bergmann
In the mind of some I did not make myself clear so allow
me to restate my position.
I am FOR supporting the use of  '_'  in
   selectors,
   variable names,
   class names,
   anywhere else where characters a-z,A-Z may be used to construct identifiers.

That said, I will rarely if ever use this feature.
I actually like being able to use  '_' for assignment (drawn as an arrow)
so I don't see the point of removing the use of  '_' for assignment unless
we intend to use it elsewhere.
I am also against compiler flags or other methods of allowing some to use
'_' for assignment or allowing or disallowing  use of  '_' in selectors, etc.

> Until now we have:

> PRO
> - Torsten
>  - Edgar
> - Bert
>  - Alexander
> - Matthew
> - Keith
> - Igor

> CONTRA
> - Ian Trudel
> - Sam

> SCOPING
> - Andreas (but vote PRO depend on backwards compatibility
      aspect)
> - Stéphane (votes for scoping)

NOT CLEARLY STATED
>  - Louis
> - Randal (vote seem to depend on Preference, which we now have)
> - Radoslav (but would rather ban underscore assignment, than
            underscores in method names)
> - Ralph Boland
> - Nicolas

Regards,

Ralph Boland