Some bugs I ran into while working on hashing

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

Some bugs I ran into while working on hashing

Andres Valloud-4
Hello, are these problems known?  I am using the latest RC build.

* Create changeset X.  Touch method Foo>>bar.  Create changeset Y.  
Touch method Foo>>bar again.  Fileout changeset X.  The fileout has the
code for changeset Y.

* Delete the first ! in a changeset with a preamble.  Try to load it
from the file tool.  You get a syntax error.  However, the progress bar
does not go away.  Is the file handle released?

* Integer>>isPrime should not be probabilistic.  Suggestion: rename it
to Integer>>isMostLikelyPrime or something similar.  Implement a
deterministic prime check for isPrime (even if it is slow --- users then
can decide whether they want a deterministic or probabilistic answer).  
Here's a rough sketch of Integer>>isPrime:

isPrime

    | guess guessSquared delta selfSqrtFloor |
    self <= 1 ifTrue: [^self error: 'operation undefined'].
    self even ifTrue: [^self = 2].
    guess := 1 bitShift: self highBit + 1 // 2.
    [
        guessSquared := guess * guess.
        delta := guessSquared - self // (guess bitShift: 1).
        delta = 0
    ] whileFalse: [guess := guess - delta].
    guessSquared = self ifFalse: [guess := guess - 1].
    selfSqrtFloor := guess.
    3 to: selfSqrtFloor by: 2 do: [:each | self \\ each = 0 ifTrue:
[^false]].
    ^true


Also, the above code can be used to implement sqrtFloor and sqrtRounded
in Integer.  I am sure Nicolas Cellier remembers this :).  Finally, I'm
not sure that isPrime should fail with "undefined operation" if the
receiver is <= 1.  1 is certainly not prime.  Primes must be positive,
so zero and the negatives could just answer false.  ???...

* Open an inspector on e.g.: Smalltalk.  In the code pane, type:

self keys inject: Set new into: [:t :x | t add: x class; yourself]

Using the mouse, select the expression, and inspect the result using the
right button menu item.  The result comes up.  However, the inspector on
Smalltalk experiences a failure in one of its panes because lines is nil
in MultiNewParagraph(NewParagraph)>>fastFindFirstLineSuchThat:

Andres.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Some bugs I ran into while working on hashing

Stéphane Ducasse
thanks andres
can you open bug entries?


> Hello, are these problems known?  I am using the latest RC build.
>
> * Create changeset X.  Touch method Foo>>bar.  Create changeset Y.
> Touch method Foo>>bar again.  Fileout changeset X.  The fileout has  
> the
> code for changeset Y.

It has always been like that in squeak since years. in Squeak cs do  
not record actual change
but just that something changed.

> * Delete the first ! in a changeset with a preamble.  Try to load it
> from the file tool.  You get a syntax error.  However, the progress  
> bar
> does not go away.  Is the file handle released?
>
> * Integer>>isPrime should not be probabilistic.  Suggestion: rename it
> to Integer>>isMostLikelyPrime or something similar.  Implement a
> deterministic prime check for isPrime (even if it is slow --- users  
> then
> can decide whether they want a deterministic or probabilistic answer).
> Here's a rough sketch of Integer>>isPrime:
>
> isPrime
>
>    | guess guessSquared delta selfSqrtFloor |
>    self <= 1 ifTrue: [^self error: 'operation undefined'].
>    self even ifTrue: [^self = 2].
>    guess := 1 bitShift: self highBit + 1 // 2.
>    [
>        guessSquared := guess * guess.
>        delta := guessSquared - self // (guess bitShift: 1).
>        delta = 0
>    ] whileFalse: [guess := guess - delta].
>    guessSquared = self ifFalse: [guess := guess - 1].
>    selfSqrtFloor := guess.
>    3 to: selfSqrtFloor by: 2 do: [:each | self \\ each = 0 ifTrue:
> [^false]].
>    ^true
>
>
> Also, the above code can be used to implement sqrtFloor and  
> sqrtRounded
> in Integer.  I am sure Nicolas Cellier remembers this :).  Finally,  
> I'm
> not sure that isPrime should fail with "undefined operation" if the
> receiver is <= 1.  1 is certainly not prime.  Primes must be positive,
> so zero and the negatives could just answer false.  ???...
>
> * Open an inspector on e.g.: Smalltalk.  In the code pane, type:
>
> self keys inject: Set new into: [:t :x | t add: x class; yourself]
>
> Using the mouse, select the expression, and inspect the result using  
> the
> right button menu item.  The result comes up.  However, the  
> inspector on
> Smalltalk experiences a failure in one of its panes because lines is  
> nil
> in MultiNewParagraph(NewParagraph)>>fastFindFirstLineSuchThat:
>
> Andres.
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Some bugs I ran into while working on hashing

