On Thu, May 05, 2005 at 10:14:34AM +0300, Gaal Yahas wrote:
: On Wed, May 04, 2005 at 11:44:58PM -0700, Larry Wall wrote:
: > : How do I open a file named "-"?
: > 
: > Um, depending on what you mean, and whether we continue to support
: > the '=' pseudofile, maybe:
: > 
: >     $fh = io("-");
: >     $fh = open "-";
: >     $fh = $name eq '-' ?? $*IN :: open $name;
: My concern is again with magic control. I've no gripes with the first
: or last of those, but I think the second should not be allowed by
: default. There has to be a safe mode for opening a file and knowing
: that's what you're opening: not a pipe, not stdio (hence there are places
: I can't permit myself to use #1). But as your third example suggests,
: never allowing open "-" will make unixish tools tedious to write, so
: maybe we need something like
:     getopt(...);
:     $fh = open $in, :allowstdio;
: (only named more eloquently).

I think that, as with various other parts of Perl 6, we can try
to sweep all the dwimmery into one spot so that it can be easily
recognized and/or avoided.  And the default "open" is not the place
for dwimmery.  It should just open an ordinary file by default.
The place for all that dwimmery is probably io().  In contrast, open
should be a multisub/method that gives you exact semantics depending
on the invocant.  In fact, io() might just be short for IO.open(),
which specifically requests dwimmery, just as URI.open() specifically
requests URI interpretation.  And bare open() is probably short for
File.open().  (Though for io(), it's probable that it actually does the
open lazily depending on usage, since that's part of its dwimmery.)


Reply via email to