Dan Sugalski <[EMAIL PROTECTED]> wrote:Log: Accessing env variables is a nice thing
Yep. Good idea.
It was about time. :) And trivial, as too much of the pending stuff has been.
> pmclass Env extends default {
What do you think of: - Env extends PerlHash
Thought about it, but I couldn't think of a reason why. The only thing really hashlike about them is that you read and write by name. Which, granted, is awfully hashlike, but none of the rest of the hash stuff seemed needed. It's not like you can access environment variables by index, or that there's any sort of multidimensionality to them.
I can see throwing together the code to take and return PMCs, which really ought to be in but isn't. Past that, I don't know if it's worth much. (Though env variables are, arguably, multidimensional in a trivial sense)
- interpreter has an empty env variable created at interpreter creation - on first access to it, the hash gets populated, writing to the hash does a setenv(3) too.
I'd considered that, but I don't think it's necessarily a great idea, as it introduces a layer of caching that can get defeated by threads, since we're not sharing a single PMC across all the threads. (Though we probably ought to)
- delete_keyed does an unsetenv(3), if available of course.
Good point, that should be in there. And it will be as soon as I sync up with CVS. :)
- defined_keyed, exists_keyed delegate (after possibly) filling the hash to SUPER().
Possibly, yeah, I can see that.
I'm also considering means to override the way this behaves since in an embedded context direct get/set/unset will be potentially overridden, and then there are platform-specific overrides that folks may want. (For VMS and Windows, for example)
I think ultimately we may want to have an interpreter-specific env PMC that is, by default, an Env PMC, but can be overridden at creation time, and we just disallow "new Px, .Env" calls, or something of that sort.
--
Dan
--------------------------------------"it's like this"------------------- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk