Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: How to prevent references from stringifying?

by xmath (Hermit)
on Oct 04, 2004 at 07:49 UTC ( #396143=note: print w/ replies, xml ) Need Help??


in reply to Re^2: How to prevent references from stringifying?
in thread How to prevent references from stringifying?

Actually, PL_hints is just used at compile-time, not at runtime. But using (PL_curcop->op_private & HINT_STRICT_STRINGIFY) instead should work.

UPDATE: Oh, and a minor note: Perl_warner needs an additional argument that indicates the warning category, like:

if ((PL_curcop->op_private & HINT_STRICT_STRINGIFY) && ckWARN(WARN_MISC)) Perl_warner(aTHX_ packWARN(WARN_MISC), "Stringification of reference disallowed");
or alternatively you could omit the check and use Perl_warn which takes no such argument.


Comment on Re^3: How to prevent references from stringifying?
Select or Download Code
Re^4: How to prevent references from stringifying?
by tachyon (Chancellor) on Oct 04, 2004 at 12:49 UTC

    I did say it was untested :-) I only do enough internals to get my XS to run and admit to a rather cursory examination of the source. I do think the warner syntax is valid though (at least on 5.6.2)

    $ grep Perl_warner op.c ./op.c: Perl_warner(aTHX_ WARN_SYNTAX, "Found = in conditional, should + be =="); ./op.c: Perl_warner(aTHX_ WARN_VOID, "Useless use of %s in void contex +t", useless); ./op.c: Perl_warner(aTHX_ WARN_BAREWORD, "Bareword found in conditiona +l"); ./op.c: Perl_warner(aTHX_ WARN_VOID, "Too late to run CHECK block"); ./op.c: Perl_warner(aTHX_ WARN_VOID, "Too late to run INIT block"); ./op.c: Perl_warner(aTHX_ WARN_REDEFINE, "Subroutine %s redefined",nam +e); ./op.c: Perl_warner(aTHX_ WARN_VOID, "Too late to run CHECK block"); ./op.c: Perl_warner(aTHX_ WARN_VOID, "Too late to run INIT block");
      Oops, I must have misread it as Perl_warner(aTHX_ "...") when I wrote the reply.

      As for packWARN, perl 5.8 uses those while 5.6 didn't, hence you're not seeing them in your 5.6.2 source tree.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2015-07-06 03:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (69 votes), past polls