in reply to Tied variables and functions for them

Neat idea, japhy! However, I do have a design question.

I always thought that the idea of tie-ing was to allow for coders to override the non-function accesses to the basic datatypes like array or hash. This way, neat things happen, but you do your normal stuff like $foo3 or $bar{baz}. I guess that I don't really understand why you would want to add another function to the standard datatypes. My thought would be that you should rethink your design in terms of a standard object instead of a tied object...

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

  • Comment on Re: Tied variables and functions for them

Replies are listed 'Best First'.
Re: Re: Tied variables and functions for them
by davorg (Chancellor) on Oct 03, 2001 at 17:31 UTC

    I disagree. Tied variables are a great way to create objects that look and feel like standard Perl variables but that change their behaviours in interesting and useful ways. It's true that most of the time you'll want people to use the "traditional" interfaces, but there will be a small number of cases where the things you want to do fall outside of that interface. I don't see that as an argument for throwing away the simpler interface completely.

    Did you see my recent article at perl.com about tied hashes? There's an example in there of a hash with a fixed set of keys. When you tie the hash, you pass it a list of the valid keys. Most of the time you can then use the tied object as a normal hash. It's possible, however, that you might want to change the set of valid keys at some point in the application. There's no way to achieve that with the hash interface so you need to invent new object methods (note: Tie::Hash:FixedKeys doesn't do this yet, but I've been thinking of adding it). Most people will never need to use these functions, so I really don't want to make it harder for them to use the object by recasting it as a more traditional object class.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you don't talk about Perl club."