Wally Hartshorn has asked for the wisdom of the Perl Monks concerning the following question:

I'm just starting to get my feet wet in OOP and am busily reading Damian Conway's "Object Oriented Perl". In chapter 4, he discusses pseudo-hashes and fields.pm. The book was written around the time of Perl 5.005, and he emphasizes that pseudo-hashes are experimental.

Searching through the messages here on PerlMonks, it appears that pseudo-hashes are going to go away, but that the "use fields" pragma will remain. Correct?

If this is the case, what are most OOP programmers doing?? Should I generally create objects as regular hashes, or should I be using the "use fields" pragma? I'm beginning to suspect that "use fields" is an idea whose time still hasn't come, but I'm not sure whether I would be causing myself any problems by using it.

Any guidance would be appreciated!

Wally Hartshorn

Edit: closed BOLD tag. larsen

Replies are listed 'Best First'.
Re: Hashes vs "use fields" for an Object?
by chromatic (Archbishop) on Sep 16, 2002 at 18:43 UTC

    Pseudo-hashes have been deprecated in Perl 5.8.0 and will be removed from 5.10.0. They will also not appear in Perl 6.

    As you suspected, the fields pragma will be rewritten to remove the pseudo-hashes parts. There've been a couple of discussions on p5p about the best way to do this.

    If using fields makes you more productive, feel free to use it. I rarely need it, but that has more to do with the kind s of problems I'm trying to solve than any particular distaste or fear of the pragma.

Re: Hashes vs "use fields" for an Object?
by sauoq (Abbot) on Sep 16, 2002 at 18:58 UTC

    I don't use the fields pragma or pseudo-hashes at all. I did play with them for a while but never used them in a serious project. My suggestion is not to use them, at least, not with Perl5.

    I don't think this stuff has been... erm... hashed out in Perl6 yet. I'd wait to worry about doing things the Perl6 way until the Perl6 way for those things has been decided and implemented. Part of the Perl6 promise is that you can continue to write Perl5 now without programming yourself into a corner.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: Hashes vs "use fields" for an Object?
by BrowserUk (Patriarch) on Sep 16, 2002 at 18:05 UTC