Re: [Pharo-dev] Capitalized

2017-03-15 Thread stepharong

Hi torsten

I do not get your point. In Pharo 60 we have.

capitalized
"Return a copy with the first letter capitalized"
| cap |
self isEmpty ifTrue: [ ^self copy ].
cap := self copy.
cap at: 1 put: (cap at: 1) asUppercase.
^ cap


"'snoopy' capitalized

'Snoopy'"


Stef



Re: [Pharo-dev] Capitalized

2017-03-15 Thread stepharong

Ok I got it

you mean

"'snOOpy' capitalized
>>>'Snoopy'"


and not
"'snOOpy' capitalized
>>>'SnOOpy'"


Indeed.

Now captialized comment is clear.
We could do that in Pharo70 alpha.
Now for OS that distinguish S from s we should pay attention.

Stef

On Wed, 15 Mar 2017 11:33:35 +0100, Torsten Bergmann   
wrote:



According to https://en.wikipedia.org/wiki/Capitalization

to "capitalize" is writing a word with its first letter as a capital  
letter (upper-case letter)

AND THE REMAINING LETTERS IN LOWER CASE writing systems.

So

  'SOMETHING' capitalized

currently returns "SOMETHING" in Pharo but should return "Something"  
according to the definition to end up with lowercase.
If we fix this I guess we would also align Pharo with other languages,  
like C# for example [1].


Could be easily changed by replacing "copy" with "asLowercase" in  
#capitalized:


 capitalized
"Return a copy with the first letter capitalized"
| cap |
self isEmpty ifTrue: [ ^self copy ].
cap := self asLowercase.
cap at: 1 put: (cap at: 1) asUppercase.
^ cap

Should we fix this? Do not know about any side effects...


Note: a) Squeak has the same issue
  b) it fits for #uncapitalized, see [2]
  c) Dont know about ANSI standard or any other ST dialect

Thx
T.


[1]  
https://github.com/srkirkland/Inflector/blob/master/Inflector.Tests/CapitalizeTests.cs
[2]  
https://github.com/srkirkland/Inflector/blob/master/Inflector.Tests/UncapitalizeTests.cs





--
Using Opera's mail client: http://www.opera.com/mail/



Re: [Pharo-dev] Capitalized

2017-03-15 Thread Torsten Bergmann
Hi,

thanks for the feedback. So it depends on which definition we will follow...

After investigating a little bit more I guess the current implementation is more
valuable and should stay. For instance we can easily convert an ivar name into 
a class name with it:   'ellipseMorph' capitalized -> 'EllipseMorph'
Also then this is in alignment with other dialects.

Additionally: changing it would break too many things because it is often used 
in some #perform: 
based meta-magic and other (see SpecPreDebugWindow>>createNotifierPaneWidgets 
for an example)

Sorry for the noise. I should upload a slice to Wikipedia + GitHub ;)

Bye
T.

> Gesendet: Mittwoch, 15. März 2017 um 14:30 Uhr
> Von: "John Brant" 
> An: pharo-dev@lists.pharo.org
> Betreff: Re: [Pharo-dev] Capitalized
>
> On 03/15/2017 05:33 AM, Torsten Bergmann wrote:
> > According to https://en.wikipedia.org/wiki/Capitalization
> >
> > to "capitalize" is writing a word with its first letter as a capital letter 
> > (upper-case letter)
> > AND THE REMAINING LETTERS IN LOWER CASE writing systems.
> >
> > So
> >
> >   'SOMETHING' capitalized
> >
> > currently returns "SOMETHING" in Pharo but should return "Something" 
> > according to the definition to end up with lowercase.
> > If we fix this I guess we would also align Pharo with other languages, like 
> > C# for example [1].
> 
> That wouldn't be what I would expect. Here's what dictionary.com has for 
> capitalize:
> 
>   1. to write or print in capital letters letters or
>   with an initial capital letter
> 
> That definition doesn't say what happens with the rest of the letters.
> 
> As for C#, isn't that someone's extension method for String and not a 
> Microsoft method? I don't see that method on Microsoft's current String 
> class documentation:
> 
> https://msdn.microsoft.com/en-us/library/system.string(v=vs.110).aspx
> 
> Also, the Uncapitalize method is inconsistent with the Capitalize 
> method. The Uncapitalize method changes only the first character and all 
> other characters are unchanged. However, the Capitalize method can 
> change all characters.
> 
> Finally, Dolphin Smalltalk has an implementation that is similar to Pharo's:
> 
> https://github.com/dolphinsmalltalk/Dolphin/blob/master/Core/Object%20Arts/Dolphin/Base/String.cls
> 
> 
> John Brant
> 
>



Re: [Pharo-dev] Capitalized

2017-03-15 Thread Ben Coman
On Wed, Mar 15, 2017 at 6:33 PM, Torsten Bergmann  wrote:

