All-
This is an idea I've been chewing on for some time. RFC 14 proposes a
new syntax to open():
$FH = open dir "/usr/local/bin" or die "Badness: $!";
which is far different from the current open(). This is actually a more
flexible and consistent syntax, with a cool feature I just came across
the other day:
@file = open("</etc/motd")->readline or die;
open(">>/var/log/logfile")->print("Hello, world!");
Python, anyone? ;-)
Anyways, I was thumbing through ye ol' Camel, looking at lots of IO
functions, wondering if we shouldn't look at doing something similar to
them. For example, let's consider sys*. Currently they look like this:
sysopen(FH, $file, O_RDONLY|O_CREAT, 0644);
sysread(FH, $scalar, $length, $offset);
syswrite(FH, $scalar, $length, $offset);
sysseek(FH, $pos, $whence);
If we instead took changed these to look more like this this new open()
and other Perl functions (like print), taking advantage of indirect
objects:
$FH = sysopen $file, O_RDONLY|O_CREAT, 0644;
$scalar = sysread $FH $length, $offset;
syswrite $FH $scalar, $length, $offset;
sysseek $FH $pos, $whence;
Then these could potentially be chained as well:
sysopen($file, O_WRONLY)->syswrite($scalar, $length, $offset);
That looks like it could be useful. Of course, you wouldn't have to do
things this way:
$FH = sysopen($file, O_WRONLY) or die;
syswrite $FH $scalar, $length, $offset;
And at the very least you get a more internally consistent syntax.
Comments?
-Nate