summaryrefslogtreecommitdiff
path: root/perly.h
diff options
context:
space:
mode:
authorDavid Golden <dagolden@cpan.org>2009-10-06 06:48:48 -0400
committerDavid Golden <dagolden@cpan.org>2009-10-06 12:41:09 -0400
commit6fa4d285bff5644bebb95aff09143322042282cc (patch)
tree3e353ca1e3a17967f6dd473bcb49a7269c880355 /perly.h
parentcc4c9faad0767bbb62e32c96638b5ce02dde234e (diff)
downloadperl-6fa4d285bff5644bebb95aff09143322042282cc.tar.gz
Add 'package NAME VERSION' syntax
This patch adds support for setting the $VERSION of a namespace when the namespace is declared with 'package'. It eliminates the need for 'our $VERSION = ...' and similar constructs. E.g. package Foo::Bar 1.23; # $Foo::Bar::VERSION == 1.23 There are several advantages to this: * VERSION is parsed in *exactly* the same way as 'use NAME VERSION' * $VERSION is set at compile time * Eliminates '$VERSION = ...' and 'eval $VERSION' clutter * As it requires VERSION to be a numeric literal or v-string literal, it can be statically parsed by toolchain modules without 'eval' the way MM->parse_version does for '$VERSION = ...' * Alpha versions with underscores do not need to be quoted; static parsing will preserve the underscore, but during compilation, Perl will remove underscores as it does for all numeric literals During development of this, there was discussion on #corehackers and elsewhere that this should also allow other metadata to be set such as "status" (stable/alpha) or "author/authority". On reflection, those metadata are not very well defined yet and likely should never be encoded into Perl core parsing so they can be freely changed in the future. (They could perhaps be achieved via a comment on the same line as 'package NAME VERSION'.) Version numbers, however, already have a very specific definition and use defined in the core through 'use NAME VERSION'. This patch merely provides appropriate symmetry for setting $VERSION with the exact same parsing and semantics as 'use'. It does not break old code with only 'package NAME', but code that uses 'package NAME VERSION' will need to be restricted to perl 5.11.X. This is analogous to the change to open() from two-args to three-args. Users requiring the latest Perl will benefit, and perhaps N years from now it will become standard practice when Perl 5.12 is targeted the way that 5.6 is today. The patch does not prevent 'package NAME VERSION' from being used multiple times for the same package with different version numbers, but nothing prevents $VERSION from being modified arbitrarily at runtime, either, so I see no urgen reason to add limitations or warnings so long as Perl uses a global $VERSION variable for package version numbers. I am posting this patch to the p5p list for discussion and review. If there seems to be general assent (or lack of dissent), I will go ahead and commit the patch to blead.
Diffstat (limited to 'perly.h')
-rw-r--r--perly.h42
1 files changed, 18 insertions, 24 deletions
diff --git a/perly.h b/perly.h
index a8c7f042dd..802da29804 100644
--- a/perly.h
+++ b/perly.h
@@ -1,24 +1,25 @@
#ifdef PERL_CORE
-
-/* A Bison parser, made by GNU Bison 2.4.1. */
+/* A Bison parser, made by GNU Bison 2.3. */
/* Skeleton interface for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
-
- This program is free software: you can redistribute it and/or modify
+
+ This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -29,11 +30,10 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
-
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
@@ -111,7 +111,6 @@
PEG = 326
};
#endif
-
/* Tokens. */
#define WORD 258
#define METHOD 259
@@ -185,13 +184,11 @@
+
#endif /* PERL_CORE */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
-
-/* Line 1676 of yacc.c */
-
I32 ival; /* __DEFAULT__ (marker for regen_perly.pl;
must always be 1st union member) */
char *pval;
@@ -207,16 +204,13 @@ typedef union YYSTYPE
#ifdef PERL_MAD
TOKEN* tkval;
#endif
-
-
-
-/* Line 1676 of yacc.c */
-} YYSTYPE;
-# define YYSTYPE_IS_TRIVIAL 1
+}
+/* Line 1489 of yacc.c. */
+ YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
#endif
-