[comp.lang.perl] Perl & cpp

arielf@taux01.nsc.com (Ariel Faigon) (04/08/91)

The -P (preprocess perl using cpp) perl option is seldom used.
I wonder what Larry had in mind when he introduced it.
Was it that "creeping featurism" ideal ;-)

Anyway, to be more productive:
-P alone is almost useless. It would have been more useful
if you could add -Dxxx and -Uxxx to it.
-D and -U are already used by perl, but -D has the form
-D<number>, and -U stands alone (unless ou use switch clustering...)
while the respective cpp options always come with some immediately
following identifier.

Maybe -P could be more useful, with -D<identifier>[=...] and
-U<identifier> supported (passed to cpp).

But wait ! don't do it ;-)

Personally, I think that since -Dxxx is used for conditional
compilation, and since perl is interpreted (you can decide
what code to interpret at run-time) - The cpp preprocessing
is really redundant. Unfortunately, it has to be kept for
backward compatibility (has anyone used it ? what for ?).

I guess you should treat this posting merely as material for thought.
Thanks again Larry, for a wonderful tool.

-- 
Ariel Faigon, CTP group, NSTA
National Semiconductor (Israel)
6 Maskit st.  P.O.B. 3007, Herzlia 46104, Israel   Tel. (972)52-522312
arielf@taux01.nsc.com   @{hplabs,pyramid,sun,decwrl} 34 48 E / 32 10 N

evans@decvax.DEC.COM (Marc Evans) (04/09/91)

In article <5685@taux01.nsc.com>, arielf@taux01.nsc.com (Ariel Faigon) writes:
|> The -P (preprocess perl using cpp) perl option is seldom used.
|> I wonder what Larry had in mind when he introduced it.
|> Was it that "creeping featurism" ideal ;-)

Really? I use it in a large number of the perl scripts I have...

|> [...]
|> (has anyone used it ? what for ?).

Probably the most common way that I use it is:

	# include "getopts.pl"

or something simular. Even #defines are handy for macros that expand into perl
code, as oposed to using perl functions or eval. I use #define in simular cases
as where I would in regular C or C++ programming.

Yes, it would have been more useful to have a -Dfoo[=bar] and -Ufoo ability,
but there are ways to deal with that. Judicious use of #if* in an appropriate
*commonly* included file has served its purpose for my needs.

- Marc

-- 
===========================================================================
Marc Evans - WB1GRH - evans@decvax.DEC.COM  | Synergytics     (603)635-8876
      Unix and X Software Consultant        | 21 Hinds Ln, Pelham, NH 03076
===========================================================================