Stephan Bergmann wrote:
On 03/20/09 23:04, Frank Schönheit - Sun Microsystems Germany wrote:
In all other cases, it is at the implementations discretion whether for
a given KeyType, it is possible to put the VOID key into the map.
Strictly, you could say it should not be possible since actually, VOID
is not a value from KeyType's value set. It is "only" that the generic
API ("put( any, any)") allows for VOID keys, where a less generic API
("XMap< KeyType, ValueType > { put( KeyType, ValueType ); }" ) would not
allow for it.
However, I would not restrict implementations too much, so I preferred
to leave it undecided in the interface definition whether VOID keys (or
values) are accepted.
Why special case VOID and not, say, CHAR?
I would prefer not to have special key at all. The above reasoning
(put(any,any) allows VOID keys) is true for all types supported by ANY
and therefore is not really an argument for having a special key.
But if we really need a special case then I vote for VOID:
1. For type VOID there is only one value (whatever its name may be).
2. When the key type is CHAR then CHAR can not be the type of a special
case. VOID has been ruled out as key type and therefore can be used as
special case for every key type.
But I get your point: Leave out "unreasonable" types that would lead
to hassle in the implementations (one might also want to leave out
float and double, given their peculiarities).
I am not sure I should dare to ask ... with peculiarities of float and
double, you refer to what? The only thing I can imagine right now is
their ... imprecision, which shouldn't be a problem in this context. Do
they have more issues, perhaps when passed around crossing bridges?
Yes, equality over floating point numbers is complicated by precision
(e.g., in languages like C and C++, intermediates may arbitrarily be
kept in extended-precision registers, so that x+y==x+y need not be true)
and NaN (where NaN==NaN is false).
Well, yes, but all of these problems are already there as soon as you
use pseudo real numbers. They are not introduced by the use of a map.
Why not have some faith in the future users of the map? They may know
of these problems and still have a perfectly good reason to use double
or float as map key.
Best regards,
Andre
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]