perltodo - Perl TO-DO List
This is a list of wishes for Perl. Send updates to perl5-porters@perl.org. If you want to work on any of these projects, be sure to check the perl5-porters archives for past ideas, flames, and propaganda. This will save you time and also prevent you from implementing something that Larry has already vetoed. One set of archives may be found at:
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/
perlio
provides this, but the interface could be a lot more straightforward.
When the lexer sees, for instance, bytes::length
, it should automatically load the bytes
pragma.
Danger, Will Robinson! Discussing the semantics of "\x{F00}"
, "\xF00"
and "\U{F00}"
on P5P will lead to a long and boring flamewar.
For displaying PVs with control characters, embedded nulls, and Unicode. This would be useful for printing warnings, or data and regex dumping, not_a_number(), and so on.
Requirements: should handle both byte and UTF-8 strings. isPRINT() characters printed as-is, character less than 256 as \xHH, Unicode characters as \x{HHH}. Don't assume ASCII-like, either, get somebody on EBCDIC to test the output.
Possible options, controlled by the flags: - whitespace (other than ' ' of isPRINT()) printed as-is - use isPRINT_LC() instead of isPRINT() - print control characters like this: "\cA" - print control characters like this: "^A" - non-PRINTables printed as '.' instead of \xHH - use \OOO instead of \xHH - use the C/Perl-metacharacters like \n, \t - have a maximum length for the produced string (read it from *lenp) - append a "..." to the produced string if the maximum length is exceeded - really fancy: print unicode characters as \N{...}
NOTE: pv_display(), pv_uni_display(), sv_uni_display() are already doing something like the above.
This may or may not be possible with the current regular expression engine. The idea is that, for instance, \b
needs to be algorithmically computed if you're dealing with Thai text. Hence, the \b assertion wants to be overloaded by a function.
Allow for long form of the General Category Properties, e.g \p{IsOpenPunctuation}
, not just the abbreviated form, e.g. \p{IsPs}
.
Allow for the metaproperties: XID Start
, XID Continue
, NF*_NO
, NF*_MAYBE
(require the DerivedCoreProperties and DerviceNormalizationProperties files).
There are also multiple value properties still unimplemented: Numeric Type
, East Asian Width
.
Case Mappings? http://www.unicode.org/unicode/reports/tr21/
Mostly implemented (all of 1:1, 1:N, N:1), only the "final sigma" and locale-specific rules of SpecCase are not implemented.
UTF-8 identifier names should probably be canonicalized: NFC?
UTF-8 in package names and sub names? The first is problematic because of the mapping to pathnames, ditto for the second one if one does autosplitting, for example. Some of this works already in 5.8.0, but essentially it is unsupported. Constructs to consider, at the very least:
use utf8;
package UnicodePackage;
sub new { bless {}, shift };
sub UnicodeMethod1 { ... $_[0]->UnicodeMethod2(...) ... }
sub UnicodeMethod2 { ... } # in here caller(0) should contain Unicode
...
package main;
my $x = UnicodePackage->new;
print ref $x, "\n"; # should be Unicode
$x->UnicodeMethod1(...);
my $y = UnicodeMethod3 UnicodePackage ...;
In the above all UnicodeXxx contain (identifier-worthy) characters beyond the code point 255, for example 256. Wherever package/class or subroutine names can be returned needs to be checked for Unicodeness.
See "UNICODE REGULAR EXPRESSION SUPPORT LEVEL" in perlunicode for what's there and what's missing. Almost all of Levels 2 and 3 is missing, and as of 5.8.0 not even all of Level 1 is there. They have some tricks Perl doesn't yet implement, such as character class subtraction.
http://www.unicode.org/unicode/reports/tr18/
There are some suggestions to use for example something like this: default to "(thread exiting first will) wait for the other threads until up to 60 seconds". Other possibilities:
use threads wait => 0;
Do not wait.
use threads wait_for => 10;
Wait up to 10 seconds.
use threads wait_for => -1;
Wait for ever.
http://archive.develooper.com/perl5-porters@perl.org/msg79618.html
To better support nonpreemptive threading systems, perhaps some of the blocking functions internally in Perl should do a yield() before a blocking call. (Now certain threads tests ({basic,list,thread.t}) simply do a yield() before they sleep() to give nonpreemptive thread implementations a chance).
In some cases, like the GNU pth, which has replacement functions that are nonblocking (pth_select instead of select), maybe Perl should be using them instead when built for threading.
Add PERL_ASYNC_CHECK
to opcodes which loop; replace sigsetjmp
with sigjmp
; check wait
for signal safety.
This was done for 5.6.0, but needs reworking for 5.7.x
POSIX 1003.1 1996 Edition support--realtime stuff: POSIX semaphores, message queues, shared memory, realtime clocks, timers, signals (the metaconfig units mostly already exist for these)
Reader-writer locks, realtime/asynchronous IO
There are non-core modules, such as Socket6
, but these will need integrating when IPv6 actually starts to really happen. See RFC 2292 and RFC 2553.
Floating point formatting is still causing some weird test failures.
Locales and Unicode interact with each other in unpleasant ways. One possible solution would be to adopt/support ICU:
http://oss.software.ibm.com/icu/index.html
[1234567890]
aren't the only numerals any more.
([=a=]
for equivalence classes, [.ch.]
for collation.) These are dependent on Unicode normalization and collation.
Currently, the user has to optimize foo|far
and foo|goo
into f(?:oo|ar)
and [fg]oo
by hand; this could be done automatically.
All the code we ship with Perl needs to be sensible about temporary file handling, locking, input validation, and so on.
Currently there are several problems with the setting of uids ($<, $> for the real and effective uids). Firstly, what exactly setuid() call gets invoked in which platform is simply a big mess that needs to be untangled. Secondly, the effects are apparently not standard across platforms, (if you first set $< and then $>, or vice versa, being uid == euid == zero, or just euid == zero, or as a normal user, what are the results?). The test suite not (usually) being run as root means that these things do not get much testing. Thirdly, there's quite often a third uid called saved uid, and Perl has no knowledge of that feature in any way. (If one has the saved uid of zero, one can get back any real and effective uids.) As an example, to change also the saved uid, one needs to set the real and effective uids twice-- in most systems, that is: in HP-UX that doesn't seem to work.
Have a way to introduce user-defined opcodes without the subroutine call overhead of an XSUB; the user should be able to create PP code. Simon Cozens has some ideas on this.
Windows needs a way to know what version of an XS or libperl
DLL it's loading.
$(
may return "foo bar baz". Unfortunately, since groups can theoretically have spaces in their names, this could be one, two or three groups.
NaN
and inf
support is particularly troublesome. (fp_classify(), fp_class(), fp_class_d(), class(), isinf(), isfinite(), finite(), isnormal(), unordered(), <ieeefp.h>, <fp_class.h> (there are metaconfig units for all these) (I think), fp_setmask(), fp_getmask(), fp_setround(), fp_getround() (no metaconfig units yet for these). Don't forget finitel(), fp_classl(), fp_class_l(), (yes, both do, unfortunately, exist), and unorderedl().)
As of Perl 5.6.1, there is a Perl macro, Perl_isnan().
Nicholas Clark has done a lot of work on this, but work is continuing. +
, -
and *
work, but guards need to be in place for %
, /
, &
, oct
, hex
and pack
.
The CPAN module Marek::Pod::Html
may be a more suitable basis for a pod2html
converter; the current one duplicates the functionality abstracted in Pod::Parser
, which makes updating the POD language difficult.
When a new Perl is being beta tested, porters have to manually grab their favourite CPAN modules and test them - this should be done automatically.
We have all the other BSD socket functions but these. There are metaconfig units for these functions which can be added. To avoid these being new opcodes, a solution similar to the way sockatmark
was added would be preferable. (Autoload the IO::whatever
module.)
The new-style patterns need full documentation, and the whole document needs to be a lot clearer.
Simon Cozens has done some work on this but it needs a rethink.
These are ideas that have been regularly tossed around, that most people believe should be done maybe during 5.8.x
Because the regular expression engine is recursive, badly designed expressions can lead to lots of recursion filling up the stack. Ilya claims that it is easy to convert the engine to being iterative, but this has still not yet been done. There may be a regular expression engine hit squad meeting at TPC5.
Perl will leak memory if you eval "hlagh hlagh hlagh hlagh"
. This is partially because it attempts to build up an op tree for that code and doesn't properly free it. The same goes for non-syntactically-correct regular expressions. Hugo looked into this, but decided it needed a mark-and-sweep GC implementation.
Alan notes that: The basic idea was to extend the parser token stack (YYSTYPE
) to include a type field so we knew what sort of thing each element of the stack was. The perly.c code would then have to be postprocessed to record the type of each entry on the stack as it was created, and the parser patched so that it could unroll the stack properly on error.
This is possible to do, but would be pretty messy to implement, as it would rely on even more sed hackery in perly.fixer.
Make Perl buildable with a cross-compiler. This will play havoc with Configure, which needs to know how the target system will respond to its tests; maybe microperl
will be a good starting point here. (Indeed, Bart Schuller reports that he compiled up microperl
for the Agenda PDA and it works fine.) A really big spanner in the works is the bootstrapping build process of Perl: if the filesystem the target systems sees is not the same what the build host sees, various input, output, and (Perl) library files need to be copied back and forth.
As of 5.8.0 Configure mostly works for cross-compilation (used successfully for iPAQ Linux), miniperl gets built, but then building DynaLoader (and other extensions) fails since MakeMaker knows nothing of cross-compilation. (See INSTALL/Cross-compilation for the state of things.)
Source filters help with this, but do not get us all the way. For instance, it should be possible to implement the ??
operator somehow; source filters don't (quite) cut it.
Damian Conway is planning to work on this, but it hasn't happened yet.
When faced with a BSD vs. SysV -style interface to some library or system function, perl's roots show in that it typically prefers the BSD interface (but falls back to the SysV one). One example is getpgrp(). Other examples include memcpy
vs. bcopy
. There are others, mostly in pp_sys.c.
Mostly, this item is a suggestion for which way to start a journey into an #ifdef
forest. It is not primarily a suggestion to eliminate any of the #ifdef
forests.
POSIX calls are perhaps more likely to be portable to unexpected architectures. They are also perhaps more likely to be actively maintained by a current vendor. They are also perhaps more likely to be available in thread-safe versions, if appropriate.
It's only necessary to rename a file when inplace editing when the file has changed. Detecting a change is perhaps the difficult bit.
eg read(ARGV, ...)
doesn't currently read across multiple files.
There should be a way of restarting the debugger on demand.
The debugger is a complex piece of software and fixing something here may inadvertently break something else over there. To tame this chaotic behaviour, a test suite is necessary.
The basic principle is sound, but there are problems with the semantics of self-referential and mutually referential lexical subs: how to declare the subs?
Sweeping away all the allocated memory in one go is a laudable goal, but it's difficult and in most cases, it's easier to let the memory get freed by exiting.
There has been talk recently of rewriting the regular expression parser to produce an optree instead of a chain of opcodes; it's unclear whether or not this would be a win.
This is to speed up
for my $re (@regexps) {
$matched++ if /$re/
}
qr//
already gives us a way of saving compiled regexps, but it should be done automatically.
Bart Schuller reports that using microperl
and a cross-compiler, he got Perl working on the Agenda PDA. However, one cannot build a full Perl because Configure needs to get the results for the target platform, for the host.
Given:
vec($v, 1000, 1) = 1;
One should be able to do
$v <<= 1;
and have the 999'th bit set.
Currently if you try with shift bitvectors you shift the NV/UV, instead of the bits in the PV. Not very logical.
The debugger is implemented in Perl in perl5db.pl; turning it into a pragma should be easy, but making it work lexically might be more difficult. Fiddling with $^P
would be necessary.
Identify areas where speed/memory tradeoffs can be made and have a hint to switch between them.
Although we have Switch.pm
in core, Larry points to the dormant nswitch
and cswitch
ops in pp.c; using these opcodes would be much faster.
Look at the "reification" code in av.c
Currently, indirect object syntax bypasses prototype checks.
HTML versions of the documentation need to be installed by default; a call to installhtml
from installperl
may be all that's necessary.
There have been persistent mumblings about putting a mark-and-sweep garbage detector into Perl; Alan Burlison has some ideas about this.
Mark-Jason Dominus has the beginnings of one of these.
There are a few suggestions for what to do with perldoc
: maybe a full-text search, an index function, locating pages on a particular high-level subject, and so on.
This is a bone of contention; we can create .3p
manpages for each built-in function, but should we install them by default? Tcl does this, and it clutters up apropos
.
Simon Cozens promises to do this before he gets old.
Allow @INC
to be changed after Perl is built.
Make POSIX.pm
behave as POSIXly as possible everywhere, meaning we have to implement POSIX equivalents for some functions if necessary.
They don't work in the debugger, and they don't work for list or hash slices.
Hugo van der Sanden plans to look at this.
This has been done in places, but needs a thorough code review. Also fchdir is available in some platforms.
Instead of having to guess whether a string is a v-string and thus needs to be displayed with %vd, make v-strings (readonly) objects (class "vstring"?) with a stringify overload.
Currently you're not allowed to assign to a restricted hash at all, even with the same keys.
%restricted = (foo => 42); # error
This should be allowed if the new keyset is a subset of the old keyset. May require more extra code than we'd like in pp_aassign.
Should overload be 'contagious' through @ISA so that derived classes would inherit their base classes' overload definitions? What to do in case of overload conflicts?
Should taint be stopped from affecting control flow, if ($tainted)? Should tainted symbolic method calls and subref calls be stopped? (Look at Ruby's $SAFE levels for inspiration?)
If an XSUB calls a subroutine that exits using goto(LABEL), last(LABEL) or next(LABEL), then the interpreter will very probably crash with a segfault because the execution resumes in the XSUB instead of never returning there.
Ideas which have been discussed, and which may or may not happen.
It's unclear what this should do or how to do it without breaking old code.
There is a patch for this, but it may require Unicodification.
($x = "elephant") =~ /e(ph)/;
$1 = "g"; # $x = "elegant"
What happens if there are multiple (nested?) brackets? What if the string changes between the match and the assignment?
Some core modules have been accused of being overly-OO. Adding procedural interfaces could demystify them.
With gdb
, you can attach the debugger to a running program if you pass the process ID. It would be good to do this with the Perl debugger on a running Perl program, although I'm not sure how it would be done.
A non-core module that would use "native" GUI to create graphical applications.
Currently
foreach (reverse @_) { ... }
puts @_
on the stack, reverses it putting the reversed version on the stack, then iterates forwards. Instead, it could be special-cased to put @_
on the stack then iterate backwards.
These items always need doing:
Simon Cozens tries to do this when possible, and contributions to the perlapi
documentation is welcome.
Michael Schwern will donate $500 to Yet Another Society when all core modules have tests.
The code we ship with Perl should look like good Perl 5.
Debugging macros (like printsv, dump) can make debugging perl inside a C debugger much easier. A good set for gdb comes with mod_perl. Something similar should be distributed with perl.
The proper way to do this is to use and extend Devel::DebugInit. Devel::DebugInit also needs to be extended to support threads.
See p5p archives for late May/early June 2001 for a recent discussion on this topic.
One can emulate ftruncate() using F_FREESP and F_CHSIZ fcntls (see the UNIX FAQ for details). This needs to go somewhere near pp_sys.c:pp_truncate().
One can emulate truncate() easily if one has ftruncate(). This emulation should also go near pp_sys.pp_truncate().
chdir, chmod, chown, chroot, exec, glob, link, lstat, mkdir, open, opendir, qx, readdir, readlink, rename, rmdir, stat, symlink, sysopen, system, truncate, unlink, utime, -X. All these could potentially accept Unicode filenames either as input or output (and in the case of system and qx Unicode in general, as input or output to/from the shell). Whether a filesystem - an operating system pair understands Unicode in filenames varies.
Known combinations that have some level of understanding include Microsoft NTFS, Apple HFS+ (In Mac OS 9 and X) and Apple UFS (in Mac OS X), NFS v4 is rumored to be Unicode, and of course Plan 9. How to create Unicode filenames, what forms of Unicode are accepted and used (UCS-2, UTF-16, UTF-8), what (if any) is the normalization form used, and so on, varies. Finding the right level of interfacing to Perl requires some thought. Remember that an OS does not implicate a filesystem.
(The Windows -C command flag "wide API support" has been at least temporarily retired in 5.8.1, and the -C has been repurposed, see perlrun.)
Currently the %ENV entries are always byte strings.
These are things which have been on the todo lists in previous releases but have recently been completed.
The Regexp::English
module, available from the CPAN, provides this:
my $re = Regexp::English
-> start_of_line
-> literal('Flippers')
-> literal(':')
-> optional
-> whitespace_char
-> end
-> remember
-> multiple
-> digit;
/$re/;
A new signal model went into 5.7.1 without much fanfare. Operations and malloc
s are no longer interrupted by signals, which are handled between opcodes. This means that PERL_ASYNC_CHECK
now actually does something. However, there are still a few things that need to be done.
Modules which implement arrays in terms of strings, substrings or files can be found on the CPAN.
Time::HiRes
has been integrated into the core.
Adding Time::HiRes
got us this too.
Tests have been added.
A C Yardley will probably have done this by the time you can read this. This allows for a generalization of the C constant detection used in building Errno.pm
.
Switch.pm
has been integrated into the core to give you all manner of switch...case
semantics.
This is Fatal.pm
.
Nick Ing-Simmons has made UTF-EBCDIC (UTR13) work with Perl.
EBCDIC? http://www.unicode.org/unicode/reports/tr16/
Although there are probably some small bugs to be rooted out, Jarkko Hietaniemi has made regular expressions polymorphic between bytes and characters.
perlcc
was recently rewritten, and can now produce standalone executables.
Tim Jenness' File::Temp
is now in core.
This module is now part of core.
Benjamin Sugars has done this.
Nick Ing-Simmons' perlio
supports an mmap
IO method.
Encode
provides this.
Added in 5.7.1
http://lists.perl.org/ , http://archive.develooper.com/
Since 5.8.0 perl uses the RT bug tracking system from Jesse Vincent, implemented by Robert Spier at http://bugs.perl.org/
Chris Nandor and Matthias Neeracher have integrated the MacPerl changes into 5.6.0.
http://use.perl.org/ is what you're looking for.
perlretut
, provided by Mark Kvale.
perldebtut
, written by Richard Foley.
Jarkko has been integrating madly into 5.7.x
Devel::DProf
is now a core module.
There's a configure option to detect unsafe concatenation with "19", and a CPAN module. (D'oh::Year
)
While not part of core, Mark-Jason Dominus has written Rx
and has also come up with a generalised strategy for regular expression debugging.
That's, uh, podchecker
These are items which used to be in the todo file, but have been deprecated for some reason.
This would break old code; use do{{ }}
instead.
Not needed now we have lexical IO handles.
Damian Conway's text formatting modules seem to be the Way To Go.
Robin Houston's Want
module does this.
This seems to be delayed until Perl 6.
The File::Glob
module has been used to replace the glob
function.
suidperl
is deprecated in favour of common sense.
We have shared hash keys, which perform the same job.
The compression modules are a little heavy; meanwhile, Nick Clark is working on experimental pragmata to do transparent decompression on input.
Could not get consensus on P5P about this.
Caution: highly flammable.
Use Inline
instead, or SWIG.
Use Inline::CPR
.
See the Perl Power Tools. ( http://language.perl.com/ppt/ )
Use our
instead.
Suggesting this on P5P will cause a boring and interminable flamewar.
Use flyweight objects, secure hashes or, dare I say it, pseudo-hashes instead. (Or whatever will replace pseudohashes in 5.10.)
ByteLoader
covers this.
List::Util
gives first() (a short-circuiting grep); tail recursion removal is done manually, with goto &whoami;
. (However, MJD has found that goto &whoami
introduces a performance penalty, so maybe there should be a way to do this after all: sub foo {START: ... goto START;
is better.)
Because of backward compatibility this is difficult: scripts could not contain any legacy eight-bit data (like Latin-1) anymore, even in string literals or pod. Also would introduce a measurable slowdown of at least few percentages since all regular expression operations would be done in full UTF-8. But if you want to try this, add -DUSE_UTF8_SCRIPTS to your compilation flags.
The Unicode::Collate and Unicode::Normalize modules by SADAHIRO Tomoyuki have been included since 5.8.0.
Collation? http://www.unicode.org/unicode/reports/tr10/
Normalization? http://www.unicode.org/unicode/reports/tr15/
Wolfgang Laun finished what Simon Cozens started.