Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: When -w and use strict aren't enough...

by jonadab (Parson)
on Nov 04, 2003 at 18:26 UTC ( #304501=note: print w/replies, xml ) Need Help??


in reply to Re^3: When -w and use strict aren't enough...
in thread When -w and use strict aren't enough...

However, forcing everybody to add declarations for any runtime-generated subroutines strikes me as both un-perlish and extremely unlikely to happen.

There's no reason it couldn't be a pragma. Why stop with use strict; use warnings; use diagnostics;  use Taint; when you can add use predeclaredsubs; use predefinedsubs; and maybe no earlyreturns; no typeglobs; and possibly use bondage; use discipline; use pain; use Inline::Pascal;


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/

Replies are listed 'Best First'.
Re^2: When -w and use strict aren't enough...
by adrianh (Chancellor) on Nov 05, 2003 at 11:57 UTC

    I'm not saying that it cannot be done, just that it might be of limited utility since it would depend on code being written (or re-written) in a way that support the pragma.

    The pain of writing code to support the pragma may well be more than the pain saved by the compile time checking.

      The pain of writing code to support the pragma may well be more than the pain saved by the compile time checking.

      Oh, I would agree with that. I personally would not use said pragmas. Then again, I don't even always use strict (though I do use it in include files and in large, complex programs, and I would certainly use it in a module). However, there are some people whose mindset just tends to prefer a lot of strict rules. People who prefer Pascal over BASIC, if you can imagine. People who use strict and warnings even for one-liners and obfuscations. Those people would probably appreciate the ability to force all subs to be predefined, for example. Of course, if they really want it, one of them would have to step forward and implement it, but what I was saying is that if it's done as a pragma, we needn't object, because all you have to do to be free of it is not bother to use the pragma.

      That said, I'm not sure what the bondage pragma would do. Perhaps require all control structures to have a single entry and a single exit point (so, no next or last permitted, to say nothing of early returns), I suppose. I imagine the discipline pragma might prohibit subroutines from accessing any variables not lexically scoped within the subroutine, so that any external variables would have to be passed in as arguments to be used, and if they were to be changed the results would have to be passed back out as a return value and applied by the calling code. I'm not sure what use pain would do, exactly, but I suppose it would be even worse than discipline.

      The really neat thing about these pragmas, if they existed, would be that we could say, "C gives you enough rope to hang yourself, but Perl gives you enough rope to tie yourself up."


      $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
        However, there are some people whose mindset just tends to prefer a lot of strict rules.

        Ya! That's me!

        People who prefer Pascal over BASIC, if you can imagine.

        *waves hands* I even started in BASIC, back in, um, Middle School? But once I got to college, and Pascal and Scheme were the order of the day, I never looked back. Iím even trying to convince a co-worker to give up Visual Basic for C#, just so we can re-write, convert, and cleanup the vast stock of VB code in our environment.

        People who use strict and warnings even for one-liners and obfuscations.

        Well, maybe not that much. OTOH, I don't write obfuscations; it's enough of a struggle to me to write clear code.

        Those people would probably appreciate the ability to force all subs to be predefined, for example.

        Actually, no. I tend to think that would make the code less clear, not more. If I recall alright, it's mostly done in other languages due to compiler needs more than anything. I'd much rather have something where subs get "auto-rendered" into POD, so it's easier to write comments on subroutines (if you so wish); I think that would be much more useful, in terms of what someone reading your code would need, than any pre-declaration concept.

        *ponders finding/writing such code..."Pod::Auto, anyone?"*

        The really neat thing about these pragmas, if they existed, would be that we could say, "C gives you enough rope to hang yourself, but Perl gives you enough rope to tie yourself up."

        HEH. *evil grin*

        ----Asim, known to some as Woodrow.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2021-06-13 21:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (58 votes). Check out past polls.

    Notices?