On Thu, Jul 07, 2011 at 04:15:16PM +0200, Leon Timmermans wrote: > On Thu, Jul 7, 2011 at 2:31 PM, Nicholas Clark <nick@ccl4.org> wrote: > > Also, right now, I think that only read-only views of read-write scalars > > will work. SvREADONLY() doesn't currently mean anything on arrays, hashes > > (typeglobs etc). Even worse, SVf_READONLY is hijacked on hashes to mean > > "restricted hash", so they would have to be moved out of the way to allow > > anything. > > SvREADONLY works fine on arrays. The situation with hashes is > something that annoys me, not in the last place because it's almost > but not quite the right thing. Oops. I thought that it didn't. "Use the source" failure on my part. "restricted hashes" almost do one of several possible permutations of "restriction". I think each of the following would be useful at different times: -1: keys fixed. No adding or deleting +1: keys from a fixed list. (What they currently do IIRC) and orthogonal to that -i: values fixed - you can't assign a new value for any key (this would be stronger than the "readonly" we're proposing) +i: values mutable - you can replace them [in that setting SvREADONLY() on something doesn't prevent you from deleting it] > > Which suggests that "shallow" is a reasonable answer. > > Which is exactly what it currently does. Except not quite, as restricted hashes let you delete their keys. I'm starting to think that the least insane solution to this *is* a general purpose vtable interface for hashes, and a general purpose vtable interface for arrays, and then implement tie (and all the other existing funky stuff) with that. It would then give the flexibility to do other stuff well, such as decently sparse arrays, and (I think) Reini's proposed typed arrays. Nicholas ClarkThread Previous | Thread Next