|Problems? Is your data what you think it is?|
RE: RE: RE: Win32::MemoryInfoby tye (Cardinal)
|on Aug 31, 2000 at 19:24 UTC||Need Help??|
I'll start from the beginning because I don't think I'll make much sense otherwise.
Okay, the basic idea is that, with so many values being returned (3 is usually too many in my book), remembering the exact order of the values is problematic. Also, if you are returning a whole list of things, it'd be nice to design the interface so it can evolve in an intelligent manner.
So, just like when you have lots of parameters, it is nice to "name" them (func(This=>"that",Count=>2)), you can return "named" values by returning a hash. I try to avoid returning hashes as lists so let's return a reference to a hash.
One of the nice things about named parameters is that you can leave out any parameters that you aren't interested in. So let's allow the user the same option here. If they only want page file information in megabytes, they can write:
The "MB" parameter is optional and we can detect it due to it being different from any of the field names. If you think you may further extend the interface in the future, you might want to make this distinction clearer and allow for extra arguments by having the field names passed as an array reference:
but I don't think that is warranted in this case.
If the user wants all or most of the items, then they use it like this:
This is particularly handy for add-hoc queries in the Perl debugger:
And Perl makes this easy to code as well:
- tye (but my friends call me "Tye")