Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: RFC: pragma pragmatic

by sundialsvc4 (Abbot)
on Aug 10, 2017 at 01:24 UTC ( #1197129=note: print w/replies, xml ) Need Help??


in reply to Re^2: RFC: pragma pragmatic
in thread RFC: pragma pragmatic

Well, I am of course fully aware of the previous postings, and (in fact) of the technical contexts in which they were made ... (gasp!   down-voters, it is true!), but I suppose that the locus of my concern understands all of that.   (And, before you reflexively down-vote this post, shaddup and hear me out ...)

I consider pragmas such as use strict and use warnings to be completely unrelated(!) to situations such as this, even though the same syntactic-keyword, use, is “used” in both cases.

To my way of thinking, constructs such as use strict and use warnings are nothing more and nothing less than “ways to flip compiler-switches, which are considered only ‘at compile-time.’”   They are strictly applied at compile time, to the limited extent that languages such as Perl possess a concept of “compile time,” and specifically do not influence the run-time behavior of the code.   Therefore, to my way of thinking, only(!!) these things qualify as “lexical.”

Per contra, the features that you describe ... (IMHO!) ... do not.

At the very moment that you, as you say, “make the scope of imported functions from some arbitrary package purely lexical,” or, “limited the scope of imported subroutines/functions to <anything_at_all>,” I would stress that (IMHO) you (of course, whoever you are ...) have just now called upon the language system to impose your own view of things upon the (unknown and unknowable) prerogatives of the original programmer of that “arbitrary” package.

Truth be said (IMHO!), you have just done something that said original programmer not only did not anticipate, but could not have anticipated.   I would argue that you have co-opted that programmer’s intention, which, I would also (respectfully!) argue, is something that you must not do.   Because you can be assured of success only in limited ... and, well-known to you ... cases.   Maybe it is no big deal.   Maybe it is huge.   (And, who’s to know?   It worked for you.   Goody for you.)

Please, please, understand the point-of-view from which I am coming:   unlike most of the apparently-present population of PerlMonks, I am never the original programmer.   The original-programmers quite likely have either been fired, have quit, or have been laid off, or have been sent back to the foreign-countries from whence they came.   To my way of thinking, the things that you describe are not “lexical,” because they are not in fact of such a nature that can be objectively resolved, entirely by the compiler, “at compile time.”   I can’t look at your source code and be certain what it means.   I might potentially have to guess what version of a (highly-volatile, say) CPAN package you might have been considering at the time that you decided, “okay, this works.™”

(Mind you, I am not there to judge you.   After all, why should I care ...?)   But you have imposed upon me an “out-of-band consideration,” of very-large and very-uncertain potential impact, which I am now (very unpleasantly) forced to consider.   Thanks a lot.)

Hence, such matters have become something that is near and dear to my ... career.   To me, your idea introduces into the source-code many side-effects that are difficult if not impossible to discern from any simple reading of the source-code alone.   (Which is all that I ever have to work with.)   Instead, the “proper interpretation” of “what I see in front of my face” is now made dependent upon the inner workings of “an arbitrary package.”   (And, what version of that thing might you have used ...?   Oh, dear.)

I freely grant that my point-of-view might be considered to be “an edge case.”   I have become accustomed to that, also.   But I submit, all-too defensively now, that it is valid.

Replies are listed 'Best First'.
Re^4: RFC: pragma pragmatic
by chromatic (Archbishop) on Aug 10, 2017 at 20:06 UTC
    To my way of thinking

    Your way of thinking is irrelevant, because it's not how Perl works.

    Other people have linked the relevant documentation. I wrote a book and give it away for free. (PragProg link for Modern Perl, 4e or online link to MP 4e).

    If that's too much of a burden for you, /msg me your address and I'll send you a paper copy.

    All of these resources are available. Please stop guessing and take the time to learn of what you speak. You're hurting yourself and you're hurting other people with your wild and uninformed speculation.

      save the postage costs, he won't read it. He doesn't read anything anyone tells him. Worst Nodes
Re^4: RFC: pragma pragmatic
by shmem (Chancellor) on Aug 10, 2017 at 08:47 UTC
    To my way of thinking, constructs such as use strict and use warnings are nothing more and nothing less than “ways to flip compiler-switches, which are considered only ‘at compile-time.’” They are strictly applied at compile time, to the limited extent that languages such as Perl possess a concept of “compile time,” and specifically do not influence the run-time behavior of the code.

    Wrong. The effect of warnings is at runtime. Would you please read just a tiny bit of the perl documentation? Read perlrun. It states:

    -c causes Perl to check the syntax of the program and then exit without executing it.

    So, no runtime with -c .

    #!/usr/bin/perl # line 1 w.pl use warnings; my $a; print $a;
    qwurx [shmem] ~> perl -c w.pl w.pl syntax OK

    No warning.

    qwurx [shmem] ~> perl w.pl Use of uninitialized value $a in print at w.pl line 4.

    Warning at runtime

    As for the rest of your post - it is completely ass-backwards. The "original programmer" of an arbitrary package can never know how and where his package is used. And if I use a package, I am free to use it in a way that suits me, and not the intentions of the "original programmer". I have to regard the intentions of the "original programmer", who instead completely ignores my intentions, and there is no way I can impose something upon them.

    To me, your idea introduces into the source-code many side-effects that are difficult if not impossible to discern from any simple reading of the source-code alone.

    This is plain FUD. Which side-effects? You can't tell because maybe you are unable to read the code, and too self-impressed by your imagined vast expertise, that you deem it unnecessary to read the documentation. Read perlpragma. Read perlrun, perlsub, perlmod. Then you can actually understand which side effects this pragmatic pragma has. And name them, substantiating your claim.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re^4: RFC: pragma pragmatic
by Your Mother (Bishop) on Aug 10, 2017 at 01:34 UTC
    I am never the original programmer

    You have made us painfully, relentlessly aware of this fact. Perhaps it might add pause to the frequent offerings of expertise and advice on precisely the matters which bring programmers here.

      A reply falls below the community's threshold of quality. You may see it by logging in.
Re^4: RFC: pragma pragmatic
by Anonymous Monk on Aug 11, 2017 at 10:19 UTC
    So "I'm here to keep talking crap even though I have no idea what I'm doing, and I'll just ignore whatever anyone else says?" - You're a broke record Mike.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2019-07-17 22:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?