From: Rafael Garcia-Suarez Date: Tue, 14 Mar 2006 17:02:38 +0000 (+0000) Subject: Make usage of :unique emit a deprecation warning. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1108974dc425da181c3fc8be06ee65371f6439d6;p=p5sagit%2Fp5-mst-13.2.git Make usage of :unique emit a deprecation warning. Remove its outdated documentation. p4raw-id: //depot/perl@27498 --- diff --git a/cv.h b/cv.h index e92b326..219686b 100644 --- a/cv.h +++ b/cv.h @@ -136,9 +136,7 @@ Returns the stash of the CV. #define CVf_CLONED 0x0040 /* a clone of one of those */ #define CVf_ANON 0x0080 /* CvGV() can't be trusted */ #define CVf_UNIQUE 0x0100 /* sub is only called once (eg PL_main_cv, - * require, eval). Not to be confused - * with the GVf_UNIQUE flag associated - * with the :unique attribute */ + * require, eval). */ #define CVf_NODEBUG 0x0200 /* no DB::sub indirection for this CV (esp. useful for special XSUBs) */ #define CVf_CONST 0x0400 /* inlinable sub */ diff --git a/pod/perldiag.pod b/pod/perldiag.pod index b1c1594..fa290e3 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -3938,8 +3938,7 @@ instead. =item The 'unique' attribute may only be applied to 'our' variables -(F) Currently this attribute is not supported on C or C -declarations. See L. +(F) This attribute was never supported on C or C declarations. =item This Perl can't reset CRTL environ elements (%s) diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 8b12f98..f1c5381 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -3490,30 +3490,6 @@ from Perl 5.8.0 also via the C module. See L for details, and L, L, and L. -The only currently recognized C attribute is C which -indicates that a single copy of the global is to be used by all -interpreters should the program happen to be running in a -multi-interpreter environment. (The default behaviour would be for -each interpreter to have its own copy of the global.) Examples: - - our @EXPORT : unique = qw(foo); - our %EXPORT_TAGS : unique = (bar => [qw(aa bb cc)]); - our $VERSION : unique = "1.00"; - -Note that this attribute also has the effect of making the global -readonly when the first new interpreter is cloned (for example, -when the first new thread is created). - -Multi-interpreter environments can come to being either through the -fork() emulation on Windows platforms, or by embedding perl in a -multi-threaded application. The C attribute does nothing in -all other environments. - -Warning: the current implementation of this attribute operates on the -typeglob associated with the variable; this means that C -also has the effect of C. This may be -subject to change. - =item pack TEMPLATE,LIST X diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index 3197824..5c44df7 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -844,3 +844,10 @@ EXPECT !=~ should be !~ at - line 8. !=~ should be !~ at - line 9. !=~ should be !~ at - line 10. +######## +# toke.c +our $foo :unique; +use warnings 'deprecated'; +our $bar :unique; +EXPECT +Use of :unique is deprecated at - line 4. diff --git a/toke.c b/toke.c index f256310..545116f 100644 --- a/toke.c +++ b/toke.c @@ -4022,12 +4022,14 @@ Perl_yylex(pTHX) } else { if (len == 6 && strnEQ(s, "unique", len)) { - if (PL_in_my == KEY_our) + if (PL_in_my == KEY_our) { #ifdef USE_ITHREADS GvUNIQUE_on(cGVOPx_gv(yylval.opval)); #else - /*EMPTY*/; /* skip to avoid loading attributes.pm */ + /* skip to avoid loading attributes.pm */ + deprecate(":unique"); #endif + } else Perl_croak(aTHX_ "The 'unique' attribute may only be applied to 'our' variables"); }