Re: Should a dirhandle be a filehandle-like iterator?

2007-05-01 Thread Smylers
John Macdonald writes: open(:file), open(:dir), open(:url), ... could be the non-dwimmy versions. If you don't specify an explicit non-dwimmy base variant, the dwim magic makes a (preferrably appropriate) choice. That'll make it easy for people porting PHP scripts to Perl 6 -- in particular

Re: Should a dirhandle be a filehandle-like iterator?

2007-05-01 Thread Luke Palmer
On 5/1/07, Smylers [EMAIL PROTECTED] wrote: What are the situations in which a programmer really needs to open something but doesn't know wether that thing is a file, a directory, or a URL? I'm still unpersuaded this is sensible default behaviour. Lots of times. It's an agnosticism, meaning

Re: Should a dirhandle be a filehandle-like iterator?

2007-05-01 Thread Larry Wall
On Tue, May 01, 2007 at 10:00:00AM +0100, Smylers wrote: : That'll make it easy for people porting PHP scripts to Perl 6 -- in : particular for those wanting to port the security hole where a CGI : parameter is used to form part of a filename opened by a script but a : malicious user can supply a

Re: Should a dirhandle be a filehandle-like iterator?

2007-04-16 Thread TSa
HaloO, Uri Guttman wrote: [..] if dirs mapped well onto file handles they would have been mapped that way long ago in the OS. in 30+ years that hasn't happened afaik. Hans Reiser is promoting just the unification of files and directories in his Reiser4 filesystem. In particular does it

Re: Should a dirhandle be a filehandle-like iterator?

2007-04-16 Thread TSa
HaloO, Jonathan Lang wrote: But then, a file handle doesn't behave exactly like standard in or standard out, either (last I checked, Perl 5 won't do anything useful if you say seek STDIN, 0, SEEK_END). How should Perl 6 behave? I guess it's possible to return a lazy list that captures STDIN

Re: Should a dirhandle be a filehandle-like iterator?

2007-04-15 Thread John Macdonald
On Fri, Apr 13, 2007 at 08:14:42PM -0700, Geoffrey Broadwell wrote: [...] -- so non-dwimmy open variants are a good idea to keep around. This could be as simple as 'open(:!dwim)' I guess, or whatever the negated boolean adverb syntax is these days open(:file), open(:dir), open(:url),

Re: Should a dirhandle be a filehandle-like iterator?

2007-04-15 Thread Larry Wall
On Sun, Apr 15, 2007 at 01:16:32PM -0400, John Macdonald wrote: : On Fri, Apr 13, 2007 at 08:14:42PM -0700, Geoffrey Broadwell wrote: : [...] -- so non-dwimmy open : variants are a good idea to keep around. : : This could be as simple as 'open(:!dwim)' I guess, or whatever the : negated

Re: Should a dirhandle be a filehandle-like iterator?

2007-04-14 Thread Yuval Kogman
Why bother, actually, when it can just be a lazy list... Opendir and closedir are very oldschool, and can be retained for whatever technical detail they are needed, but in most modern code I think that: for readdir($dir_name) { .say } should work as well. The act of opening a directory

Re: Should a dirhandle be a filehandle-like iterator?

2007-04-14 Thread Steve Peters
On Fri, Apr 13, 2007 at 07:43:23PM -0500, brian d foy wrote: As I was playing around with dirhandles, I thought What if... (which is actualy sorta fun to do in Pugs, where Perl 5 has everything documented somewhere even if nobody has read it). My goal is modest: explain fewer things in the

Re: Should a dirhandle be a filehandle-like iterator?

2007-04-14 Thread Smylers
Jonathan Lang writes: Also: why distinguish between open and opendir? If the string is the name of a file, 'open' means open the file; if it is the name of a directory, 'open' means open the directory. Many programs open a file from a name specified by the user. Even if Copenfile existed,

Re: Should a dirhandle be a filehandle-like iterator?

2007-04-13 Thread Jonathan Lang
brian d foy wrote: As I was playing around with dirhandles, I thought What if... (which is actualy sorta fun to do in Pugs, where Perl 5 has everything documented somewhere even if nobody has read it). My goal is modest: explain fewer things in the Llama. If dirhandles were like filehandles,

Re: Should a dirhandle be a filehandle-like iterator?

2007-04-13 Thread Geoffrey Broadwell
On Fri, 2007-04-13 at 19:00 -0700, Jonathan Lang wrote: Please. I've always found the opendir ... readdir ... closedir set to be clunky. Also: why distinguish between open and opendir? If the string is the name of a file, 'open' means open the file; if it is the name of a directory,

Re: Should a dirhandle be a filehandle-like iterator?

2007-04-13 Thread Jonathan Lang
Geoffrey Broadwell wrote: Jonathan Lang wrote: Also: why distinguish between open and opendir? If the string is the name of a file, 'open' means open the file; if it is the name of a directory, 'open' means open the directory. If it's the name of a pipe, it opens the pipe. And so on. As

Re: Should a dirhandle be a filehandle-like iterator?

2007-04-13 Thread Uri Guttman
JL == Jonathan Lang [EMAIL PROTECTED] writes: JL Please. I've always found the opendir ... readdir ... closedir set JL to be clunky. JL Also: why distinguish between open and opendir? If the string is JL the name of a file, 'open' means open the file; if it is the name of JL a

Re: Should a dirhandle be a filehandle-like iterator?

2007-04-13 Thread Jonathan Lang
Uri Guttman wrote: JL == Jonathan Lang [EMAIL PROTECTED] writes: JL Please. I've always found the opendir ... readdir ... closedir set JL to be clunky. JL Also: why distinguish between open and opendir? If the string is JL the name of a file, 'open' means open the file; if it is

Re: Should a dirhandle be a filehandle-like iterator?

2007-04-13 Thread Uri Guttman
JL == Jonathan Lang [EMAIL PROTECTED] writes: JL Well, I did suggest that openfile and opendir exist alongside JL open, with openfile being more akin to Perl 5's open or JL sysopen, and open being a bit more dwimmy. JL But in general, most of the differences that you mention are things