Enhancement Request: Adding population count for Integers to the standard image

Matthew S. Hamrick matthew.hamrick at gibson.com
Fri Dec 10 15:55:29 UTC 2004


There are historical reasons for calling this method popCount. The most 
significant being most of the people that will use it work within a 400 
yard radius of Ft. Meade, Maryland, Menwith Hill, England, and Moffett 
Field in Sunnyvale, California. They all call this operation 
"population count". Large Integer libraries from RSA Security, 
Certicom, the one I wrote for inclusion into the Treo 600 and 
Sony-Ericsson mobile phones, and GNU's MP (multiple precision) library 
also use this terminology.

So the idea for using the name 'popCount' comes from the fact that the 
community that's likely to use the instruction recognizes that name.

On the other hand, however, yes, the name is a little cryptic, and 
Squeak's role in education should not be under-appreciated. Maybe we 
could:

	1. define a method called numberOfOnes in Integer that performs the 
operation.
		1.a. this method would raise an error if we attempted to send it to a 
negative integer.
	2. define a method called numberOfZeros in Integer that performs the 
converse operation (counting the number of zeros in a negative 
integer.)
		2.a this method would raise an error if we attempted to send it to a 
positive integer.
	3. define a method called popCount in Integer that simply calls 
numberOfOnes.

This would have the benefit of providing a clearer name for the 
operation for people who might happen upon it while browsing the 
source. And considering that the implementation makes use of number 
theory that is definitely NOT taught in high-schools, a serendipitous 
encounter by a secondary school student and this method might lead to 
motivation to study more number theory and less arithmetic. At the same 
time, the cryptanalysis community will see the function using the 
'typical' name: popCount.

Included are change-sets for Integer, SmallInteger, and PopTestCount.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Integer.msh.6.cs
Type: application/octet-stream
Size: 2245 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20041210/c925a551/Integer.msh.6.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PopCountTest.msh.2.cs
Type: application/octet-stream
Size: 3829 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20041210/c925a551/PopCountTest.msh.2.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SmallInteger.msh.1.cs
Type: application/octet-stream
Size: 1056 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20041210/c925a551/SmallInteger.msh.1.obj
-------------- next part --------------


On Dec 10, 2004, at 8:08 AM, Marcus Denker wrote:

>
> Am 10.12.2004 um 13:54 schrieb st?phane ducasse:
>
>> matthew
>>
>> why don't you call your method numberOfZeros? because it is talking 
>> better to me.
>                                                             
> numberOfOnes
>
>
>


More information about the Squeak-dev mailing list