D5 - congrats and a question 
Author Message
 D5 - congrats and a question

Andy and Blair,

Congratulations on the release of D5!!

Dictionary no longer allows nil keys.  Why the test/error?

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.



Wed, 20 Oct 2004 04:36:26 GMT  
 D5 - congrats and a question

Quote:
> Andy and Blair,

> Congratulations on the release of D5!!

> Dictionary no longer allows nil keys.  Why the test/error?

Because LookupTable/IdentityDictionary store the (key,value) pair in
parallel arrays, rather than an array of Associations, and they use nil to
mark empty slots in the key array making it impossible to distinguish a nil
key from an empty slot. LookupTable and Dictionary are interchangeable for
the majority of requirements for a "map" (though we tend to use the former
because it is more efficient), so it seemed preferable to disallow nil keys
for both rather than introduce an inconsistency.

Regards

Blair



Wed, 20 Oct 2004 07:03:28 GMT  
 D5 - congrats and a question
Blair,

Quote:
> Because LookupTable/IdentityDictionary store the (key,value) pair in
> parallel arrays, rather than an array of Associations, and they use nil to
> mark empty slots in the key array making it impossible to distinguish a
nil
> key from an empty slot. LookupTable and Dictionary are interchangeable for
> the majority of requirements for a "map" (though we tend to use the former
> because it is more efficient), so it seemed preferable to disallow nil
keys
> for both rather than introduce an inconsistency.

Does ANSI specify the "correct" behavior?  It seems that somewhere one would
want to have the option to associate something with nothing, or perhaps with
nil as the singleton UndefinedObject.  I remember hitting the same issue
with SharedLookupTable, and just hacked around it; in that case, I really
care about nil as "just another object".  The code that blew up today can be
altered, but, a Dictionary that happens to have a nil key really seems to
fit the problem.

Anyway, it sounds like I can safely remove the check to get things going??

Have a good one,

Bill

--
Wilhelm K. Schwab, Ph.D.



Wed, 20 Oct 2004 07:45:00 GMT  
 D5 - congrats and a question

Quote:
> Blair,

> > Because LookupTable/IdentityDictionary store the (key,value) pair in
> > parallel arrays, rather than an array of Associations, and they use nil
to
> > mark empty slots in the key array making it impossible to distinguish a
> nil
> > key from an empty slot. LookupTable and Dictionary are interchangeable
for
> > the majority of requirements for a "map" (though we tend to use the
former
> > because it is more efficient), so it seemed preferable to disallow nil
> keys
> > for both rather than introduce an inconsistency.

> Does ANSI specify the "correct" behavior?

Yes, in a way. It specifically says that it is "undefined" :-). This means
that regardles of what the "correct" behaviour might be from an intellectual
perspective, the different dialects at the time of its writing adopted
different rules so it was deliberately left unspecified. Dolphin XP, like
VisualWorks, treats it as an error. Past Dolphin versions did not explicitly
treated as an error, but it did result in "undefined" behaviour.

Regards

Blair



Wed, 20 Oct 2004 22:06:51 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Congrats to the ruby-talk list

2. Congrats to Intel on Fortran 8.0

3. Congrats J3

4. Congrats to the XSB team for XSB 2.3!

5. (non-python) congrats to Bob Kahn

6. congrats to infoseek

7. D5.1.1 Bug -- The Save as Ugly Name Blues

8. D5.1: Workarounds for two strange TreeView quirks

9. what version of D5.1 runs smacc?

10. Q: Unicode support for text edit control? (D5)

11. Issues porting app from D4 to D5

12. D5 patches

 

 
Powered by phpBB® Forum Software