Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Associative Data Store Re:(6)

From: brian:hawley:bigfoot at: 19-Sep-2000 22:57

Joel Neely wrote:
>1) The motivation for my original note on the age/grade example was > specifically to explain why I believe there are reasonable uses >for block! data as keys. If memory serves, your Associate and > Associate? functions support that capability. So I think we're in >violent agreement here ;-) since we're dealing with the same >concept.
There are only two problems with using blocks as keys. First, blocks can be recursive, directly or indirectly. You can't directly compare recursive blocks without crashing REBOL. This is true not only for the equality operations but also for find and select as well. I just checked every comparison operator - you can't even use =? or <>. Second, the hash! type only hashes on string types. There is no reason to expect RT to extend hashing to block types - the most we could hope for would be immediate values and word types. To hash structured values is an expensive process. Both these problems are solved by molding any-block! keys. Mold now works on recursive structures, and the result is a string. It even allows hashes to optimize lookup of non-strings. This is only speed-efficient with large amounts of data but at least it won't crash REBOL. I'll stay neutral on the cost/benefit analysis of objects versus global functions. I chalk it up to individual preference. Brian Hawley