Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: use fields; # damnit

by adrianh (Chancellor)
on Aug 21, 2004 at 07:57 UTC ( #384767=note: print w/ replies, xml ) Need Help??


in reply to Re: use fields; # damnit
in thread use fields; # damnit

So I guess my question to you (and everyone else) is, are fields really ready for real world usage?

Well, there are certainly people using it out there in the wild.

That said, I don't and won't use them myself for three reasons.

First, there are reasons why pseudo-hashes are being deprecated. Until the non-pseudo fields has been out for a couple of releases I'm not going to use them.

Second, to use them we have to control the base-class. Often I'm coding in places where I don't control the base class. Since I like consistency throughout the code fields aren't that useful to me.

Can I get these benifits today, without the risk of using "experimental" features?

The third reason I don't use them is that I can get the benefit of compile-time field name typo checking (and other benefits too) by using Abigail's inside out objects technique - without having to touch any experimental features.


Comment on Re^2: use fields; # damnit
Re^3: use fields; # damnit
by Aristotle (Chancellor) on Aug 21, 2004 at 15:21 UTC

    First, there are reasons why pseudo-hashes are being deprecated. Until the non-pseudo fields has been out for a couple of releases I'm not going to use them.

    The point is that fields is guaranteed to keep working the way it does. That it uses pseudohashes is an implementation detail you are not supposed to care about.

    Of course, your objection that it requires knowledge about the implementation of the base class is valid and a good reason not to use it anyway.

    Makeshifts last the longest.

      The point is that fields is guaranteed to keep working the way it does. That it uses pseudohashes is an implementation detail you are not supposed to care about.

      Yeah I realise that :-)

      The point I was trying to make was that right now fields are implemented using pseudo-hashes. Since pseudo-hashes have problems that I want to avoid I won't be using fields until they're implemented using restricted hashes (or whatever) and the new release has been out enough for the bugs to have been stomped on.

Re^3: use fields; # damnit
by tphyahoo (Vicar) on Jul 06, 2005 at 10:50 UTC
    Adrianh, I don't understand what you mean by "we have to control the base-class." I thought the fields pragma played well with inheritance. Could you give a concrete example where this would be a problem?

    ps, I just posted a followup to this thread at Should I use Fields, InsideOuts, or Properties?.

      Adrianh, I don't understand what you mean by "we have to control the base-class." I thought the fields pragma played well with inheritance. Could you give a concrete example where this would be a problem?

      The fields pragma only plays well with classes that have also been built with the fields pragma.

      If I want to subclass a class that's based around a blessed hashref or coderef then I'm out of luck.

      Since I often code with classes than I do not control (e.g. classes from CPAN) that are not implemented with pseudohashes I can't use the fields pragma with them.

      Make sense?

      OK, I get it. Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://384767]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (13)
As of 2014-09-02 20:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (29 votes), past polls