> According to https://en.wikipedia.org/wiki/Capitalization
>
> to "capitalize" is writing a word with its first letter as a capital
> letter (upper-case letter)
> AND THE REMAINING LETTERS IN LOWER CASE writing systems.
>
> So
>
>   'SOMETHING' capitalized
>
> currently returns "SOMETHING" in Pharo but should return "Something"
> according to the definition to end up with lowercase.
>

I think it would be reasonable to expect...
self assert: 'something' capitalized
   equals: 'SOMETHING' capitalized

In ignorance of history, I'd call this a bug.
Maybe not for "frozen" Pharo 6, but not needing a deprecation, just a fix.

cheers -ben


> If we fix this I guess we would also align Pharo with other languages,
> like C# for example [1].
>
> Could be easily changed by replacing "copy" with "asLowercase" in
> #capitalized:
>
>  capitalized
> "Return a copy with the first letter capitalized"
> | cap |
> self isEmpty ifTrue: [ ^self copy ].
> cap := self asLowercase.
> cap at: 1 put: (cap at: 1) asUppercase.
> ^ cap
>
> Should we fix this? Do not know about any side effects...
>
>
> Note: a) Squeak has the same issue
>   b) it fits for #uncapitalized, see [2]
>   c) Dont know about ANSI standard or any other ST dialect
>
> Thx
> T.
>
>
> [1] https://github.com/srkirkland/Inflector/blob/master/Inflector.Tests/
> CapitalizeTests.cs
> [2] https://github.com/srkirkland/Inflector/blob/master/Inflector.Tests/
> UncapitalizeTests.cs
>
>


Re: [Pharo-dev] Capitalized

2017-03-15 Thread John Brant

On 03/15/2017 05:33 AM, Torsten Bergmann wrote:

According to https://en.wikipedia.org/wiki/Capitalization

to "capitalize" is writing a word with its first letter as a capital letter 
(upper-case letter)
AND THE REMAINING LETTERS IN LOWER CASE writing systems.

So

  'SOMETHING' capitalized

currently returns "SOMETHING" in Pharo but should return "Something" according 
to the definition to end up with lowercase.
If we fix this I guess we would also align Pharo with other languages, like C# 
for example [1].


That wouldn't be what I would expect. Here's what dictionary.com has for 
capitalize:


1. to write or print in capital letters letters or
with an initial capital letter

That definition doesn't say what happens with the rest of the letters.

As for C#, isn't that someone's extension method for String and not a 
Microsoft method? I don't see that method on Microsoft's current String 
class documentation:


https://msdn.microsoft.com/en-us/library/system.string(v=vs.110).aspx

Also, the Uncapitalize method is inconsistent with the Capitalize 
method. The Uncapitalize method changes only the first character and all 
other characters are unchanged. However, the Capitalize method can 
change all characters.


Finally, Dolphin Smalltalk has an implementation that is similar to Pharo's:

https://github.com/dolphinsmalltalk/Dolphin/blob/master/Core/Object%20Arts/Dolphin/Base/String.cls


John Brant



Re: [Pharo-dev] Capitalized

2017-03-15 Thread Peter Uhnak
Maybe for next Pharo version? As this is a breaking change, which you cannot 
just deprecate. Also then there would need to be another method that provides 
the current behavior.

Peter

On Wed, Mar 15, 2017 at 12:16:44PM +, Henrik Nergaard wrote:
> >to "capitalize" is writing a word with its first letter.
> 
> The Smalltalk String is not neccessarily just a word, it could be something 
> else so the current implementation makes no assumptions of what the string is.
> 
> -
> 
> | newClass |
> 
> newClass := Object subclass: #AbcSomeClass
> instanceVariableNames: 'errorCodeName referencePosition instanceVariable'.
> newClass instanceVariableNamesDo: [ :aString | | code |
> code := String streamContents: [ :aStream | | prefix cap |
> prefix := aString first isVowel ifTrue: ['an'] ifFalse: ['a'].
> cap := aString capitalized.
> aStream
> << aString; << ':'; space; << prefix; << cap;
> cr; cr; tab;
> << aString; << ' := '; << prefix; << cap.
> ].
> newClass compile: code classified: 'accessing'
> ].
> 
> newClass browse
> 
> 
> 
> >Should we fix this? Do not know about any side effects...
> 
> I think it would be better and more clear to then implement a new method 
> called something like #onlyCapitalized that removes all other uppercase 
> letters.
> 
> 
> Best regards,
> 
> Henrik
> 
> 
> 
> Fra: Pharo-dev  på vegne av Torsten 
> Bergmann 
> Sendt: 15. mars 2017 11:33:35
> Til: Pharo Development List
> Emne: [Pharo-dev] Capitalized
> 
> According to https://en.wikipedia.org/wiki/Capitalization
> 
> to "capitalize" is writing a word with its first letter as a capital letter 
> (upper-case letter)
> AND THE REMAINING LETTERS IN LOWER CASE writing systems.
> 
> So
> 
>   'SOMETHING' capitalized
> 
> currently returns "SOMETHING" in Pharo but should return "Something" 
> according to the definition to end up with lowercase.
> If we fix this I guess we would also align Pharo with other languages, like 
> C# for example [1].
> 
> Could be easily changed by replacing "copy" with "asLowercase" in 
> #capitalized:
> 
>  capitalized
> "Return a copy with the first letter capitalized"
> | cap |
> self isEmpty ifTrue: [ ^self copy ].
> cap := self asLowercase.
> cap at: 1 put: (cap at: 1) asUppercase.
> ^ cap
> 
> Should we fix this? Do not know about any side effects...
> 
> 
> Note: a) Squeak has the same issue
>   b) it fits for #uncapitalized, see [2]
>   c) Dont know about ANSI standard or any other ST dialect
> 
> Thx
> T.
> 
> 
> [1] 
> https://github.com/srkirkland/Inflector/blob/master/Inflector.Tests/CapitalizeTests.cs
> [2] 
> https://github.com/srkirkland/Inflector/blob/master/Inflector.Tests/UncapitalizeTests.cs
> 



