This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Refactor test code to remove duplication is a TODO.
[perl5.git] / pod / perltodo.pod
index f75b83c..c4559ae 100644 (file)
@@ -22,6 +22,22 @@ programming languages offer you 1 line of immortality?
 
 =head1 Tasks that only need Perl knowledge
 
+=head2 Remove duplication of test setup.
+
+Schwern notes, that there's duplication of code - lots and lots of tests have
+some variation on the big block of C<$Is_Foo> checks.  We can safely put this
+into a file, change it to build an C<%Is> hash and require it.  Maybe just put
+it into F<test.pl>. Throw in the handy tainting subroutines.
+
+=head2 merge common code in installperl and installman
+
+There are some common subroutines and a common C<BEGIN> block in F<installperl>
+and F<installman>. These should probably be merged. It would also be good to
+check for duplication in all the utility scripts supplied in the source
+tarball. It might be good to move them all to a subdirectory, but this would
+require careful checking to find all places that call them, and change those
+correctly.
+
 =head2 common test code for timed bail out
 
 Write portable self destruct code for tests to stop them burning CPU in
@@ -40,6 +56,19 @@ is needed to improve the cross-linking.
 The addition of C<Pod::Simple> and its related modules may make this task
 easier to complete.
 
+=head2 merge checkpods and podchecker
+
+F<pod/checkpods.PL> (and C<make check> in the F<pod/> subdirectory)
+implements a very basic check for pod files, but the errors it discovers
+aren't found by podchecker. Add this check to podchecker, get rid of
+checkpods and have C<make check> use podchecker.
+
+=head2 perlmodlib.PL rewrite
+
+Currently perlmodlib.PL needs to be run from a source directory where perl
+has been built, or some modules won't be found, and others will be
+skipped. Make it run from a clean perl source tree (so it's reproducible).
+
 =head2 Parallel testing
 
 (This probably impacts much more than the core: also the Test::Harness
@@ -87,6 +116,28 @@ tests that are currently missing.
 
 A full test suite for the B module would be nice.
 
+=head2 Deparse inlined constants
+
+Code such as this
+
+    use constant PI => 4;
+    warn PI
+
+will currently deparse as
+
+    use constant ('PI', 4);
+    warn 4;
+
+because the tokenizer inlines the value of the constant subroutine C<PI>.
+This allows various compile time optimisations, such as constant folding
+and dead code elimination. Where these haven't happened (such as the example
+above) it ought be possible to make B::Deparse work out the name of the
+original constant, because just enough information survives in the symbol
+table to do this. Specifically, the same scalar is used for the constant in
+the optree as is used for the constant subroutine, so by iterating over all
+symbol tables and generating a mapping of SV address to constant name, it
+would be possible to provide B::Deparse with this functionality.
+
 =head2 A decent benchmark
 
 C<perlbench> seems impervious to any recent changes made to the perl core. It
@@ -305,11 +356,36 @@ cross-compilation/execution environments the HOST and the TARGET do
 not see the same filesystem(s), the $Config{run} may need to do some
 file/directory copying back and forth.
 
+=head2 roffitall
+
+Make F<pod/roffitall> be updated by F<pod/buildtoc>.
+
 =head1 Tasks that need a little C knowledge
 
 These tasks would need a little C knowledge, but don't need any specific
 background or experience with XS, or how the Perl interpreter works
 
+=head2 Exterminate PL_na!
+
+C<PL_na> festers still in the darkest corners of various typemap files.
+It needs to be exterminated, replaced by a local variable of type C<STRLEN>.
+
+=head2 Modernize the order of directories in @INC
+
+The way @INC is laid out by default, one cannot upgrade core (dual-life)
+modules without overwriting files. This causes problems for binary
+package builders.  One possible proposal is laid out in this
+message:
+L<http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-04/msg02380.html>.
+
+=head2 -Duse32bit*
+
+Natively 64-bit systems need neither -Duse64bitint nor -Duse64bitall.
+On these systems, it might be the default compilation mode, and there
+is currently no guarantee that passing no use64bitall option to the
+Configure process will build a 32bit perl. Implementing -Duse32bit*
+options would be nice for perl 5.12.
+
 =head2 Make it clear from -v if this is the exact official release
 
 Currently perl from C<p4>/C<rsync> ships with a F<patchlevel.h> file that
@@ -358,6 +434,11 @@ custom allocates so it would both use less memory and less CPU to allocate
 the various OP structures from arenas. The SV arena code can probably be
 re-used for this.
 
+Note that Configuring perl with C<-Accflags=-DPL_OP_SLAB_ALLOC> will use
+Perl_Slab_alloc() to pack optrees into a contiguous block, which is
+probably superior to the use of OP arenas, esp. from a cache locality
+standpoint.  See L<Profile Perl - am I hot or not?>.
+
 =head2 Improve win32/wince.c
 
 Currently, numerous functions look virtually, if not completely,
@@ -383,10 +464,29 @@ warning suppressant and actually make use of the new secure CRT functions.
 
 There is also a similar issue with POSIX CRT function names like fileno having
 been deprecated in favour of ISO C++ conformant names like _fileno. These
-warnings are also currently suppressed with the compiler option /wd4996. It
+warnings are also currently suppressed by adding -D_CRT_NONSTDC_NO_DEPRECATE. It
 might be nice to do as Microsoft suggest here too, although, unlike the secure
 functions issue, there is presumably little or no benefit in this case.
 
+=head2 __FUNCTION__ for MSVC-pre-7.0
+
+Jarkko notes that one can things morally equivalent to C<__FUNCTION__>
+(or C<__func__>) even in MSVC-pre-7.0, contrary to popular belief.
+See L<http://www.codeproject.com/debug/extendedtrace.asp> if you feel like
+making C<PERL_MEM_LOG> more useful on Win32.
+
+=head2 strcat(), strcpy(), strncat(), strncpy(), sprintf(), vsprintf()
+
+Maybe create a utility that checks after each libperl.a creation that
+none of the above (nor sprintf(), vsprintf(), or *SHUDDER* gets())
+ever creep back to libperl.a.
+
+  nm libperl.a | ./miniperl -alne '$o = $F[0] if /:$/; print "$o $F[1]" if $F[0] eq "U" && $F[1] =~ /^(?:strn?c(?:at|py)|v?sprintf|gets)$/'
+
+Note, of course, that this will only tell whether B<your> platform
+is using those naughty interfaces.
+
+
 =head1 Tasks that need a knowledge of XS
 
 These tasks would need C knowledge, and roughly the level of knowledge of
@@ -435,6 +535,12 @@ See L</"Virtualize operating system access">.
 Currently glob patterns and filenames returned from File::Glob::glob()
 are always byte strings.  See L</"Virtualize operating system access">.
 
+=head2 Unicode and lc/uc operators
+
+Some built-in operators (C<lc>, C<uc>, etc.) behave differently, based on
+what the internal encoding of their argument is. That should not be the
+case. Maybe add a pragma to switch behaviour.
+
 =head2 use less 'memory'
 
 Investigate trade offs to switch out perl's choices on memory usage.
@@ -460,17 +566,6 @@ system() accepts a LIST syntax (and a PROGRAM LIST syntax) to avoid
 running a shell. readpipe() (the function behind qx//) could be similarly
 extended.
 
-=head2 strcat(), strcpy(), strncat(), strncpy(), sprintf(), vsprintf()
-
-Maybe create a utility that checks after each libperl.a creation that
-none of the above (nor sprintf(), vsprintf(), or *SHUDDER* gets())
-ever creep back to libperl.a.
-
-  nm libperl.a | ./miniperl -alne '$o = $F[0] if /:$/; print "$o $F[1]" if $F[0] eq "U" && $F[1] =~ /^(?:strn?c(?:at|py)|v?sprintf|gets)$/'
-
-Note, of course, that this will only tell whether B<your> platform
-is using those naughty interfaces.
-
 =head2 Audit the code for destruction ordering assumptions
 
 Change 25773 notes
@@ -514,12 +609,76 @@ only the interpretation of non-ASCII characters, and not for the script file
 handle. To make it work needs some investigation of the ordering of function
 calls during startup, and (by implication) a bit of tweaking of that order.
 
+=head2 Propagate const outwards from Perl_moreswitches()
+
+Change 32057 changed the parameter and return value of C<Perl_moreswitches()>
+from <char *> to <const char *>. It should now be possible to propagate
+const-correctness outwards to C<S_parse_body()>, C<Perl_moreswitches()>
+and C<Perl_yylex()>.
+
+=head2 Duplicate logic in S_method_common() and Perl_gv_fetchmethod_autoload()
+
+A comment in C<S_method_common> notes
+
+       /* This code tries to figure out just what went wrong with
+          gv_fetchmethod.  It therefore needs to duplicate a lot of
+          the internals of that function.  We can't move it inside
+          Perl_gv_fetchmethod_autoload(), however, since that would
+          cause UNIVERSAL->can("NoSuchPackage::foo") to croak, and we
+          don't want that.
+       */
+
+If C<Perl_gv_fetchmethod_autoload> gets rewritten to take (more) flag bits,
+then it ought to be possible to move the logic from C<S_method_common> to
+the "right" place. When making this change it would probably be good to also
+pass in at least the method name length, if not also pre-computed hash values
+when known. (I'm contemplating a plan to pre-compute hash values for common
+fixed strings such as C<ISA> and pass them in to functions.)
+
+=head2 Organize error messages
+
+Perl's diagnostics (error messages, see L<perldiag>) could use
+reorganizing so that each error message has its
+stable-for-all-eternity unique id, categorized by severity, type, and
+subsystem.  (The error messages would be listed in a datafile outside
+of the Perl source code, and the source code would only refer the
+messages by the is.)  This clean-up and regularizing should apply
+for all croak() messages.
+
+This would enable all sorts of things: easier translation/localization
+of the messages (though please do keep in mind the caveats of
+L<Locale::Maketext> about too straightforward approaches to
+translation), filtering by severity, and instead of grepping for a
+particular error message one could look for a stable error id.  (Of
+course, changing the error messages by default would break all the
+existing software depending on some particular error message...)
+
+This kind of functionality is known as I<message catalogs>.  Look for
+inspiration for example in the catgets() system, possibly even use it
+if available-- but B<only> if available, all platforms will B<not>
+catgets().
+
+For the really pure at heart, consider extending this item to cover
+also the warning messages (see L<perllexwarn>, C<warnings.pl>).
 
 =head1 Tasks that need a knowledge of the interpreter
 
 These tasks would need C knowledge, and knowledge of how the interpreter works,
 or a willingness to learn.
 
+=head2 state variable initialization in list context
+
+Currently this is illegal:
+
+    state ($a, $b) = foo(); 
+
+The current Perl 6 design is that C<state ($a) = foo();> and
+C<(state $a) = foo();> have different semantics, which is tricky to implement
+in Perl 5 as currently the produce the same opcode trees. It would be useful
+to clarify that the Perl 6 design is firm, and then implement the necessary
+code in Perl 5. There are comments in C<Perl_newASSIGNOP()> that show the
+code paths taken by various assignment constructions involving state variables.
+
 =head2 Implement $value ~~ 0 .. $range
 
 It would be nice to extend the syntax of the C<~~> operator to also
@@ -544,6 +703,12 @@ 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." ssh and screen do this with named pipes in /tmp. Maybe we can too.
 
+=head2 Optimize away empty destructors
+
+Defining an empty DESTROY method might be useful (notably in
+AUTOLOAD-enabled classes), but it's still a bit expensive to call. That
+could probably be optimized.
+
 =head2 LVALUE functions for lists
 
 The old perltodo notes that lvalue functions don't work for list or hash
@@ -663,6 +828,12 @@ implement per-thread working directories: Win32 already does this.
 
 See also L</"Extend PerlIO and PerlIO::Scalar">.
 
+=head2 Investigate PADTMP hash pessimisation
+
+The peephole optimier converts constants used for hash key lookups to shared
+hash key scalars. Under ithreads, something is undoing this work. See
+See http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2007-09/msg00793.html
+
 =head1 Big projects
 
 Tasks that will get your name mentioned in the description of the "Highlights