[bug] Float >> NaN in a dictionary

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

[bug] Float >> NaN in a dictionary

MrGwen
Issue status update for
http://smalltalk.gnu.org/node/317
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/317

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     normal
 Assigned to:  Unassigned
 Reported by:  MrGwen
 Updated by:   MrGwen
 Status:       active

Hi,

I cann add a Float >> NaN in a dictionary by the way multiple times (

st> p at: (FloatQ allInstances at: 3) put: 123
st> p at: (FloatQ allInstances at: 3) put: 123
st> p at: (FloatQ allInstances at: 3) put: 123
st> p
Dictionary (
       NaN->123
       NaN->123
       NaN->123
))

But when I try to acces to it, it failed :

Object: Dictionary new: 32 "<0x2b1783097a40>" error: Invalid argument
Inf: key not found
SystemExceptions.NotFound(Exception)>>signal
SystemExceptions.NotFound(Exception)>>signal:
SystemExceptions.NotFound class>>signalOn:what:
[] in Dictionary>>at:
Dictionary>>at:ifAbsent:
Dictionary>>at:
UndefinedObject>>executeStatements




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] Float >> NaN in a dictionary

Paolo Bonzini-3
Issue status update for
http://smalltalk.gnu.org/project/issue/317
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/317

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     normal
 Assigned to:  Unassigned
 Reported by:  MrGwen
 Updated by:   bonzinip
 Status:       active

I'd say it does not make much sense.  Given that NaNs are ~= to
themselves, you cannot do anything with them in an equality-based hash
table (only in a identity-based one).

Were you just playing with fire or did you get into this in some
real-world case?

I wonder how much if anything would be broken by making Float>>#hash
raise an exception for NaNs.




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Re: [bug] Float >> NaN in a dictionary

MrGwen
On Friday 12 June 2009 11:09:54 Paolo Bonzini wrote:

> Issue status update for
> http://smalltalk.gnu.org/project/issue/317
> Post a follow up:
> http://smalltalk.gnu.org/project/comments/add/317
>
>  Project:      GNU Smalltalk
>  Version:      <none>
>  Component:    Base classes
>  Category:     bug reports
>  Priority:     normal
>  Assigned to:  Unassigned
>  Reported by:  MrGwen
>  Updated by:   bonzinip
>  Status:       active
>
> I'd say it does not make much sense.  Given that NaNs are ~= to
> themselves, you cannot do anything with them in an equality-based hash
> table (only in a identity-based one).

I understand, I don't know well the behavior of Float.

>
> Were you just playing with fire or did you get into this in some
> real-world case?
>

In fact I'm working on a tool for saving "image" written in Smalltalk. (I need
to create this tool and not to use the code in the vm) So the idea is to put
all the objects in a dictionary and we know if the object was written or not
(and by the way the position of the written object is in the dic) - like the
SystemTracer in Squeak. But I can handle this problem in an other way.

> I wonder how much if anything would be broken by making Float>>#hash
> raise an exception for NaNs.
>
>
>
>
> _______________________________________________
> help-smalltalk mailing list
> [hidden email]
> http://lists.gnu.org/mailman/listinfo/help-smalltalk

Cheers,
Gwenael

--

GtkLauncher for GNU Smalltalk : http://gtklauncher.bioskop.fr/


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Re: [bug] Float >> NaN in a dictionary

Paolo Bonzini-3

> In fact I'm working on a tool for saving "image" written in Smalltalk. (I need
> to create this tool and not to use the code in the vm) So the idea is to put
> all the objects in a dictionary and we know if the object was written or not
> (and by the way the position of the written object is in the dic) - like the
> SystemTracer in Squeak. But I can handle this problem in an other way.

You need an IdentityDictionary for that anyway.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] Float >> NaN in a dictionary

Paolo Bonzini-3
In reply to this post by MrGwen
Issue status update for
http://smalltalk.gnu.org/project/issue/317
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/317

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     normal
 Assigned to:  Unassigned
 Reported by:  MrGwen
 Updated by:   bonzinip
-Status:       active
+Status:       fixed

Fixed in 46d1034 by refusing to hash a NaN (it works in
IdentityDictionaries of course).




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk