Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

Free up := for bind

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


nick at ccl4

Nov 4, 2009, 3:50 AM

Post #1 of 2 (52 views)
Permalink
Free up := for bind

I made the appended commit.

It strikes me that if we we deprecate := now, then we have the option of using
it as a bind operator in the future. If we don't deprecate it now, then we
have to wait for it to become deprecated before we can re-use it. At which
point likely we'd opt to use something less good.

Nicholas Clark

----- Forwarded message from Nicholas Clark <nick[at]ccl4.org> -----

Envelope-to: nick[at]ccl4.org
Delivery-date: Wed, 04 Nov 2009 11:39:54 +0000
Mailing-List: contact perl5-changes-help[at]perl.org; run by ezmlm
Mail-Followup-To: perl5-porters[at]perl.org
Delivered-To: mailing list perl5-changes[at]perl.org
Delivered-To: perl5-changes[at]perl.org
From: "Nicholas Clark" <nick[at]ccl4.org>
To: perl5-changes[at]perl.org
Subject: [perl.git] branch blead, updated. v5.11.1-108-gd83f38d
Reply-To: "Perl5 Porters" <perl5-porters[at]perl.org>
Date: Wed, 04 Nov 2009 12:39:28 +0100

In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/d83f38d8facaed626f27ae5d9f0f66709664dc5e?hp=2b6765935f5ee68d8093e686b8e292ad5de5a898>

- Log -----------------------------------------------------------------
commit d83f38d8facaed626f27ae5d9f0f66709664dc5e
Author: Nicholas Clark <nick[at]ccl4.org>
Date: Wed Nov 4 11:33:12 2009 +0000

Deprecate use of := to mean an empty attribute list in my $pi := 4;

An accident of Perl's parser meant that my $pi := 4; was parsed as an empty
attribute list. Empty attribute lists are ignored, hence the above is
equivalent to my $pi = 4; However, the fact that it is currently valid syntax
means that := cannot be used as new token, without silently changing the
meaning of existing code.

Hence it is now deprecated, so that it can subsequently be removed, allowing
the possibility of := to be used as a new token with new semantics.
-----------------------------------------------------------------------

Summary of changes:
dist/B-Deparse/t/deparse.t | 14 +++++++++-
pod/perl5112delta.pod | 23 +++++++++++++++--
t/lib/warnings/toke | 59 ++++++++++++++++++++++++++++++++++++++++++++
toke.c | 3 ++
4 files changed, 95 insertions(+), 4 deletions(-)

diff --git a/dist/B-Deparse/t/deparse.t b/dist/B-Deparse/t/deparse.t
index c9c92f9..12879fc 100644
--- a/dist/B-Deparse/t/deparse.t
+++ b/dist/B-Deparse/t/deparse.t
@@ -17,7 +17,7 @@ BEGIN {
require feature;
feature->import(':5.10');
}
-use Test::More tests => 78;
+use Test::More tests => 81;
use Config ();

use B::Deparse;
@@ -591,3 +591,15 @@ foreach (0..3) {
print ++$x, "\n";
}
}
+####
+my $pi = 4;
+####
+no warnings;
+my $pi := 4;
+>>>>
+no warnings;
+my $pi = 4;
+####
+my $pi : = 4;
+>>>>
+my $pi = 4;
diff --git a/pod/perl5112delta.pod b/pod/perl5112delta.pod
index b2a6522..aea02f3 100644
--- a/pod/perl5112delta.pod
+++ b/pod/perl5112delta.pod
@@ -15,11 +15,28 @@ XXX Unlikely to need this section.

=head1 Incompatible Changes

-XXX For a release on a stable branch, this section aspires to be:
+=head2 Use of C<:=> to mean an empty attribute list is now deprecated.

- There are no changes intentionally incompatible with 5.XXX.XXX. If any
- exist, they are bugs and reports are welcome.
+An accident of Perl's parser means that these constructions are all equivalent:

+ my $pi := 4;
+ my $pi : = 4;
+ my $pi : = 4;
+
+with the C<:> being treated as the start of an attribute list, which ends
+before the C<=>. As whitespace is not significant here, all are parsed as an
+empty attribute list, hence all the above are equivalent to, and better written
+as
+
+ my $pi = 4;
+
+because no attribute processing is done for an empty list.
+
+As is, this means that C<:=> cannot be used as a new token, without silently
+changing the meaning of existing code. Hence that particular form is now
+deprecated, and will become a syntax error. If it is absolutely necessary to
+have empty attribute lists (for example, because of a code generator) the
+avoid the warning by adding a space before the C<=>.

