Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^2: Why no warnings for 1 in void context?

by tlm (Prior)
on Jul 16, 2005 at 17:50 UTC ( #475487=note: print w/replies, xml ) Need Help??

in reply to Re: Why no warnings for 1 in void context?
in thread Why no warnings for 1 in void context?

Well, also "ignoramus" and "dimwit" (which, BTW, pretty much describe my state right now) sail through without warnings... After some googling, I suspect the special treatment of such strings has something to do with nroff/troff/groff, but I know zilch about these, so I'll have to leave it at that...

the lowliest monk

  • Comment on Re^2: Why no warnings for 1 in void context?

Replies are listed 'Best First'.
Re^3: Why no warnings for 1 in void context?
by jdporter (Canon) on Jul 16, 2005 at 20:49 UTC

    Very good! Yes, it's a little known feature of perl that certain nroff directives are legal in perl, in the sense that they are always recognized, even if not defined. (They will not override or change the meaning of any actual definitions in your code.) The place to begin is in op.c, in function Perl_scalarvoid. Here we learn that any symbol occurring in void context which begins with 'di', 'ds', or 'ig' is given a pass to sail by without warning.

    (In the exact same place, 0 and 1 are defined as non-warning-worthy in void context. merlyn knew that, of course.)

    The code tells us to look in the pink camel [that's Programming Perl 1st ed.], near page 319. This is where two scripts, wrapman and wrapinst, are presented. This is really the best clue to why these nroff directives are special... and what it boils down to is Larry's (clever) attempt to make it easy to document code by making it possible for (some) code to be both legal perl and legal nroff. I think even he would admit that it wasn't terribly successful. But this was in the days before POD.

    No doubt this feature has been exploited in obfu.

      Why not just quote the source?

      // op.c 765 else if (SvPOK(sv)) { /* perl4's way of mixing documentation and code (before the invention of POD) was based a trick to mix nroff and perl code. The trick was built upon these three nroff macros being used in void context. The pink camel has the details in the script wrapman near page 319. */ if (strnEQ(SvPVX(sv), "di", 2) || strnEQ(SvPVX(sv), "ds", 2) || strnEQ(SvPVX(sv), "ig", 2)) useless = 0; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://475487]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2018-03-18 16:35 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (230 votes). Check out past polls.