Nicolas Cellier
In reply to this post by Andres Valloud-4
2009/10/25 Andres Valloud <[hidden email]>:

>
> isPrime
>
>    | guess guessSquared delta selfSqrtFloor |
>    self <= 1 ifTrue: [^self error: 'operation undefined'].
>    self even ifTrue: [^self = 2].
>    guess := 1 bitShift: self highBit + 1 // 2.
>    [
>        guessSquared := guess * guess.
>        delta := guessSquared - self // (guess bitShift: 1).
>        delta = 0
>    ] whileFalse: [guess := guess - delta].
>    guessSquared = self ifFalse: [guess := guess - 1].
>    selfSqrtFloor := guess.
>    3 to: selfSqrtFloor by: 2 do: [:each | self \\ each = 0 ifTrue:
> [^false]].
>    ^true
>
>
> Also, the above code can be used to implement sqrtFloor and sqrtRounded
> in Integer.  I am sure Nicolas Cellier remembers this :).

If http://bugs.squeak.org were not down, I would even provide a link
with these enhancements

>
> Andres.
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Some bugs I ran into while working on hashing

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

> 2009/10/25 Andres Valloud <[hidden email]>:
>>
>> isPrime
>>
>>    | guess guessSquared delta selfSqrtFloor |
>>    self <= 1 ifTrue: [^self error: 'operation undefined'].
>>    self even ifTrue: [^self = 2].
>>    guess := 1 bitShift: self highBit + 1 // 2.
>>    [
>>        guessSquared := guess * guess.
>>        delta := guessSquared - self // (guess bitShift: 1).
>>        delta = 0
>>    ] whileFalse: [guess := guess - delta].
>>    guessSquared = self ifFalse: [guess := guess - 1].
>>    selfSqrtFloor := guess.
>>    3 to: selfSqrtFloor by: 2 do: [:each | self \\ each = 0 ifTrue:
>> [^false]].
>>    ^true
>>
>>
>> Also, the above code can be used to implement sqrtFloor and sqrtRounded
>> in Integer.  I am sure Nicolas Cellier remembers this :).
>
> If http://bugs.squeak.org were not down, I would even provide a link
> with these enhancements
>

google says it should be http://www.google.fr/bugs.squeak.org/view.php?id=7099.
Or go to the source
http://blogten.blogspot.com/2008/06/drove-to-reno-today.html
http://blogten.blogspot.com/2008/06/update-on-sqrtrounded.html


>>
>> Andres.
>>
>> _______________________________________________
>> Pharo-project mailing list
>> [hidden email]
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>
>

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Some bugs I ran into while working on hashing

Stéphane Ducasse
nicolas if you produce a slice I will integrate them.
For now I'm focusing on emptying the pending stack of fixed items

Stef

On Oct 25, 2009, at 4:53 PM, Nicolas Cellier wrote:

> 2009/10/25 Nicolas Cellier <[hidden email]>:
>> 2009/10/25 Andres Valloud <[hidden email]>:
>>>
>>> isPrime
>>>
>>>    | guess guessSquared delta selfSqrtFloor |
>>>    self <= 1 ifTrue: [^self error: 'operation undefined'].
>>>    self even ifTrue: [^self = 2].
>>>    guess := 1 bitShift: self highBit + 1 // 2.
>>>    [
>>>        guessSquared := guess * guess.
>>>        delta := guessSquared - self // (guess bitShift: 1).
>>>        delta = 0
>>>    ] whileFalse: [guess := guess - delta].
>>>    guessSquared = self ifFalse: [guess := guess - 1].
>>>    selfSqrtFloor := guess.
>>>    3 to: selfSqrtFloor by: 2 do: [:each | self \\ each = 0 ifTrue:
>>> [^false]].
>>>    ^true
>>>
>>>
>>> Also, the above code can be used to implement sqrtFloor and  
>>> sqrtRounded
>>> in Integer.  I am sure Nicolas Cellier remembers this :).
>>
>> If http://bugs.squeak.org were not down, I would even provide a link
>> with these enhancements
>>
>
> google says it should be http://www.google.fr/bugs.squeak.org/view.php?id=7099 
> .
> Or go to the source
> http://blogten.blogspot.com/2008/06/drove-to-reno-today.html
> http://blogten.blogspot.com/2008/06/update-on-sqrtrounded.html
>
>
>>>
>>> Andres.
>>>
>>> _______________________________________________
>>> Pharo-project mailing list
>>> [hidden email]
>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>>>
>>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project