Re: RFC 51 (v2) Angle brackets should accept filenames a
[email protected] (Chaim Frenkel) 09 Aug 2000 16:23:12 -0400
| Newsgroups | perl.perl6.language.io |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "JE" == Jon Ericson <[email protected]> writes: JE> Chaim Frenkel wrote: >> What does >> >> $foo = <"filename">; # 1 >> $bar = <"another">; >> $gaz = <"filename>; # 2 JE> ^ add " here >> Does #2 get the second line or the first? JE> $gaz contains the second line. Otherwise this: JE> while (<'filename'>){print;}; JE> won't work. This gets a little hairy, I admit. Actually they are two different problems. The while loop can be internally replaced with an open, while, close. Or with a local version of a filehandle that _only_ is valid at that line or block. The same string being the same file is more of an issue. Just consider having two different modules/packages, opening the same file. You _might_ want them to have different meanings. >> Can the <> contain a function? JE> Of course. Stick any old list there. >> Your example seems to indicate that >> it can. But if it is hard for me to parse visually, I'm not sure >> how easy it would be for the parser. JE> To my eye angle brackets signify input. Perhaps but what about Damien's proposal if ($x < foo() > $y) { ... } Remember perl has to intuit among, < file >, <, <= , !<, etc. I'd rather not add to the load. However, there is the concept of lazy evaluation that has been proposed so you might be able to get your way. @foo = lazy grep .... while( <@foo> ) { ... } However, I'd rather you limit your proposal to being valid only at a single spot in the code. Similar to the .., and ... toggle operators. So that different usages of the same string mean different filehandles. I'm not quite in favor of the proposal, since DWIMing the meaning of a string doesn't seem to be clear. Perhaps you should go through all of the possiblities. You will also have to consider, if the string is to be put through magic open? or strictly valid file and directory names. What about the proposed URL intuiting? Should that be accepted? <chaim> -- Chaim Frenkel Nonlinear Knowledge, Inc. [email protected] +1-718-236-0183