Front page | perl.perl5.porters |
Postings from June 2009
Re: 5.12 release/roadmap?
Thread Previous
|
Thread Next
From:
H.Merijn Brand
Date:
June 2, 2009 03:39
Subject:
Re: 5.12 release/roadmap?
Message ID:
20090602123919.1a3aa561@pc09.procura.nl
On Tue, 2 Jun 2009 12:13:31 +0200, "H.Merijn Brand"
<h.m.brand@xs4all.nl> wrote:
> On Tue, 2 Jun 2009 10:50:09 +0100, Nicholas Clark <nick@ccl4.org> wrote:
>
> > On Tue, Jun 02, 2009 at 09:18:27AM +0200, H.Merijn Brand wrote:
> > > On Mon, 01 Jun 2009 18:11:39 +1000, Paul Fenwick
> > > <pjf@perltraining.com.au> wrote:
> > >
> > > > Most importantly for me, I'd love for "use 5.12" to disable (again, with
> > > > lexical scope) a bunch of old ugly things that we'd like to get rid of.
> > > > Horrible things like $[, and $|, and package filehandles, and split()
> > > > overwriting @_, and all the other bits of Perl that I just keep wishing
> > > > weren't there. Maybe that goes into "use 5.14", but I actually feel that
> > > > removing some of the cruft would do wonders for language vitality.
> > >
> > > On a related note, it'd be great to be able to really bind the now
> > > semi-global variable $^, $~, $=, and $- to the filehandle they belong
> > > to. My hopes on getting this fixed are really low, as the
> > > implementation is scattered all over the source code and making them
> > > really bound to the current selected file handle will most likely break
> > > binary compatibility and as formats are frowned upon, nobody seems to
> > > care.
> >
> > Breaking binary compatibility isn't a problem in a major release.
> > Heck, blead can breaks binary compatibility on each successive commit :-)
> >
> > Did you mean "backwards compatibility"?
>
> No.
>
> I think that to make those variable bound to IO handles, the Istructure
> has to be changed and/or extended. The major problem here isn't that
> but the scattering of the implementation.
>
> > The level of me "not caring" is "sure, if you think it's sensible then do it",
> > and by "sensible", I mean "not going to end up with bug reports months or
> > years later about obscure breakage". Bug reports *immediately* are probably
> > OK. I have an unofficial plan in my head about what I want to play with, and
> > formats aren't on that list.
>
> I'm not sure *I* am (yet) able to do it. I must admit my internals and
> XS skills have grown over the years, but this goes deeeep :)
>
> I /do/ think it would be a sane change. Making it possible to (re)move
> more globals that shouldn't be global or could even be lexicaliced
> and/or localized on a per filehandle basis would for sure fix a whole
> bunch of bug reports
>
> Other things that could be `fixed' by this is keeping explicitly set
> formats:
> --8<---
> use strict;
> use warnings;
>
> format BAR_TOP =
> @>> @>> @>> BAR_TOP
> $=, $-, $~
> .
> format FOO =
> @>> @>> @>> FOO
> $=, $-, $~
> .
>
> open my $fh, ">&STDOUT";
>
> select STDOUT;
> $^ = "BAR_TOP";
> $~ = "FOO";
> write;
>
> select $fh;
> write;
> -->8---
>
> results in
>
> 60 60 FOO BAR_TOP
> 60 0 FOO FOO
> Undefined format "$fh" called at test.pl line 23.
>
> > "Bug" reports about blatant breakage aren't about the bug the reporter thought
> > they were reporting. As in the bug is "PEBKAC" when the fix is "RFTM", because
> > it's a documented and intended change.
>
> I will gladly admit that priority is low.
On some renewed analysis, I think most of the work has already been
done since I first digged into this. All those variables are already
localized:
--8<---
#define _XPVIO_TAIL \
PerlIO * xio_ifp; /* ifp and ofp are normally the same */ \
PerlIO * xio_ofp; /* but sockets need separate streams */ \
/* Cray addresses everything by word boundaries (64 bits) and \
* code and data pointers cannot be mixed (which is exactly what \
* Perl_filter_add() tries to do with the dirp), hence the \
* following union trick (as suggested by Gurusamy Sarathy). \
* For further information see Geir Johansen's problem report \
* titled [ID 20000612.002] Perl problem on Cray system \
* The any pointer (known as IoANY()) will also be a good place \
* to hang any IO disciplines to. \
*/ \
union { \
DIR * xiou_dirp; /* for opendir, readdir, etc */ \
void * xiou_any; /* for alignment */ \
} xio_dirpu; \
IV xio_lines; /* $. */ \
IV xio_page; /* $% */ \
IV xio_page_len; /* $= */ \
IV xio_lines_left; /* $- */ \
char * xio_top_name; /* $^ */ \
GV * xio_top_gv; /* $^ */ \
char * xio_fmt_name; /* $~ */ \
GV * xio_fmt_gv; /* $~ */ \
char * xio_bottom_name;/* $^B */ \
GV * xio_bottom_gv; /* $^B */ \
char xio_type; \
U8 xio_flags
struct xpvio {
_XPV_HEAD;
_XPVMG_HEAD;
_XPVIO_TAIL;
};
typedef struct {
_XPV_ALLOCATED_HEAD;
_XPVMG_HEAD;
_XPVIO_TAIL;
} xpvio_allocated;
-->8---
Which leaves us with the correct `restore' of the variables once
'select' is called.
--8<---
use strict;
use warnings;
format STDOUT_TOP =
@>> @>> @>>>>>>>>> STDOUT_TOP
$=, $-, $~
.
format STDOUT =
@>> @>> @>>>>>>>>> STDOUT
$=, $-, $~
.
$= = 3;
select STDOUT;
write;
write;
sub wicked
{
select STDERR;
local $^ = "STDOUT_TOP";
local $~ = "STDOUT";
write;
"";
} # wicked
format WICKED =
@* ~~
@{[wicked]}
.
$~ = "WICKED";
write;
select STDOUT;
write;
write;
write;
-->8---
$ bleadperl test.pl
3 3 STDOUT STDOUT_TOP
3 0 STDOUT STDOUT
3 1 STDOUT STDOUT
60 60 STDOUT STDOUT_TOP
60 0 STDOUT STDOUT
60 58 STDOUT STDOUT
60 57 STDOUT STDOUT
60 56 STDOUT STDOUT
$
The bottom three have the wrong $= and $-
(arguable, the two middle ones also, as I set $= globally, but it seems
to be bound to the current filehandle (STDOUT), which IMHO is correct)
--
H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/
using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00,
11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
Thread Previous
|
Thread Next