Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: DWIM Part Nineteen: Unary Operators in Void Context

by clemburg (Curate)
on Aug 21, 2001 at 14:31 UTC ( [id://106503]=note: print w/replies, xml ) Need Help??


in reply to DWIM Part Nineteen: Unary Operators in Void Context

The second question relates a bit more to the title... After all, "lc $foo;" certainly doesn't DWIM now... and I'm wondering if it's unreasonable to expect Perl to work this way. Certainly, I've been known to want crazy things from Perl before... is this an exception, or just more uneducated rambling?

In a language like Perl, where you can define your own subroutines and even override the built-in functions (see Camel III, Chapter 11, Overriding Built-in Functions, p. 306), and do that even so that other modules can't detect it, I see really no reason for you to expect that the perl that *all we others* get should do what *you* want.

Seriously, why don't you just implement the behaviour that you want with your own subroutine (or overridden built-in). Don't expect others to agree to your choices. Make your choices and implement what you need. (If you are really tempted, join the Perl6 effort and try to get your suggestions accepted.)

To quote Alan Perlis again: "Invent and fit - have fits and reinvent."

Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com

  • Comment on Re: DWIM Part Nineteen: Unary Operators in Void Context

Replies are listed 'Best First'.
die if $Redefine > 0.01 && $Document < 2*$Normal
by dragonchild (Archbishop) on Aug 21, 2001 at 16:15 UTC
    I'm all for customizing your Perl interpreter, either by modules or rearranging the internals. Buuuutt.....

    DOCUMENT WHAT YOU DID

    If you ever expect someone to understand that uc $foo; actually is calling your uc and not the standard one, you have to write that down. And, make sure you write it down somewhere really prominent. Like, at the beginning of all your scripts. Call your module redefining uc something like "Redefinitions::Unary::uc". Make sure it's obvious what you're doing. And, in that module, make sure you explain exactly how you did it, so I can figure it out.

    Or, if you're modifying the interpreter, make sure the shebang line reflects that. Never assume I know more than a really stupid monkey. :)

    ------
    /me wants to be the brightest bulb in the chandelier!

    Vote paco for President!

Re: Re: DWIM Part Nineteen: Unary Operators in Void Context
by mr_mischief (Monsignor) on Aug 21, 2001 at 19:02 UTC
    Seriously, why don't you just implement the behaviour that you want with your own subroutine (or overridden built-in). Don't expect others to agree to your choices. Make your choices and implement what you need. (If you are really tempted, join the Perl6 effort and try to get your suggestions accepted.)

    One reason for having p5p as an public mailing list is so that suggestions like this can be made there. The other is reason, of course, is because a good bugfix could come from unknown persons.

    I, personally, think the idea has some merit, but I'd be afraid to hurt backwards compatibility (although I can't imagine what current program depends on noop code). I think this would be useful as a module on CPAN, but it would be more useful as a core pragma.

    Without asking the opinions of others and seeing who agrees, it is sometimes difficult to determine how useful other people may find a bit of code. I know I would hate to code and recode the same working piece of software to get it ready for public release, only to find out it wasn't wanted. It's not such a matter of expecting others to agree as asking if others do agree.

    Personally, I think many of Perl's builtins could benefit from such a check. It would probably be a little too slow and too different from what people know to be a default in a future release of 5. IMHO, it's a great candidate for a pragma in 5 or 6, and possibly a good candidate for the default in 6.

    Chris

    Update: Corrected a couple of tpyos.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-25 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found