in reply to Real world uses of the tie function.

Hi.

Just thought that you (hopefully your teacher is already)should be aware there are some subtle bugs with the tie implementation.

Tie's FETCH called twice?
warning: tied vars may evaluate twice in logical expressions
warning: bug with tie (5.6.1)

But you ask why anyone would want to write a Tie? Well, outside of the many ties on CPAN and their usefullnes I would say the answer would in general be one of two reasons:

A) A programmer has a class whose behaviour conceptually is equivelent (or a superset) of the behaviour of a base type. So they decide to provide a Tie interface so that their users can stay within a familiar paradigm. Tie::IniFile

B) A programmer wants to intercept accesses to a base type to add some kind of extra processing. Tie::Refhash

C) The programmer wants to do something funky and unexpected Tie::Cycle

Yves / DeMerphq
---
Writing a good benchmark isnt as easy as it might look.

  • Comment on Re: Real world uses of the tie function.

Replies are listed 'Best First'.
Re: Re: Real world uses of the tie function.
by mojotoad (Monsignor) on Apr 17, 2002 at 19:44 UTC
    In addition to those problems, there's also my very first post here on PM. It was about a problem with tied hashes...to which I never really got a satisfactory response: Whither the truth of a tied hash?

    In short, a populated hash will respond truthfully in a scalar context:

    if (%h) { ...do something... }
    whereas a populated tied hash will do no such thing. It will always evaluate to false.

    So much for drop-in hash sniffers.

    Matt