non braking space oddity

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

non braking space oddity

Nicolas Cellier
While looking at http://bugs.squeak.org/view.php?id=7211, I found this
funny classification:

Character nbsp isSeparator. -> false
(Scanner new typeTableAt: Character nbsp) -> #xBinary

That makes nbsp a valid binary selector, and that ain't good...

Example: I thought I would compile a method #bingo, but I compile a
method with an invisible binary selector...

Object compile: (String with: Character nbsp) , ' bingo ^self'.
2 perform: (String with: Character nbsp) asSymbol with: nil.
2 perform: #bingo.

Note that a leading nbsp can happen via a copy from web...
I doubt this is an intentional feature.

Reply | Threaded
Open this post in threaded view
|

Re: non braking space oddity

Nicolas Cellier
Hem, definition: a braking space with good enough brakes prevent a line break.

I would prefer a default fill of TypeTable with #xInvalidCharacter
wouldn't you ?

Nicolas

2009/10/27 Nicolas Cellier <[hidden email]>:

> While looking at http://bugs.squeak.org/view.php?id=7211, I found this
> funny classification:
>
> Character nbsp isSeparator. -> false
> (Scanner new typeTableAt: Character nbsp) -> #xBinary
>
> That makes nbsp a valid binary selector, and that ain't good...
>
> Example: I thought I would compile a method #bingo, but I compile a
> method with an invisible binary selector...
>
> Object compile: (String with: Character nbsp) , ' bingo ^self'.
> 2 perform: (String with: Character nbsp) asSymbol with: nil.
> 2 perform: #bingo.
>
> Note that a leading nbsp can happen via a copy from web...
> I doubt this is an intentional feature.
>

Reply | Threaded
Open this post in threaded view
|

Re: non braking space oddity

Nicolas Cellier
2009/10/27 Nicolas Cellier <[hidden email]>:
> Hem, definition: a braking space with good enough brakes prevent a line break.
>
> I would prefer a default fill of TypeTable with #xInvalidCharacter
> wouldn't you ?
>

Oh, I just noticed there is a #xIllegal ... Not really used.

Using #xIllegal as default type would raise the question of what
character beyond ASCII can be considered a valid binary...

«¬­±·»¿×÷ eventually are good candidates for example
Not sure about these ¢£¤¥§¶

My following question will be about
Scanner>>typeTableAt: aCharacter
        ^typeTable at: aCharacter charCode ifAbsent:[#xLetter]

I would tend to restrict this to
        ^typeTable at: aCharacter charCode ifAbsent:[
                aCharacter isLetter
                        ifTrue: [#xLetter]
                        ifFalse: [#xIllegal]]

but we might want some more extended binary characters...
And program with ideograms, not only letters...

Unless we restrict selectors to ASCII ?
Are non ASCII selectors in use ?

> Nicolas
>
> 2009/10/27 Nicolas Cellier <[hidden email]>:
>> While looking at http://bugs.squeak.org/view.php?id=7211, I found this
>> funny classification:
>>
>> Character nbsp isSeparator. -> false
>> (Scanner new typeTableAt: Character nbsp) -> #xBinary
>>
>> That makes nbsp a valid binary selector, and that ain't good...
>>
>> Example: I thought I would compile a method #bingo, but I compile a
>> method with an invisible binary selector...
>>
>> Object compile: (String with: Character nbsp) , ' bingo ^self'.
>> 2 perform: (String with: Character nbsp) asSymbol with: nil.
>> 2 perform: #bingo.
>>
>> Note that a leading nbsp can happen via a copy from web...
>> I doubt this is an intentional feature.
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: non braking space oddity

Andreas.Raab
Nicolas Cellier wrote:
> Oh, I just noticed there is a #xIllegal ... Not really used.
>
> Using #xIllegal as default type would raise the question of what
> character beyond ASCII can be considered a valid binary...
>
> «¬­±·»¿×÷ eventually are good candidates for example
> Not sure about these ¢£¤¥§¶

Good question. I would vote for being somewhat conservative and instead
of using xIllegal for potential binary values use something like
xQuestionable which would raise an exception that client code could
handle if needed (and if unhandled behave like xIllegal).

> My following question will be about
> Scanner>>typeTableAt: aCharacter
> ^typeTable at: aCharacter charCode ifAbsent:[#xLetter]
>
> I would tend to restrict this to
> ^typeTable at: aCharacter charCode ifAbsent:[
> aCharacter isLetter
> ifTrue: [#xLetter]
> ifFalse: [#xIllegal]]
>
> but we might want some more extended binary characters...
> And program with ideograms, not only letters...
>
> Unless we restrict selectors to ASCII ?
> Are non ASCII selectors in use ?

Yes. Not in any standard Squeak images but I've seen non-ascii selectors
in custom code (and I think it's perfectly reasonable).

Cheers,
   - Andreas