=head1 NAME
perl6storm - tchrist's brainstorm list for perl6
=head1 DESCRIPTION
I'm going away for a long, long time, way past the RFC deadline.
Here is my file of notions I've brainstormed over the last few
weeks. Some have been covered in other RFCs. Many haven't. Most
could use some kicking around for eventual immuration. When following
up, you should probably start new threads for each numbered perlstorm
notion below.
=over
=item perl6storm #0000
This:
($a,$b) = <FH>;
should not drain whole ahndle on known LHS count, to rescue
my($x) = <FH>;
=item perl6storm #0001
The way that you need to use \z instead of \Z. Or that
even with /s, $ doesn't mean that. Too many programming
errors because of this.
=item perl6storm #0002
This is our only chance to add more defaults to use strict.
What can we can that is sane, safe, and prudent?
=item perl6storm #0003
Make parens "optionally mandatory" on function calls.
use strict 'functions';
This solves once and for all the annoying precedence problems
that have spawned a million bugs since time immemorial, such
as writing
rand +3
but meaning
rand() + 3
It also obviates the hard-to-read and/or fiaschetti.
Actually, this could go the other way:
no strict 'parenthification';
=item perl6storm #0004
Need perl to spit out pod/non-pod, like cc -E. Pod is too hard to parse.
This would make catpod trivially implemented as a compiler filter.
=item perl6storm #0005
Functions with packed data, like gethostbywhatever, should die die die.
They should never take nor return binary. the netent functions are busted.
=item perl6storm #0006
How can you have
perl --novice
be
perl -MDevel::Novice
yet this propagate to caller's lexical context a use strict and a
use warnings? Hm...
Should perl have long opts?
=item perl6storm #0007
Warnings on void syscalls. including implicit ones.
=item perl6storm #0010
Allow a way to kill *all* defaults at compile time. Or warn about them.
no defaults;
use defaults 'none';
use warnings 'defaults';
this is for anal python folks.
=item perl6storm #0011
perl w/o args with stdin and out ttys should be perl -de 0.
saves novices from typing "perl<CR>" and getting confuddled.
=item perl6storm #0012
local()izing a my() lexical? chip wanted this. annoying
that you can do it on partials:
my @a;
local $a[1];
but not entires:
my @a;
local @a;
=item perl6storm #0013
perldata reads:
To find out whether a given string is a valid nonzero
number, it's usually enough to test it against both
numeric 0 and also lexical "0" (although this will cause
-w noises). That's because strings that aren't numbers
count as 0, just as they do in awk:
if ($str == 0 && $str ne "0") {
warn "That doesn't look like a number";
}
That's usually preferable because otherwise you won't
treat IEEE notations like NaN or Infinity properly. At
other times you might prefer to use the POSIX::strtod
function or a regular expression to check whether data is
numeric. See the perlre manpage for details on regular
expressions.
warn "has nondigits" if /\D/;
warn "not a natural number" unless /^\d+$/; # rejects -3
warn "not an integer" unless /^-?\d+$/; # rejects +3
warn "not an integer" unless /^[+-]?\d+$/;
warn "not a decimal number" unless /^-?\d+\.?\d*$/; # rejects .2
warn "not a decimal number" unless /^-?(?:\d+(?:\.\d*)?|\.\d+)$/;
warn "not a C float"
unless /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/;
shouldn't this be in a module? people always want this. even
the C core has looks_like_a_number.
use Some_Core_Module
if (has_all_digits(...))
if (is_natural_number(...))
if (is_integer(...))
if (isn't_integer(...)) :-)
if (is_decimal(...))
if (is_float(...))
See Ram:2 for more, where it reads:
If you're on a POSIX system, Perl's supports the C<POSIX::strtod>
function. Its semantics are somewhat cumbersome, so here's a C<getnum>
wrapper function for more convenient access. This function takes a string and
returns the number it found, or C<undef> for input that isn't a C float.
The C<is_numeric> function is a front end to C<getnum> if you just want
to say, ``Is this a float?''
sub getnum {
use POSIX qw(strtod);
my $str = shift;
$str =~ s/^\s+//;
$str =~ s/\s+$//;
$! = 0;
my($num, $unparsed) = strtod($str);
if (($str eq '') || ($unparsed != 0) || $!) {
return undef;
} else {
return $num;
}
}
sub is_numeric { defined &getnum }
=item perl6storm #0014
make it easy to have an overloaded stringify (q/""/) and comparison
operator (qw/<=> cmp/) without having to say "use overload".
=item perl6storm #0015
merge tie and overloading. python's ease of doing this
makes this embarrassing.
=item perl6storm #0016
object as scope/namespace? see python. it's danged clean
there in that you can now implement safe trivially.
don't have to keep inventing crazy overloads.
=item perl6storm #0017
fix prototypes so that they're less surprising.
=item perl6storm #0020
add named parameters.
sub fn($x, $y)
but does this mean
sub fn(@) {
my($x, $y) = @_[0,1];
}
or does it mean
sub fn($$) {
my($x, $y) = @_[0,1];
}
Whichever you choose, you'll annoy people -- guaranteed.
=item perl6storm #0021
make the User::pwent style by-name hash object returns
the default
=item perl6storm #0022
make marshalling easy. core module? would this allow for easy
persistence of data structures other than dbm files?
general persistence is hard, right? can this be an attribute?
=item perl6storm #0023
allow for way to get smoothly infinitely precise numbers. to
unastonish non-numeric programmers, figure out how to deal with
floats and bigint complexities without getting as slow as rexx.
Compares of floats. Fudge? Pad? Warn?
=item perl6storm #0024
people think printf %d means %.0f -- should it? actually,
maybe a rounding pragma for $x[$i] (eg integer context).
=item perl6storm #0025
Make -T the default when operating in a CGI env. That is, taintmode.
Will this kill us? Close to it. Tough. Insecurity through idiocy
is a problem. Make them *add* a switch to make it insecure, like
-U, if that's what they mean, to disable tainting instead.
=item perl6storm #0026
Make CGI programming easier. Make as first class as
@ARGV and %ENV for CLI progging.
=item perl6storm #0027
Consider a tuple comparison function. Hmm, change OP to (OP) maybe?
$both_same = ($a, $b) (==) (1,2);
Well, that's certainly ugly. I hate things that are paren dependent.
Shouldn't eof() vs eof die the death?
=item perl6storm #0030
Pod is too hard. Parsers very nasty. It's because of nested tags,
not because of paragraphs. Fix pod so tags don't nest. That way
it's easy again.
=item perl6storm #0031
Add pragma to auto-flock LOCK_EX any files opened O_WRONLY,
and LOCK_SH otherwise.
=item perl6storm #0032
Allow inspection of command line switches.
Allow enabling of command line switches via pragmatic i/f.
=item perl6storm #0033
Should == on strings (wrong type) turn into eq?
=item perl6storm #0034
Find an easier way to write the prefix dereffers. infix
easier for brain to read for left-to-write stack-based cognitive
reasons.
@{ (some_expression_here) }
could be
(some_expression_here)->@
or maybe
(some_expression_here)->as_whatever
=item perl6storm #0035
Make A->B place A in string context, like => does.
That way no A()->B naughtiness.
=item perl6storm #0036
Allow
print $fh[$i] "whatever\n"
to work. Requires change to indirect object parsing.
=item perl6storm #0037
Add something like a shell_output(EXPR) alias for `STRING` so we
can do shell_output(some_fn()). Actually, this is readpipe(),
but it's not done yet. We'd like a "safe" readpipe(EXPR)
for nonshellescapes.
=item perl6storm #0040
Figure out way to do
/$e1 $e2/
safely, where $e1 might have '(foo) \1' in it.
and $e2 might have '(bar) \1' in it. Those won't work.
=item perl6storm #0041
People don't grok <>. They think
while (<>)
will localize $_, or that <> by itself will assign to it!
What can be done? Can we make
while (<>)
turn into
while (local $_ = <>)
the way they think? Would that die from 'no defaults' or
'use less "magic"'?
Can we make
<>;
turn into
$_ = <>
the way they think?
=item perl6storm #0042
Detect uses of foreach that should be while.
foreach (<FH>) { ... }
=item perl6storm #0043
Write something that spits out module dependencies. Like makedep.
A tool that sources but doesn't run? a program/module then spits
out %INC might suffice. Can we autobundle with CPAN tricks?
=item perl6storm #0044
rewrite abominable debugger code.
=item perl6storm #0045
make all utilities sterling examples of how perl *should*
be written for maintainability goals. right now, many are
hacked up protos that escaped. embarrassing to read.
=item perl6storm #0046
make open work on URLs.
=item perl6storm #0047
Radical notion: consider removing context.
Scalar vs list context makes people miserable.
=item perl6storm #0050
Radical notion: consider removing precedence.
Wrong precedence makes people miserable.
=item perl6storm #0051
Generalize the defined() magic in readdir, readline, etc.
so it isn't unique to special functions.
=item perl6storm #0052
Make "0" (more?) true so that people don't get surprised.
or
Make "0.00" (more?) false so that people don't get surprised.
=item perl6storm #0053
Make <DIRH> call readdir() just as <FILEH> calls readline().
=item perl6storm #0054
Add dup() and dup2() style stuff to give legible ways of
handling &FH and &=FH.
=item perl6storm #0055
Make it clean and easy to push input and output stream filters as
alteratives to forkopen. For example:
push_filter STDOUT, { s/^/READY/ }
is like calling program with
prog | perl -pe 's/^/READY/'
or fancy forkopen tricks. Allow ways to look at filters
on stack.
=item perl6storm #0056
Remove the complicated "extended" regex features (?...) Or rewrite
them in a non-regex spec-y way. (?{...}) and (??{...}) come to
mind.
=item perl6storm #0057
ADD MORE TOOLS!!!! Code devel and analysis tools. Maybe PPT, too.
BTW: I can't make "perlman fred" be accessible as "perl -man fred"
but I want to. That's because the an.pm pragma won't be loaded
without a read -e or script. So "fred" must exist as a path, for
all values of "fred". That's annoying.
=item perl6storm #0060
formats and html doesn't mix nicely (not wysiwig). Neither do any
hidden chars, like ESC-blah. Can we do more for generating simple
clean transparent xml?
=item perl6storm #0061
Make CPAN.pm not hate me.
=item perl6storm #0062
Can there be an anal mode that detects anything that might xU
(raise exception as unimplemented on some plats?)
=item perl6storm #0063
Core the portopath manippers. Too slow. Fix their stupid
names: catfile sucks. it doesn't `cat file`.
=item perl6storm #0064
Do something about microsoft's CRLF abomination.
=item perl6storm #0065
Make indirect objectable built-ins overloadable/overrideable/inheritable
by object type.
=item perl6storm #0066
Allow next/last/redo in do{} per C.
=item perl6storm #0067
Where's ferror()? Can we raise exceptions on them?
use io_errors; # wrong name
or maybe
STDOUT->raise_on_error
=item perl6storm #0070
Make tacit fclose stdout detect failure.
END { close STDOUT || die "close STDOUT: $!" }
But was there some horrible gotcha with this?
=item perl6storm #0071
How do you prototype split? print?
=item perl6storm #0072
"Fix" the $ prototype. No coerce on @ or %. Fix for
lists. fn($$) should permit fn(foo()) to mean fn((foo())[0,1]),
which is damned annoying to write. likewise fn(@foo[0,1]),
which freaks.
=item perl6storm #0073
kill bareword strings entirely.
=item perl6storm #0074
make all the built-ins take perl style interfaces, not C ones.
eg: notice how larry changed openlog from C to Perl. having
to write "O_blah | O_blah" hurts.
=item perl6storm #0075
Make a way for regex switches not to be single lettered.
re_match( EXPR, REGEX, FLAGS )
$gotit =
re_match($line = readline(),
qr/^foo.*bar/,
REG_ICASE | REG_NEWLINE)
But now we're back to ugly O_ or'ing. See regcomp(3).
=item perl6storm #0076
Allow ASCII characters to be specified symbolically.
Too retro? chr(NUL), chr(SOH), chr(STX). Or are those
already chars, and one would do ord(SOH) instead? Module
would suffice.
=item perl6storm #0077
make open(FH, "|cmd|") just work -- call open2 etc.
=item perl6storm #0100
add python and java sections to perltrap.
=item perl6storm #0101
Just like the "use english" pragma (the modern not-yet-written
version of "use English" module), make something for legible
fileops.
is_readable(file) is really -r(file)
note that these are hard to write now due to -s(FH)/2 style
parsing bugs and prototype issues on handles vs paths.
=item perl6storm #0102
Make "my sub" work.
Make nested subs work.
=item perl6storm #0103
Finally implement the less pragma.
use less 'memory';
etc. Right now, you can say silly things.
use less 'sillyiness';
What about use more? Or is that just no less
use less 'magic';
no more 'magic';
=item perl6storm #0104
Look at the deep magic seen in some of the examples in Camel-3's
OO and tie chapters and in perltootc. Consider what to canonize
into a simpler-to-get-at mechanism, just as plum engendered much
in perl5.
=item perl6storm #0105
Learn to count in decimal.
=back
=head1 BUGS
None. These are features.
=head1 AUTHOR
Tom Christiansen