Anyway, as I said, I think I may be missing some point you're making. If you'd care to clarify, I'd be happy to discuss further.

Hi

My point is that empty list , the parens , are not being lost, they never existed, and they can't be passed around, because foo() is the same as foo((),(),())

Its a special case in the parser that causes use YADA (); to be treated as BEGIN{require YADA;} with no call to import.

B::Deparse peeks at the optree to decide when to print use YADA();

This is the parsing parts of a "use" statement

https://perl5.git.perl.org/perl.git/blob/HEAD:/perly.y#l349

349 | USE startsub 350 { CvSPECIAL_on(PL_compcv); /* It's a BEGI +N {} */ } 351 BAREWORD BAREWORD optlistexpr ';' 352 { 353 SvREFCNT_inc_simple_void(PL_compcv); 354 utilize($1, $2, $4, $5, $6); 355 parser->parsed_sub = 1; 356 $$ = NULL; 357 }

toke.c s_tokenize_use

Related loading module parts
op.c Perl_vload_module
op.c Perl_utilize

6307 /* Fake up an import/unimport */ 6308 if (arg && arg->op_type == OP_STUB) { 6309 imop = arg; /* no import on explicit () */ 6310 }

http://perldoc.perl.org/perlapi.html#load_module

If you look inside sub begin_is_use inside B::Deparse ( L571 and L611 ) you can see what it goes through to decide if its dealing with a use statement with or without empty parens, its looking at the optree, because of the fake begin sub in utilize

As you can see, the empty parens simply never existed

Similar to my post above, but a weaker demonstration, if you look at perlrun there are two switches for loading modules

$ perl -mopen -e 1 $ perl -Mopen -e 1 open: needs explicit list of PerlIO layers at -e line 0. BEGIN failed--compilation aborted.

Passing no arguments (like empty parens) doesn't work with either version import gets called , because in the end its a simple use statement

$ perl -Mopen= -e 1 open: needs explicit list of PerlIO layers at -e line 0. BEGIN failed--compilation aborted. $ perl -mopen= -e 1 open: needs explicit list of PerlIO layers at -e line 0. BEGIN failed--compilation aborted.

In reply to Re^3: 'if' pragma and modules with an empty import list by beech
in thread 'if' pragma and modules with an empty import list by kcott

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.