Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^4: use base 'XYZ' and exporting

by ihb (Deacon)
on May 30, 2005 at 00:33 UTC ( [id://461618]=note: print w/replies, xml ) Need Help??


in reply to Re^3: use base 'XYZ' and exporting
in thread use base 'XYZ' and exporting

OK, so forget uplevel and just reimplement what base actually does.

How's that for a contradition of the spirit your main argument for using it? :-) (Having one source for every piece of information.) When base changes, it won't be a base equivalent with just an add-on.

It's a pity base.pm didn't do it right from the start. If you're going to act like "use" then you should do it properly.

People disagree with that "right" behaviour is, but base doesn't pretended to act like use. It can be used for any class, not just classes loaded with use. It's a module to setup inheritance at compile-time (which was important for fields).

This breaks the rule of having 1 source for every piece of information and leads to subtle errors.

You'll likely have to mention the class again, if you plan to use it in the code below of where you load it. (Update: Err, was about base classes, and you'll likely not name the base class again in the current package (but probably someplace else).) If you're hardcore about this, and you'll have to be if you implement a module like this and uses it, you shouldn't use hardcoded class names either. You should use $theclass = The::Class::; or something equivalent and use the variable instead, in case you need to change the class. But OAOO isn't about mentioning everything once. It's about expressing relations once. There's semantic abstraction and there's syntactic abstraction. I'm not saying that you don't agree with me on that, I'm merely clarifying. This is a both semantic and syntactic abstraction, but I'm trying to say that there is a limit on what is realistic in real life.

In theory I agree with you. I like it the same way I like base's abstraction of loading and @ISA assignment -- I probably should've said that clearer in my reply. I like both semantic and syntactic abstraction. I'm a complete OAOO idiot. But in real life I disagree about this particular example. That's why I said "... what good it really does" (emphasis added). With this you save one occurance of the class name but you likely have at least one more occurance and already have a much harder sync problem; in comparision this is nothing and will probably be taken care of rather automatically. The cost is to confuse the maintenance people and create another hardly needed dependancy.

If this was a patch to base or if it was a standard module it'd be another issue...

ihb

See perltoc if you don't know which perldoc to read!

Replies are listed 'Best First'.
Re^5: use base 'XYZ' and exporting
by fergal (Chaplain) on May 30, 2005 at 10:14 UTC

    If I was really serious about doing this, I'd be patching base (so that's it's not hardwired to caller(0)) and creating a new module. The new module is because you can't go making base call import() all of a sudden.

    The point of my original post was really about the interface and how with some fiddling it can support everything. Whatever preferences people might have for defaults, I'd argue that not supporting all options (when supporting them is essentially zero cost) is definitely not the right thing.

    In this case I'm stuck with the current base.pm, so OAOO can't work, something's got to give. If I must break OAOO then I think it's better to break it OAOO :) I don't think I've ever use a base class's name in the body of a module, if I did I was probably doing something very naughty and OAOO would be the least of my worries.

    Anyway, it looks like we're only arguing about degrees here rather than principles.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2024-04-25 11:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found