=head1 Core Enhancements

diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke
index a7ef0f8..2236442 100644
--- a/t/lib/warnings/toke
+++ b/t/lib/warnings/toke
@@ -901,3 +901,62 @@ my $bar = qr/^foo${\}n/;
EXPECT
Possible unintended interpolation of $\ in regex at - line 3.
Possible unintended interpolation of $\ in regex at - line 5.
+########
+# toke.c
+use feature 'state';
+# This one is fine as an empty attribute list
+my $holy_Einstein : = '';
+# This one is deprecated
+my $krunch := 4;
+our $FWISK_FWISK_FWIZZACH_FWACH_ZACHITTY_ZICH_SHAZZATZ_FWISK := '';
+state $thump := 'Trumpets';
+# Lather rinse repeat in my usual obsessive style
+my @holy_perfect_pitch : = ();
+my @zok := ();
+our @GUKGUK := ();
+# state @widget_mark := ();
+my %holy_seditives : = ();
+my %bang := ();
+our %GIGAZING := ();
+# state %hex := ();
+no warnings 'deprecated';
+my $holy_giveaways : = '';
+my $eee_yow := [];
+our $TWOYYOYYOING_THUK_UGH := 1 == 1;
+state $octothorn := 'Tinky Winky';
+my @holy_Taj_Mahal : = ();
+my @touche := ();
+our @PLAK_DAK_THUK_FRIT := ();
+# state @hash_mark := ();
+my %holy_priceless_collection_of_Etruscan_snoods : = ();
+my %wham_eth := ();
+our %THWUK := ();
+# state %octalthorpe := ();
+use warnings;
+my $holy_sewer_pipe : = '';
+my $thunk := undef;
+our $BLIT := time;
+state $crunch := 'Laa Laa';
+my @glurpp := ();
+my @holy_harem : = ();
+our @FABADAP := ();
+# state @square := ();
+my %holy_pin_cushions : = ();
+my %swoosh := ();
+our %RRRRR := ();
+# state %scratchmark := ();
+EXPECT
+Use of := for an empty attribute list is deprecated at - line 6.
+Use of := for an empty attribute list is deprecated at - line 7.
+Use of := for an empty attribute list is deprecated at - line 8.
+Use of := for an empty attribute list is deprecated at - line 11.
+Use of := for an empty attribute list is deprecated at - line 12.
+Use of := for an empty attribute list is deprecated at - line 15.
+Use of := for an empty attribute list is deprecated at - line 16.
+Use of := for an empty attribute list is deprecated at - line 33.
+Use of := for an empty attribute list is deprecated at - line 34.
+Use of := for an empty attribute list is deprecated at - line 35.
+Use of := for an empty attribute list is deprecated at - line 36.
+Use of := for an empty attribute list is deprecated at - line 38.
+Use of := for an empty attribute list is deprecated at - line 41.
+Use of := for an empty attribute list is deprecated at - line 42.
diff --git a/toke.c b/toke.c
index bd20434..fa78415 100644
--- a/toke.c
+++ b/toke.c
@@ -4298,6 +4298,9 @@ Perl_yylex(pTHX)
if (!PL_in_my || PL_lex_state != LEX_NORMAL)
break;
PL_bufptr = s; /* update in case we back off */
+ if (*s == '=') {
+ deprecate(":= for an empty attribute list");
+ }
goto grabattrs;
case XATTRBLOCK:
PL_expect = XBLOCK;

--
Perl5 Master Repository

----- End forwarded message -----


demerphq at gmail

Nov 4, 2009, 4:48 AM

Post #2 of 2 (40 views)
Permalink
Re: Free up := for bind [In reply to]

2009/11/4 Nicholas Clark <nick[at]ccl4.org>:
> I made the appended commit.
>
> It strikes me that if we we deprecate := now, then we have the option of using
> it as a bind operator in the future. If we don't deprecate it now, then we
> have to wait for it to become deprecated before we can re-use it. At which
> point likely we'd opt to use something less good.
>
The pascal mob will be most displeased... Luckily there is only 4 of them. :-)

Yves


--
perl -Mre=debug -e "/just|another|perl|hacker/"

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.