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

[REBOL] Confusing hash! behavior?

From: rex::smallandmighty::com at: 8-Aug-2001 14:11

Are there any gotchas or flat out bugs I need to know about with regards to using the hash! datatype? I've been experiencing some weirdness with regards to accessing the contents when they're a field of a nested object!, Sketch of the hierarchy: outer object! contains *data field as a hash! block *inner object! contains *code which inserts and accesses the keys and values stored in the data field defined in the enclosing object! For some reason values get put in the hash! while executing a function in the generator object, but when the function exits, the hash! in the outer object! is empty, yet these should reference the same hash!. I haven't copied it, and the set-word in the outer object! that the hash! is bound to hasn't been redefined anywhere within the inner object!. I do initialize the hash! during construction of the outer object! Something very similar to: meta: make hash! 255 My gut seems to be telling me that hashes only really like to be constructed from preexisting blocks, e.g. make hash! [ a "snout" b haunch c "chitterling" ] Insert and append seem to work fine external to an object!, but are very unreliable internally. It seems like sometimes the external set-word and the internal set-word used to represent the state of the hash! get out of sync. Should I keep another normal block! around with duplicate references to the keys and values and then always rebuild a new hash! upon insertion? Insertion should be a relatively infrequent events in my app, but I do need as close to a constant time key-value look-up as possible. I'm not quite exasperated, but I'm definitely somewhat frustrated. I don't want to start kludging when I could just be working with these things in a fundamentally incorrect manner. I'm using Rebol/Core 2,5 on Mac OS X. .:Eric