This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove (?{...}) closures in regexps from the todo list.
[perl5.git] / Porting / todo.pod
CommitLineData
7711098a
GS
1=head1 NAME
2
c3143508 3todo - Perl TO-DO list
7711098a
GS
4
5=head1 DESCRIPTION
e50bb9a1 6
049aabcb 7This is a list of wishes for Perl. The most up to date version of this file
c3143508 8is at L<http://perl5.git.perl.org/perl.git/blob_plain/HEAD:/Porting/todo.pod>
049aabcb
NC
9
10The tasks we think are smaller or easier are listed first. Anyone is welcome
11to work on any of these, but it's a good idea to first contact
12I<perl5-porters@perl.org> to avoid duplication of effort, and to learn from
13any previous attempts. By all means contact a pumpking privately first if you
14prefer.
e50bb9a1 15
0bdfc961
NC
16Whilst patches to make the list shorter are most welcome, ideas to add to
17the list are also encouraged. Check the perl5-porters archives for past
b4af8972
RB
18ideas, and any discussion about them. One set of archives may be found at
19L<http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/>
938c8732 20
617eabfa
NC
21What can we offer you in return? Fame, fortune, and everlasting glory? Maybe
22not, but if your patch is incorporated, then we'll add your name to the
23F<AUTHORS> file, which ships in the official distribution. How many other
24programming languages offer you 1 line of immortality?
938c8732 25
0bdfc961 26=head1 Tasks that only need Perl knowledge
e50bb9a1 27
de2b17d8
NC
28=head2 Migrate t/ from custom TAP generation
29
30Many tests below F<t/> still generate TAP by "hand", rather than using library
96090e4f 31functions. As explained in L<perlhack/TESTING>, tests in F<t/> are
de2b17d8
NC
32written in a particular way to test that more complex constructions actually
33work before using them routinely. Hence they don't use C<Test::More>, but
34instead there is an intentionally simpler library, F<t/test.pl>. However,
35quite a few tests in F<t/> have not been refactored to use it. Refactoring
36any of these tests, one at a time, is a useful thing TODO.
37
0d8e5a42
RGS
38The subdirectories F<base>, F<cmd> and F<comp>, that contain the most
39basic tests, should be excluded from this task.
40
0be987a2
NC
41=head2 Automate perldelta generation
42
43The perldelta file accompanying each release summaries the major changes.
44It's mostly manually generated currently, but some of that could be
45automated with a bit of perl, specifically the generation of
46
47=over
48
49=item Modules and Pragmata
50
51=item New Documentation
52
53=item New Tests
54
55=back
56
57See F<Porting/how_to_write_a_perldelta.pod> for details.
58
0bdfc961 59=head2 Make Schwern poorer
e50bb9a1 60
613bd4f7 61We should have tests for everything. When all the core's modules are tested,
0bdfc961
NC
62Schwern has promised to donate to $500 to TPF. We may need volunteers to
63hold him upside down and shake vigorously in order to actually extract the
64cash.
3958b146 65
0bdfc961 66=head2 Improve the coverage of the core tests
e50bb9a1 67
e1020413 68Use Devel::Cover to ascertain the core modules' test coverage, then add
02f21748 69tests that are currently missing.
30222c0f 70
0bdfc961 71=head2 test B
e50bb9a1 72
0bdfc961 73A full test suite for the B module would be nice.
e50bb9a1 74
0bdfc961 75=head2 A decent benchmark
e50bb9a1 76
617eabfa 77C<perlbench> seems impervious to any recent changes made to the perl core. It
0bdfc961
NC
78would be useful to have a reasonable general benchmarking suite that roughly
79represented what current perl programs do, and measurably reported whether
80tweaks to the core improve, degrade or don't really affect performance, to
81guide people attempting to optimise the guts of perl. Gisle would welcome
82new tests for perlbench.
6168cf99 83
0bdfc961 84=head2 fix tainting bugs
6168cf99 85
0bdfc961
NC
86Fix the bugs revealed by running the test suite with the C<-t> switch (via
87C<make test.taintwarn>).
e50bb9a1 88
0bdfc961 89=head2 Dual life everything
e50bb9a1 90
0bdfc961
NC
91As part of the "dists" plan, anything that doesn't belong in the smallest perl
92distribution needs to be dual lifed. Anything else can be too. Figure out what
93changes would be needed to package that module and its tests up for CPAN, and
94do so. Test it with older perl releases, and fix the problems you find.
e50bb9a1 95
a393eb28
RGS
96To make a minimal perl distribution, it's useful to look at
97F<t/lib/commonsense.t>.
98
0bdfc961 99=head2 POSIX memory footprint
e50bb9a1 100
0bdfc961
NC
101Ilya observed that use POSIX; eats memory like there's no tomorrow, and at
102various times worked to cut it down. There is probably still fat to cut out -
103for example POSIX passes Exporter some very memory hungry data structures.
e50bb9a1 104
8c422da5
NC
105=head2 makedef.pl and conditional compilation
106
107The script F<makedef.pl> that generates the list of exported symbols on
108platforms which need this. Functions are declared in F<embed.fnc>, variables
109in F<intrpvar.h>. Quite a few of the functions and variables are conditionally
110declared there, using C<#ifdef>. However, F<makedef.pl> doesn't understand the
111C macros, so the rules about which symbols are present when is duplicated in
112the Perl code. Writing things twice is bad, m'kay. It would be good to teach
113F<.pl> to understand the conditional compilation, and hence remove the
114duplication, and the mistakes it has caused.
e50bb9a1 115
801de10e
NC
116=head2 use strict; and AutoLoad
117
118Currently if you write
119
120 package Whack;
121 use AutoLoader 'AUTOLOAD';
122 use strict;
123 1;
124 __END__
125 sub bloop {
126 print join (' ', No, strict, here), "!\n";
127 }
128
129then C<use strict;> isn't in force within the autoloaded subroutines. It would
130be more consistent (and less surprising) to arrange for all lexical pragmas
131in force at the __END__ block to be in force within each autoloaded subroutine.
132
773b3597
RGS
133There's a similar problem with SelfLoader.
134
91d0cbf6
NC
135=head2 profile installman
136
137The F<installman> script is slow. All it is doing text processing, which we're
138told is something Perl is good at. So it would be nice to know what it is doing
139that is taking so much CPU, and where possible address it.
140
c69ca1d4 141=head2 enable lexical enabling/disabling of individual warnings
a9ed9b74
JV
142
143Currently, warnings can only be enabled or disabled by category. There
144are times when it would be useful to quash a single warning, not a
145whole category.
91d0cbf6 146
85234543
KW
147=head2 document diagnostics
148
149Many diagnostic messages are not currently documented. The list is at the end
150of t/porting/diag.t.
151
0bdfc961 152=head1 Tasks that need a little sysadmin-type knowledge
e50bb9a1 153
0bdfc961
NC
154Or if you prefer, tasks that you would learn from, and broaden your skills
155base...
e50bb9a1 156
cd793d32 157=head2 make HTML install work
e50bb9a1 158
78b489b0 159There is an C<install.html> target in the Makefile. It's marked as
adebf063
NC
160"experimental". It would be good to get this tested, make it work reliably, and
161remove the "experimental" tag. This would include
162
163=over 4
164
165=item 1
166
167Checking that cross linking between various parts of the documentation works.
168In particular that links work between the modules (files with POD in F<lib/>)
169and the core documentation (files in F<pod/>)
170
171=item 2
172
78b489b0
NC
173Improving the code that split C<perlfunc> into chunks, preferably with
174general case code added to L<Pod::Functions> that could be used elsewhere.
175
617eabfa
NC
176Challenges here are correctly identifying the groups of functions that go
177together, and making the right named external cross-links point to the right
78b489b0
NC
178page. Currently this works reasonably well in the general case, and correctly
179parses two or more C<=items> giving the different parameter lists for the
180same function, such used by C<substr>. However it fails completely where
181I<different> functions are listed as a sequence of C<=items> but share the
182same description. All the functions from C<getpwnam> to C<endprotoent> have
183individual stub pages, with only the page for C<endservent> holding the
184description common to all. Likewise C<q>, C<qq> and C<qw> have stub pages,
185instead of sharing the body of C<qx>.
186
187Note also the current code isn't ideal with the two forms of C<select>, mushing
188them both into one F<select.html> with the two descriptions run together.
189Fixing this may well be a special case.
adebf063
NC
190
191=back
3a89a73c 192
0bdfc961
NC
193=head2 compressed man pages
194
195Be able to install them. This would probably need a configure test to see how
196the system does compressed man pages (same directory/different directory?
197same filename/different filename), as well as tweaking the F<installman> script
198to compress as necessary.
199
30222c0f
NC
200=head2 Add a code coverage target to the Makefile
201
202Make it easy for anyone to run Devel::Cover on the core's tests. The steps
203to do this manually are roughly
204
205=over 4
206
207=item *
208
209do a normal C<Configure>, but include Devel::Cover as a module to install
f11a3063 210(see L<INSTALL> for how to do this)
30222c0f
NC
211
212=item *
213
214 make perl
215
216=item *
217
218 cd t; HARNESS_PERL_SWITCHES=-MDevel::Cover ./perl -I../lib harness
219
220=item *
221
222Process the resulting Devel::Cover database
223
224=back
225
226This just give you the coverage of the F<.pm>s. To also get the C level
227coverage you need to
228
229=over 4
230
231=item *
232
233Additionally tell C<Configure> to use the appropriate C compiler flags for
234C<gcov>
235
236=item *
237
238 make perl.gcov
239
240(instead of C<make perl>)
241
242=item *
243
244After running the tests run C<gcov> to generate all the F<.gcov> files.
245(Including down in the subdirectories of F<ext/>
246
247=item *
248
249(From the top level perl directory) run C<gcov2perl> on all the C<.gcov> files
250to get their stats into the cover_db directory.
251
252=item *
253
254Then process the Devel::Cover database
255
256=back
257
258It would be good to add a single switch to C<Configure> to specify that you
259wanted to perform perl level coverage, and another to specify C level
260coverage, and have C<Configure> and the F<Makefile> do all the right things
261automatically.
262
02f21748 263=head2 Make Config.pm cope with differences between built and installed perl
0bdfc961
NC
264
265Quite often vendors ship a perl binary compiled with their (pay-for)
266compilers. People install a free compiler, such as gcc. To work out how to
267build extensions, Perl interrogates C<%Config>, so in this situation
268C<%Config> describes compilers that aren't there, and extension building
269fails. This forces people into choosing between re-compiling perl themselves
270using the compiler they have, or only using modules that the vendor ships.
271
272It would be good to find a way teach C<Config.pm> about the installation setup,
273possibly involving probing at install time or later, so that the C<%Config> in
274a binary distribution better describes the installed machine, when the
275installed machine differs from the build machine in some significant way.
276
728f4ecd
NC
277=head2 linker specification files
278
279Some platforms mandate that you provide a list of a shared library's external
280symbols to the linker, so the core already has the infrastructure in place to
281do this for generating shared perl libraries. My understanding is that the
282GNU toolchain can accept an optional linker specification file, and restrict
283visibility just to symbols declared in that file. It would be good to extend
284F<makedef.pl> to support this format, and to provide a means within
285C<Configure> to enable it. This would allow Unix users to test that the
286export list is correct, and to build a perl that does not pollute the global
32d539f5
RU
287namespace with private symbols, and will fail in the same way as msvc or mingw
288builds or when using PERL_DL_NONLAZY=1.
728f4ecd 289
a229ae3b
RGS
290=head2 Cross-compile support
291
292Currently C<Configure> understands C<-Dusecrosscompile> option. This option
293arranges for building C<miniperl> for TARGET machine, so this C<miniperl> is
294assumed then to be copied to TARGET machine and used as a replacement of full
295C<perl> executable.
296
d1307786 297This could be done little differently. Namely C<miniperl> should be built for
a229ae3b 298HOST and then full C<perl> with extensions should be compiled for TARGET.
d1307786 299This, however, might require extra trickery for %Config: we have one config
87a942b1
JH
300first for HOST and then another for TARGET. Tools like MakeMaker will be
301mightily confused. Having around two different types of executables and
302libraries (HOST and TARGET) makes life interesting for Makefiles and
303shell (and Perl) scripts. There is $Config{run}, normally empty, which
304can be used as an execution wrapper. Also note that in some
305cross-compilation/execution environments the HOST and the TARGET do
306not see the same filesystem(s), the $Config{run} may need to do some
307file/directory copying back and forth.
0bdfc961 308
98fca0e8
NC
309=head2 Split "linker" from "compiler"
310
311Right now, Configure probes for two commands, and sets two variables:
312
313=over 4
314
b91dd380 315=item * C<cc> (in F<cc.U>)
98fca0e8
NC
316
317This variable holds the name of a command to execute a C compiler which
318can resolve multiple global references that happen to have the same
319name. Usual values are F<cc> and F<gcc>.
320Fervent ANSI compilers may be called F<c89>. AIX has F<xlc>.
321
b91dd380 322=item * C<ld> (in F<dlsrc.U>)
98fca0e8
NC
323
324This variable indicates the program to be used to link
325libraries for dynamic loading. On some systems, it is F<ld>.
326On ELF systems, it should be C<$cc>. Mostly, we'll try to respect
327the hint file setting.
328
329=back
330
8d159ec1
NC
331There is an implicit historical assumption from around Perl5.000alpha
332something, that C<$cc> is also the correct command for linking object files
333together to make an executable. This may be true on Unix, but it's not true
334on other platforms, and there are a maze of work arounds in other places (such
335as F<Makefile.SH>) to cope with this.
98fca0e8
NC
336
337Ideally, we should create a new variable to hold the name of the executable
338linker program, probe for it in F<Configure>, and centralise all the special
339case logic there or in hints files.
340
341A small bikeshed issue remains - what to call it, given that C<$ld> is already
8d159ec1
NC
342taken (arguably for the wrong thing now, but on SunOS 4.1 it is the command
343for creating dynamically-loadable modules) and C<$link> could be confused with
344the Unix command line executable of the same name, which does something
345completely different. Andy Dougherty makes the counter argument "In parrot, I
346tried to call the command used to link object files and libraries into an
347executable F<link>, since that's what my vaguely-remembered DOS and VMS
348experience suggested. I don't think any real confusion has ensued, so it's
349probably a reasonable name for perl5 to use."
98fca0e8
NC
350
351"Alas, I've always worried that introducing it would make things worse,
352since now the module building utilities would have to look for
353C<$Config{link}> and institute a fall-back plan if it weren't found."
8d159ec1
NC
354Although I can see that as confusing, given that C<$Config{d_link}> is true
355when (hard) links are available.
98fca0e8 356
75585ce3
SP
357=head2 Configure Windows using PowerShell
358
359Currently, Windows uses hard-coded config files based to build the
360config.h for compiling Perl. Makefiles are also hard-coded and need to be
361hand edited prior to building Perl. While this makes it easy to create a perl.exe
362that works across multiple Windows versions, being able to accurately
363configure a perl.exe for a specific Windows versions and VS C++ would be
364a nice enhancement. With PowerShell available on Windows XP and up, this
365may now be possible. Step 1 might be to investigate whether this is possible
366and use this to clean up our current makefile situation. Step 2 would be to
367see if there would be a way to use our existing metaconfig units to configure a
368Windows Perl or whether we go in a separate direction and make it so. Of
369course, we all know what step 3 is.
370
0bdfc961
NC
371=head1 Tasks that need a little C knowledge
372
373These tasks would need a little C knowledge, but don't need any specific
374background or experience with XS, or how the Perl interpreter works
375
3d826b29
NC
376=head2 Weed out needless PERL_UNUSED_ARG
377
378The C code uses the macro C<PERL_UNUSED_ARG> to stop compilers warning about
379unused arguments. Often the arguments can't be removed, as there is an
380external constraint that determines the prototype of the function, so this
381approach is valid. However, there are some cases where C<PERL_UNUSED_ARG>
382could be removed. Specifically
383
384=over 4
385
386=item *
387
388The prototypes of (nearly all) static functions can be changed
389
390=item *
391
392Unused arguments generated by short cut macros are wasteful - the short cut
393macro used can be changed.
394
395=back
396
bcbaa2d5
RGS
397=head2 -Duse32bit*
398
399Natively 64-bit systems need neither -Duse64bitint nor -Duse64bitall.
400On these systems, it might be the default compilation mode, and there
401is currently no guarantee that passing no use64bitall option to the
402Configure process will build a 32bit perl. Implementing -Duse32bit*
e12cb30b 403options would be nice for perl 5.18.0.
bcbaa2d5 404
fee0a0f7 405=head2 Profile Perl - am I hot or not?
62403a3c 406
fee0a0f7
NC
407The Perl source code is stable enough that it makes sense to profile it,
408identify and optimise the hotspots. It would be good to measure the
409performance of the Perl interpreter using free tools such as cachegrind,
410gprof, and dtrace, and work to reduce the bottlenecks they reveal.
411
412As part of this, the idea of F<pp_hot.c> is that it contains the I<hot> ops,
413the ops that are most commonly used. The idea is that by grouping them, their
414object code will be adjacent in the executable, so they have a greater chance
415of already being in the CPU cache (or swapped in) due to being near another op
416already in use.
62403a3c
NC
417
418Except that it's not clear if these really are the most commonly used ops. So
fee0a0f7
NC
419as part of exercising your skills with coverage and profiling tools you might
420want to determine what ops I<really> are the most commonly used. And in turn
421suggest evictions and promotions to achieve a better F<pp_hot.c>.
62403a3c 422
91d0cbf6
NC
423One piece of Perl code that might make a good testbed is F<installman>.
424
98fed0ad
NC
425=head2 Allocate OPs from arenas
426
427Currently all new OP structures are individually malloc()ed and free()d.
428All C<malloc> implementations have space overheads, and are now as fast as
429custom allocates so it would both use less memory and less CPU to allocate
430the various OP structures from arenas. The SV arena code can probably be
431re-used for this.
432
539f2c54
JC
433Note that Configuring perl with C<-Accflags=-DPL_OP_SLAB_ALLOC> will use
434Perl_Slab_alloc() to pack optrees into a contiguous block, which is
435probably superior to the use of OP arenas, esp. from a cache locality
436standpoint. See L<Profile Perl - am I hot or not?>.
437
a229ae3b 438=head2 Improve win32/wince.c
0bdfc961 439
a229ae3b 440Currently, numerous functions look virtually, if not completely,
c23989d1 441identical in both F<win32/wince.c> and F<win32/win32.c> files, which can't
6d71adcd
NC
442be good.
443
c5b31784
SH
444=head2 Use secure CRT functions when building with VC8 on Win32
445
446Visual C++ 2005 (VC++ 8.x) deprecated a number of CRT functions on the basis
447that they were "unsafe" and introduced differently named secure versions of
448them as replacements, e.g. instead of writing
449
450 FILE* f = fopen(__FILE__, "r");
451
452one should now write
453
454 FILE* f;
455 errno_t err = fopen_s(&f, __FILE__, "r");
456
457Currently, the warnings about these deprecations have been disabled by adding
458-D_CRT_SECURE_NO_DEPRECATE to the CFLAGS. It would be nice to remove that
459warning suppressant and actually make use of the new secure CRT functions.
460
461There is also a similar issue with POSIX CRT function names like fileno having
462been deprecated in favour of ISO C++ conformant names like _fileno. These
26a6faa8 463warnings are also currently suppressed by adding -D_CRT_NONSTDC_NO_DEPRECATE. It
c5b31784
SH
464might be nice to do as Microsoft suggest here too, although, unlike the secure
465functions issue, there is presumably little or no benefit in this case.
466
038ae9a4
SH
467=head2 Fix POSIX::access() and chdir() on Win32
468
469These functions currently take no account of DACLs and therefore do not behave
470correctly in situations where access is restricted by DACLs (as opposed to the
471read-only attribute).
472
473Furthermore, POSIX::access() behaves differently for directories having the
474read-only attribute set depending on what CRT library is being used. For
475example, the _access() function in the VC6 and VC7 CRTs (wrongly) claim that
476such directories are not writable, whereas in fact all directories are writable
477unless access is denied by DACLs. (In the case of directories, the read-only
478attribute actually only means that the directory cannot be deleted.) This CRT
479bug is fixed in the VC8 and VC9 CRTs (but, of course, the directory may still
480not actually be writable if access is indeed denied by DACLs).
481
482For the chdir() issue, see ActiveState bug #74552:
b4af8972 483L<http://bugs.activestate.com/show_bug.cgi?id=74552>
038ae9a4
SH
484
485Therefore, DACLs should be checked both for consistency across CRTs and for
486the correct answer.
487
488(Note that perl's -w operator should not be modified to check DACLs. It has
489been written so that it reflects the state of the read-only attribute, even
490for directories (whatever CRT is being used), for symmetry with chmod().)
491
16815324
NC
492=head2 strcat(), strcpy(), strncat(), strncpy(), sprintf(), vsprintf()
493
494Maybe create a utility that checks after each libperl.a creation that
495none of the above (nor sprintf(), vsprintf(), or *SHUDDER* gets())
496ever creep back to libperl.a.
497
498 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)$/'
499
500Note, of course, that this will only tell whether B<your> platform
501is using those naughty interfaces.
502
2a930eea 503=head2 -D_FORTIFY_SOURCE=2
de96509d 504
2a930eea 505Recent glibcs support C<-D_FORTIFY_SOURCE=2> which gives
de96509d 506protection against various kinds of buffer overflow problems.
2a930eea 507It should probably be used for compiling Perl whenever available,
de96509d 508Configure and/or hints files should be adjusted to probe for the
2a930eea 509availability of these feature and enable it as appropriate.
16815324 510
8964cfe0
NC
511=head2 Arenas for GPs? For MAGIC?
512
513C<struct gp> and C<struct magic> are both currently allocated by C<malloc>.
514It might be a speed or memory saving to change to using arenas. Or it might
515not. It would need some suitable benchmarking first. In particular, C<GP>s
516can probably be changed with minimal compatibility impact (probably nothing
517outside of the core, or even outside of F<gv.c> allocates them), but they
518probably aren't allocated/deallocated often enough for a speed saving. Whereas
519C<MAGIC> is allocated/deallocated more often, but in turn, is also something
520more externally visible, so changing the rules here may bite external code.
521
3880c8ec
NC
522=head2 Shared arenas
523
524Several SV body structs are now the same size, notably PVMG and PVGV, PVAV and
525PVHV, and PVCV and PVFM. It should be possible to allocate and return same
526sized bodies from the same actual arena, rather than maintaining one arena for
527each. This could save 4-6K per thread, of memory no longer tied up in the
528not-yet-allocated part of an arena.
529
8964cfe0 530
6d71adcd
NC
531=head1 Tasks that need a knowledge of XS
532
533These tasks would need C knowledge, and roughly the level of knowledge of
534the perl API that comes from writing modules that use XS to interface to
535C.
536
e851c105
DG
537=head2 Write an XS cookbook
538
539Create pod/perlxscookbook.pod with short, task-focused 'recipes' in XS that
540demonstrate common tasks and good practices. (Some of these might be
541extracted from perlguts.) The target audience should be XS novices, who need
542more examples than perlguts but something less overwhelming than perlapi.
543Recipes should provide "one pretty good way to do it" instead of TIMTOWTDI.
544
5b7d14ff
DG
545Rather than focusing on interfacing Perl to C libraries, such a cookbook
546should probably focus on how to optimize Perl routines by re-writing them
547in XS. This will likely be more motivating to those who mostly work in
548Perl but are looking to take the next step into XS.
549
550Deconstructing and explaining some simpler XS modules could be one way to
551bootstrap a cookbook. (List::Util? Class::XSAccessor? Tree::Ternary_XS?)
552Another option could be deconstructing the implementation of some simpler
553functions in op.c.
554
0b162fb0 555=head2 Document how XSUBs can use C<cv_set_call_checker> to inline themselves as OPs
05fb4e20
NC
556
557For a simple XSUB, often the subroutine dispatch takes more time than the
0b162fb0
NC
558XSUB itself. v5.14.0 now allows XSUBs to register a function which will be
559called when the parser is finished building an C<entersub> op which calls
560them.
561
562Registration is done with C<Perl_cv_set_call_checker>, is documented at the
563API level in L<perlapi>, and L<perl5140delta/Custom per-subroutine check hooks>
564notes that it can be used to inline a subroutine, by replacing it with a
565custom op. However there is no further detail of the code needed to do this.
566It would be useful to add one or more annotated examples of how to create
567XSUBs that inline.
568
569This should provide a measurable speed up to simple XSUBs inside
05fb4e20
NC
570tight loops. Initially one would have to write the OP alternative
571implementation by hand, but it's likely that this should be reasonably
572straightforward for the type of XSUB that would benefit the most. Longer
573term, once the run-time implementation is proven, it should be possible to
574progressively update ExtUtils::ParseXS to generate OP implementations for
575some XSUBs.
576
318bf708
NC
577=head2 Remove the use of SVs as temporaries in dump.c
578
579F<dump.c> contains debugging routines to dump out the contains of perl data
580structures, such as C<SV>s, C<AV>s and C<HV>s. Currently, the dumping code
581B<uses> C<SV>s for its temporary buffers, which was a logical initial
582implementation choice, as they provide ready made memory handling.
583
584However, they also lead to a lot of confusion when it happens that what you're
585trying to debug is seen by the code in F<dump.c>, correctly or incorrectly, as
586a temporary scalar it can use for a temporary buffer. It's also not possible
587to dump scalars before the interpreter is properly set up, such as during
588ithreads cloning. It would be good to progressively replace the use of scalars
589as string accumulation buffers with something much simpler, directly allocated
590by C<malloc>. The F<dump.c> code is (or should be) only producing 7 bit
591US-ASCII, so output character sets are not an issue.
592
593Producing and proving an internal simple buffer allocation would make it easier
594to re-write the internals of the PerlIO subsystem to avoid using C<SV>s for
595B<its> buffers, use of which can cause problems similar to those of F<dump.c>,
596at similar times.
597
5d96f598
NC
598=head2 safely supporting POSIX SA_SIGINFO
599
600Some years ago Jarkko supplied patches to provide support for the POSIX
601SA_SIGINFO feature in Perl, passing the extra data to the Perl signal handler.
602
603Unfortunately, it only works with "unsafe" signals, because under safe
604signals, by the time Perl gets to run the signal handler, the extra
605information has been lost. Moreover, it's not easy to store it somewhere,
606as you can't call mutexs, or do anything else fancy, from inside a signal
607handler.
608
609So it strikes me that we could provide safe SA_SIGINFO support
610
611=over 4
612
613=item 1
614
615Provide global variables for two file descriptors
616
617=item 2
618
619When the first request is made via C<sigaction> for C<SA_SIGINFO>, create a
620pipe, store the reader in one, the writer in the other
621
622=item 3
623
624In the "safe" signal handler (C<Perl_csighandler()>/C<S_raise_signal()>), if
625the C<siginfo_t> pointer non-C<NULL>, and the writer file handle is open,
626
627=over 8
628
629=item 1
630
631serialise signal number, C<struct siginfo_t> (or at least the parts we care
632about) into a small auto char buff
633
634=item 2
635
636C<write()> that (non-blocking) to the writer fd
637
638=over 12
639
640=item 1
641
642if it writes 100%, flag the signal in a counter of "signals on the pipe" akin
643to the current per-signal-number counts
644
645=item 2
646
647if it writes 0%, assume the pipe is full. Flag the data as lost?
648
649=item 3
650
651if it writes partially, croak a panic, as your OS is broken.
652
653=back
654
655=back
656
657=item 4
658
659in the regular C<PERL_ASYNC_CHECK()> processing, if there are "signals on
660the pipe", read the data out, deserialise, build the Perl structures on
661the stack (code in C<Perl_sighandler()>, the "unsafe" handler), and call as
662usual.
663
664=back
665
666I think that this gets us decent C<SA_SIGINFO> support, without the current risk
667of running Perl code inside the signal handler context. (With all the dangers
668of things like C<malloc> corruption that that currently offers us)
669
670For more information see the thread starting with this message:
b4af8972 671L<http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2008-03/msg00305.html>
5d96f598 672
6d71adcd
NC
673=head2 autovivification
674
675Make all autovivification consistent w.r.t LVALUE/RVALUE and strict/no strict;
676
677This task is incremental - even a little bit of work on it will help.
678
679=head2 Unicode in Filenames
680
681chdir, chmod, chown, chroot, exec, glob, link, lstat, mkdir, open,
682opendir, qx, readdir, readlink, rename, rmdir, stat, symlink, sysopen,
683system, truncate, unlink, utime, -X. All these could potentially accept
684Unicode filenames either as input or output (and in the case of system
685and qx Unicode in general, as input or output to/from the shell).
686Whether a filesystem - an operating system pair understands Unicode in
687filenames varies.
688
689Known combinations that have some level of understanding include
690Microsoft NTFS, Apple HFS+ (In Mac OS 9 and X) and Apple UFS (in Mac
691OS X), NFS v4 is rumored to be Unicode, and of course Plan 9. How to
692create Unicode filenames, what forms of Unicode are accepted and used
693(UCS-2, UTF-16, UTF-8), what (if any) is the normalization form used,
694and so on, varies. Finding the right level of interfacing to Perl
695requires some thought. Remember that an OS does not implicate a
696filesystem.
697
698(The Windows -C command flag "wide API support" has been at least
699temporarily retired in 5.8.1, and the -C has been repurposed, see
700L<perlrun>.)
701
87a942b1
JH
702Most probably the right way to do this would be this:
703L</"Virtualize operating system access">.
704
6d71adcd
NC
705=head2 Unicode in %ENV
706
707Currently the %ENV entries are always byte strings.
87a942b1 708See L</"Virtualize operating system access">.
6d71adcd 709
1f2e7916
JD
710=head2 Unicode and glob()
711
712Currently glob patterns and filenames returned from File::Glob::glob()
87a942b1 713are always byte strings. See L</"Virtualize operating system access">.
1f2e7916 714
6d71adcd
NC
715=head2 use less 'memory'
716
717Investigate trade offs to switch out perl's choices on memory usage.
718Particularly perl should be able to give memory back.
719
720This task is incremental - even a little bit of work on it will help.
721
722=head2 Re-implement C<:unique> in a way that is actually thread-safe
723
724The old implementation made bad assumptions on several levels. A good 90%
725solution might be just to make C<:unique> work to share the string buffer
726of SvPVs. That way large constant strings can be shared between ithreads,
727such as the configuration information in F<Config>.
728
729=head2 Make tainting consistent
730
731Tainting would be easier to use if it didn't take documented shortcuts and
732allow taint to "leak" everywhere within an expression.
733
734=head2 readpipe(LIST)
735
736system() accepts a LIST syntax (and a PROGRAM LIST syntax) to avoid
737running a shell. readpipe() (the function behind qx//) could be similarly
738extended.
739
6d71adcd
NC
740=head2 Audit the code for destruction ordering assumptions
741
742Change 25773 notes
743
744 /* Need to check SvMAGICAL, as during global destruction it may be that
745 AvARYLEN(av) has been freed before av, and hence the SvANY() pointer
746 is now part of the linked list of SV heads, rather than pointing to
747 the original body. */
748 /* FIXME - audit the code for other bugs like this one. */
749
750adding the C<SvMAGICAL> check to
751
752 if (AvARYLEN(av) && SvMAGICAL(AvARYLEN(av))) {
753 MAGIC *mg = mg_find (AvARYLEN(av), PERL_MAGIC_arylen);
754
755Go through the core and look for similar assumptions that SVs have particular
756types, as all bets are off during global destruction.
757
749904bf
JH
758=head2 Extend PerlIO and PerlIO::Scalar
759
760PerlIO::Scalar doesn't know how to truncate(). Implementing this
761would require extending the PerlIO vtable.
762
763Similarly the PerlIO vtable doesn't know about formats (write()), or
764about stat(), or chmod()/chown(), utime(), or flock().
765
766(For PerlIO::Scalar it's hard to see what e.g. mode bits or ownership
767would mean.)
768
769PerlIO doesn't do directories or symlinks, either: mkdir(), rmdir(),
770opendir(), closedir(), seekdir(), rewinddir(), glob(); symlink(),
771readlink().
772
94da6c29
JH
773See also L</"Virtualize operating system access">.
774
d6c1e11f
JH
775=head2 Organize error messages
776
777Perl's diagnostics (error messages, see L<perldiag>) could use
a8d0aeb9 778reorganizing and formalizing so that each error message has its
d6c1e11f
JH
779stable-for-all-eternity unique id, categorized by severity, type, and
780subsystem. (The error messages would be listed in a datafile outside
c4bd451b
CB
781of the Perl source code, and the source code would only refer to the
782messages by the id.) This clean-up and regularizing should apply
d6c1e11f
JH
783for all croak() messages.
784
785This would enable all sorts of things: easier translation/localization
786of the messages (though please do keep in mind the caveats of
787L<Locale::Maketext> about too straightforward approaches to
788translation), filtering by severity, and instead of grepping for a
789particular error message one could look for a stable error id. (Of
790course, changing the error messages by default would break all the
791existing software depending on some particular error message...)
792
793This kind of functionality is known as I<message catalogs>. Look for
794inspiration for example in the catgets() system, possibly even use it
795if available-- but B<only> if available, all platforms will B<not>
de96509d 796have catgets().
d6c1e11f
JH
797
798For the really pure at heart, consider extending this item to cover
799also the warning messages (see L<perllexwarn>, C<warnings.pl>).
3236f110 800
0bdfc961 801=head1 Tasks that need a knowledge of the interpreter
3298bd4d 802
0bdfc961
NC
803These tasks would need C knowledge, and knowledge of how the interpreter works,
804or a willingness to learn.
3298bd4d 805
10517af5
JD
806=head2 forbid labels with keyword names
807
808Currently C<goto keyword> "computes" the label value:
809
810 $ perl -e 'goto print'
811 Can't find label 1 at -e line 1.
812
343c8006
JD
813It is controversial if the right way to avoid the confusion is to forbid
814labels with keyword names, or if it would be better to always treat
815bareword expressions after a "goto" as a label and never as a keyword.
10517af5 816
de6375e3
RGS
817=head2 truncate() prototype
818
819The prototype of truncate() is currently C<$$>. It should probably
820be C<*$> instead. (This is changed in F<opcode.pl>)
821
565590b5
NC
822=head2 error reporting of [$a ; $b]
823
824Using C<;> inside brackets is a syntax error, and we don't propose to change
825that by giving it any meaning. However, it's not reported very helpfully:
826
827 $ perl -e '$a = [$b; $c];'
828 syntax error at -e line 1, near "$b;"
829 syntax error at -e line 1, near "$c]"
830 Execution of -e aborted due to compilation errors.
831
832It should be possible to hook into the tokeniser or the lexer, so that when a
833C<;> is parsed where it is not legal as a statement terminator (ie inside
834C<{}> used as a hashref, C<[]> or C<()>) it issues an error something like
835I<';' isn't legal inside an expression - if you need multiple statements use a
836do {...} block>. See the thread starting at
b4af8972 837L<http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2008-09/msg00573.html>
565590b5 838
718140ec
NC
839=head2 lexicals used only once
840
841This warns:
842
843 $ perl -we '$pie = 42'
844 Name "main::pie" used only once: possible typo at -e line 1.
845
846This does not:
847
848 $ perl -we 'my $pie = 42'
849
850Logically all lexicals used only once should warn, if the user asks for
d6f4ea2e
SP
851warnings. An unworked RT ticket (#5087) has been open for almost seven
852years for this discrepancy.
718140ec 853
a3d15f9a
RGS
854=head2 UTF-8 revamp
855
85c006b6
KW
856The handling of Unicode is unclean in many places. In the regex engine
857there are especially many problems. The swash data structure could be
858replaced my something better. Inversion lists and maps are likely
859candidates. The whole Unicode database could be placed in-core for a
860huge speed-up. Only minimal work was done on the optimizer when utf8
861was added, with the result that the synthetic start class often will
862fail to narrow down the possible choices when given non-Latin1 input.
a3d15f9a 863
caf782b7 864=begin todo
a3d15f9a 865
caf782b7
NC
866Many things are fixed, but is these still true?
867
868 The tokeniser ignores the UTF-8-ness of C<PL_rsfp>, or any SVs
869 returned from source filters.
870
871=end
a3d15f9a 872
636e63cb
NC
873=head2 state variable initialization in list context
874
875Currently this is illegal:
876
877 state ($a, $b) = foo();
878
a2874905 879In Perl 6, C<state ($a) = foo();> and C<(state $a) = foo();> have different
a8d0aeb9 880semantics, which is tricky to implement in Perl 5 as currently they produce
a2874905 881the same opcode trees. The Perl 6 design is firm, so it would be good to
a8d0aeb9 882implement the necessary code in Perl 5. There are comments in
a2874905
NC
883C<Perl_newASSIGNOP()> that show the code paths taken by various assignment
884constructions involving state variables.
636e63cb 885
a393eb28
RGS
886=head2 A does() built-in
887
888Like ref(), only useful. It would call the C<DOES> method on objects; it
889would also tell whether something can be dereferenced as an
890array/hash/etc., or used as a regexp, etc.
891L<http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2007-03/msg00481.html>
892
893=head2 Tied filehandles and write() don't mix
894
895There is no method on tied filehandles to allow them to be called back by
896formats.
4fedb12c 897
53967bb9
RGS
898=head2 Propagate compilation hints to the debugger
899
900Currently a debugger started with -dE on the command-line doesn't see the
901features enabled by -E. More generally hints (C<$^H> and C<%^H>) aren't
902propagated to the debugger. Probably it would be a good thing to propagate
903hints from the innermost non-C<DB::> scope: this would make code eval'ed
904in the debugger see the features (and strictures, etc.) currently in
905scope.
906
d10fc472 907=head2 Attach/detach debugger from running program
1626a787 908
cd793d32
NC
909The old perltodo notes "With C<gdb>, you can attach the debugger to a running
910program if you pass the process ID. It would be good to do this with the Perl
0bdfc961
NC
911debugger on a running Perl program, although I'm not sure how it would be
912done." ssh and screen do this with named pipes in /tmp. Maybe we can too.
1626a787 913
0bdfc961
NC
914=head2 LVALUE functions for lists
915
916The old perltodo notes that lvalue functions don't work for list or hash
917slices. This would be good to fix.
918
0bdfc961
NC
919=head2 regexp optimiser optional
920
921The regexp optimiser is not optional. It should configurable to be, to allow
922its performance to be measured, and its bugs to be easily demonstrated.
923
ef36c6a7
RGS
924=head2 C</w> regex modifier
925
926That flag would enable to match whole words, and also to interpolate
927arrays as alternations. With it, C</P/w> would be roughly equivalent to:
928
929 do { local $"='|'; /\b(?:P)\b/ }
930
b4af8972
RB
931See
932L<http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2007-01/msg00400.html>
ef36c6a7
RGS
933for the discussion.
934
0bdfc961
NC
935=head2 optional optimizer
936
937Make the peephole optimizer optional. Currently it performs two tasks as
938it walks the optree - genuine peephole optimisations, and necessary fixups of
939ops. It would be good to find an efficient way to switch out the
940optimisations whilst keeping the fixups.
941
942=head2 You WANT *how* many
943
944Currently contexts are void, scalar and list. split has a special mechanism in
945place to pass in the number of return values wanted. It would be useful to
946have a general mechanism for this, backwards compatible and little speed hit.
947This would allow proposals such as short circuiting sort to be implemented
948as a module on CPAN.
949
950=head2 lexical aliases
951
e12cb30b 952Allow lexical aliases (maybe via the syntax C<my \$alias = \$foo>).
0bdfc961 953
de535794 954=head2 Self-ties
2810d901 955
de535794 956Self-ties are currently illegal because they caused too many segfaults. Maybe
a8d0aeb9 957the causes of these could be tracked down and self-ties on all types
de535794 958reinstated.
0bdfc961
NC
959
960=head2 Optimize away @_
961
962The old perltodo notes "Look at the "reification" code in C<av.c>".
963
87a942b1
JH
964=head2 Virtualize operating system access
965
966Implement a set of "vtables" that virtualizes operating system access
967(open(), mkdir(), unlink(), readdir(), getenv(), etc.) At the very
968least these interfaces should take SVs as "name" arguments instead of
969bare char pointers; probably the most flexible and extensible way
e1a3d5d1
JH
970would be for the Perl-facing interfaces to accept HVs. The system
971needs to be per-operating-system and per-file-system
972hookable/filterable, preferably both from XS and Perl level
87a942b1
JH
973(L<perlport/"Files and Filesystems"> is good reading at this point,
974in fact, all of L<perlport> is.)
975
e1a3d5d1
JH
976This has actually already been implemented (but only for Win32),
977take a look at F<iperlsys.h> and F<win32/perlhost.h>. While all Win32
978variants go through a set of "vtables" for operating system access,
e1020413 979non-Win32 systems currently go straight for the POSIX/Unix-style
e1a3d5d1
JH
980system/library call. Similar system as for Win32 should be
981implemented for all platforms. The existing Win32 implementation
982probably does not need to survive alongside this proposed new
983implementation, the approaches could be merged.
87a942b1
JH
984
985What would this give us? One often-asked-for feature this would
94da6c29
JH
986enable is using Unicode for filenames, and other "names" like %ENV,
987usernames, hostnames, and so forth.
988(See L<perlunicode/"When Unicode Does Not Happen">.)
989
990But this kind of virtualization would also allow for things like
991virtual filesystems, virtual networks, and "sandboxes" (though as long
992as dynamic loading of random object code is allowed, not very safe
993sandboxes since external code of course know not of Perl's vtables).
994An example of a smaller "sandbox" is that this feature can be used to
995implement per-thread working directories: Win32 already does this.
996
997See also L</"Extend PerlIO and PerlIO::Scalar">.
87a942b1 998
057163d7
NC
999=head2 Store the current pad in the OP slab allocator
1000
1001=for clarification
1002I hope that I got that "current pad" part correct
1003
1004Currently we leak ops in various cases of parse failure. I suggested that we
1005could solve this by always using the op slab allocator, and walking it to
1006free ops. Dave comments that as some ops are already freed during optree
1007creation one would have to mark which ops are freed, and not double free them
1008when walking the slab. He notes that one problem with this is that for some ops
1009you have to know which pad was current at the time of allocation, which does
1010change. I suggested storing a pointer to the current pad in the memory allocated
1011for the slab, and swapping to a new slab each time the pad changes. Dave thinks
1012that this would work.
1013
52960e22
JC
1014=head2 repack the optree
1015
1016Repacking the optree after execution order is determined could allow
057163d7
NC
1017removal of NULL ops, and optimal ordering of OPs with respect to cache-line
1018filling. The slab allocator could be reused for this purpose. I think that
1019the best way to do this is to make it an optional step just before the
1020completed optree is attached to anything else, and to use the slab allocator
1021unchanged, so that freeing ops is identical whether or not this step runs.
1022Note that the slab allocator allocates ops downwards in memory, so one would
1023have to actually "allocate" the ops in reverse-execution order to get them
1024contiguous in memory in execution order.
1025
b4af8972
RB
1026See
1027L<http://www.nntp.perl.org/group/perl.perl5.porters/2007/12/msg131975.html>
057163d7
NC
1028
1029Note that running this copy, and then freeing all the old location ops would
1030cause their slabs to be freed, which would eliminate possible memory wastage if
1031the previous suggestion is implemented, and we swap slabs more frequently.
52960e22 1032
12e06b6f
NC
1033=head2 eliminate incorrect line numbers in warnings
1034
1035This code
1036
1037 use warnings;
1038 my $undef;
1039
1040 if ($undef == 3) {
1041 } elsif ($undef == 0) {
1042 }
1043
18a16cc5 1044used to produce this output:
12e06b6f
NC
1045
1046 Use of uninitialized value in numeric eq (==) at wrong.pl line 4.
1047 Use of uninitialized value in numeric eq (==) at wrong.pl line 4.
1048
18a16cc5
NC
1049where the line of the second warning was misreported - it should be line 5.
1050Rafael fixed this - the problem arose because there was no nextstate OP
1051between the execution of the C<if> and the C<elsif>, hence C<PL_curcop> still
1052reports that the currently executing line is line 4. The solution was to inject
1053a nextstate OPs for each C<elsif>, although it turned out that the nextstate
1054OP needed to be a nulled OP, rather than a live nextstate OP, else other line
1055numbers became misreported. (Jenga!)
12e06b6f
NC
1056
1057The problem is more general than C<elsif> (although the C<elsif> case is the
1058most common and the most confusing). Ideally this code
1059
1060 use warnings;
1061 my $undef;
1062
1063 my $a = $undef + 1;
1064 my $b
1065 = $undef
1066 + 1;
1067
1068would produce this output
1069
1070 Use of uninitialized value $undef in addition (+) at wrong.pl line 4.
1071 Use of uninitialized value $undef in addition (+) at wrong.pl line 7.
1072
1073(rather than lines 4 and 5), but this would seem to require every OP to carry
1074(at least) line number information.
1075
1076What might work is to have an optional line number in memory just before the
1077BASEOP structure, with a flag bit in the op to say whether it's present.
1078Initially during compile every OP would carry its line number. Then add a late
1079pass to the optimiser (potentially combined with L</repack the optree>) which
1080looks at the two ops on every edge of the graph of the execution path. If
1081the line number changes, flags the destination OP with this information.
1082Once all paths are traced, replace every op with the flag with a
1083nextstate-light op (that just updates C<PL_curcop>), which in turn then passes
1084control on to the true op. All ops would then be replaced by variants that
1085do not store the line number. (Which, logically, why it would work best in
1086conjunction with L</repack the optree>, as that is already copying/reallocating
1087all the OPs)
1088
18a16cc5
NC
1089(Although I should note that we're not certain that doing this for the general
1090case is worth it)
1091
52960e22
JC
1092=head2 optimize tail-calls
1093
1094Tail-calls present an opportunity for broadly applicable optimization;
1095anywhere that C<< return foo(...) >> is called, the outer return can
1096be replaced by a goto, and foo will return directly to the outer
1097caller, saving (conservatively) 25% of perl's call&return cost, which
1098is relatively higher than in C. The scheme language is known to do
1099this heavily. B::Concise provides good insight into where this
1100optimization is possible, ie anywhere entersub,leavesub op-sequence
1101occurs.
1102
1103 perl -MO=Concise,-exec,a,b,-main -e 'sub a{ 1 }; sub b {a()}; b(2)'
1104
1105Bottom line on this is probably a new pp_tailcall function which
1106combines the code in pp_entersub, pp_leavesub. This should probably
1107be done 1st in XS, and using B::Generate to patch the new OP into the
1108optrees.
1109
e12cb30b 1110=head2 Add C<0odddd>
0c397127
KW
1111
1112It has been proposed that octal constants be specifiable through the syntax
1113C<0oddddd>, parallel to the existing construct to specify hex constants
1114C<0xddddd>
1115
0bdfc961
NC
1116=head1 Big projects
1117
1118Tasks that will get your name mentioned in the description of the "Highlights
e12cb30b 1119of 5.18.0"
0bdfc961
NC
1120
1121=head2 make ithreads more robust
1122
45a81a90 1123Generally make ithreads more robust.
0bdfc961
NC
1124
1125This task is incremental - even a little bit of work on it will help, and
1126will be greatly appreciated.
1127
07577ec1
FC
1128One bit would be to determine how to clone directory handles on systems
1129without a C<fchdir> function (in sv.c:Perl_dirp_dup).
6c047da7 1130
59c7f7d5
RGS
1131Fix Perl_sv_dup, et al so that threads can return objects.
1132
6bda09f9
YO
1133=head2 Add class set operations to regexp engine
1134
1135Apparently these are quite useful. Anyway, Jeffery Friedl wants them.
1136
1137demerphq has this on his todo list, but right at the bottom.
44a7a252
JV
1138
1139
1140=head1 Tasks for microperl
1141
1142
1143[ Each and every one of these may be obsolete, but they were listed
1144 in the old Todo.micro file]
1145
44a7a252
JV
1146=head2 do away with fork/exec/wait?
1147
1148(system, popen should be enough?)
1149
1150=head2 some of the uconfig.sh really needs to be probed (using cc) in buildtime:
1151
1152(uConfigure? :-) native datatype widths and endianness come to mind
1153