Re: [Pharo-dev] Capitalized

2017-03-15 Thread Henrik Nergaard
>to "capitalize" is writing a word with its first letter.

The Smalltalk String is not neccessarily just a word, it could be something 
else so the current implementation makes no assumptions of what the string is.

-

| newClass |

newClass := Object subclass: #AbcSomeClass
instanceVariableNames: 'errorCodeName referencePosition instanceVariable'.
newClass instanceVariableNamesDo: [ :aString | | code |
code := String streamContents: [ :aStream | | prefix cap |
prefix := aString first isVowel ifTrue: ['an'] ifFalse: ['a'].
cap := aString capitalized.
aStream
<< aString; << ':'; space; << prefix; << cap;
cr; cr; tab;
<< aString; << ' := '; << prefix; << cap.
].
newClass compile: code classified: 'accessing'
].

newClass browse



>Should we fix this? Do not know about any side effects...

I think it would be better and more clear to then implement a new method called 
something like #onlyCapitalized that removes all other uppercase letters.


Best regards,

Henrik


________
Fra: Pharo-dev  på vegne av Torsten Bergmann 

Sendt: 15. mars 2017 11:33:35
Til: Pharo Development List
Emne: [Pharo-dev] Capitalized

According to https://en.wikipedia.org/wiki/Capitalization

to "capitalize" is writing a word with its first letter as a capital letter 
(upper-case letter)
AND THE REMAINING LETTERS IN LOWER CASE writing systems.

So

  'SOMETHING' capitalized

currently returns "SOMETHING" in Pharo but should return "Something" according 
to the definition to end up with lowercase.
If we fix this I guess we would also align Pharo with other languages, like C# 
for example [1].

Could be easily changed by replacing "copy" with "asLowercase" in #capitalized:

 capitalized
"Return a copy with the first letter capitalized"
| cap |
self isEmpty ifTrue: [ ^self copy ].
cap := self asLowercase.
cap at: 1 put: (cap at: 1) asUppercase.
^ cap

Should we fix this? Do not know about any side effects...


Note: a) Squeak has the same issue
  b) it fits for #uncapitalized, see [2]
  c) Dont know about ANSI standard or any other ST dialect

Thx
T.


[1] 
https://github.com/srkirkland/Inflector/blob/master/Inflector.Tests/CapitalizeTests.cs
[2] 
https://github.com/srkirkland/Inflector/blob/master/Inflector.Tests/UncapitalizeTests.cs



[Pharo-dev] Capitalized

2017-03-15 Thread Torsten Bergmann
According to https://en.wikipedia.org/wiki/Capitalization

to "capitalize" is writing a word with its first letter as a capital letter 
(upper-case letter) 
AND THE REMAINING LETTERS IN LOWER CASE writing systems.

So 

  'SOMETHING' capitalized

currently returns "SOMETHING" in Pharo but should return "Something" according 
to the definition to end up with lowercase.
If we fix this I guess we would also align Pharo with other languages, like C# 
for example [1]. 

Could be easily changed by replacing "copy" with "asLowercase" in #capitalized:

 capitalized
"Return a copy with the first letter capitalized"
| cap |
self isEmpty ifTrue: [ ^self copy ].
cap := self asLowercase.
cap at: 1 put: (cap at: 1) asUppercase.
^ cap

Should we fix this? Do not know about any side effects...


Note: a) Squeak has the same issue
  b) it fits for #uncapitalized, see [2]
  c) Dont know about ANSI standard or any other ST dialect

Thx
T.


[1] 
https://github.com/srkirkland/Inflector/blob/master/Inflector.Tests/CapitalizeTests.cs
[2] 
https://github.com/srkirkland/Inflector/blob/master/Inflector.Tests/UncapitalizeTests.cs