Working with files wish list

2008-12-15 Thread Richard Hainsworth
Following the request for ideas on IO, this is my wish list for working with files. I am not a perl guru and so I do not claim to be able to write specifications. But I do know what I would like. The organisation of the IO as roles seems to be a great idea. I think that what is suggested here

Re: r24325 - docs/Perl6/Spec

2008-12-15 Thread David Green
On 2008-Dec-14, at 11:21 am, Moritz Lenz wrote: Uri Guttman wrote: how is sort ordering specified? Currently it is not specified, it defaults to infix:. If you can suggest a non-confusing way to specify both a transformation closure and a comparison method, please go ahead. how does it k

Re: Working with files wish list

2008-12-15 Thread jason switzer
On Mon, Dec 15, 2008 at 10:43 AM, Richard Hainsworth wrote: > a) I am fed up with writing something like > > open(FP, ">${fname}_out.txt") or die "Cant open ${fname}_out.txt for > writing\n"; > > The complex definition of the filename is only to show that it has to be > restated identically twice.

Re: Working with files wish list

2008-12-15 Thread Leon Timmermans
On Mon, Dec 15, 2008 at 5:43 PM, Richard Hainsworth wrote: > Following the request for ideas on IO, this is my wish list for working with > files. I am not a perl guru and so I do not claim to be able to write > specifications. But I do know what I would like. > > The organisation of the IO as rol

Re: Working with files wish list

2008-12-15 Thread Uri Guttman
> "LT" == Leon Timmermans writes: >> e) When dealing with files in directories in perl5 under linux, I need >> >> opendir(DIR,'./path/') or die "cant open ./path/\n"; >> >> my @filelist = grep { /^.+\.txt/ } readdir(DIR); >> >> I would prefer something like >> >> my Loca

Re: r24325 - docs/Perl6/Spec

2008-12-15 Thread Larry Wall
>> infix: does numeric comparison if both operands are numbers, and >> string comparison otherwise. That is a bit of an oversimplification. > "Cmp" (like "eqv") depends on the particular type, so to sort a certain > way, you should need only to coerce the values to the right type: > > @st

Re: List.end - last item and last index mixing

2008-12-15 Thread Larry Wall
On Sun, Dec 14, 2008 at 09:33:20PM +0100, Moritz Lenz wrote: : Moritz Lenz wrote: : > From S29: : > : > : =item end : > : : > : our Any method end (@array: ) is export : > : : > : Returns the final subscript of the first dimension; for a one-dimensional : > : array this simply the index of the fi

Re: What does a Pair numify to?

2008-12-15 Thread Larry Wall
On Thu, Dec 11, 2008 at 02:24:54PM +0100, TSa wrote: > HaloO, > > Carl Mäsak wrote: >> Pugs and Elf currently numify a Pair object to 2, and Rakudo currently >> dies of despair. >> >> My guess is that the semantics of Pugs and Elf falls out naturally >> form a pair being treated as a list of two el

Re: What does a Pair numify to?

2008-12-15 Thread mark . a . biggar
-- Original message -- From: Larry Wall > On Thu, Dec 11, 2008 at 02:24:54PM +0100, TSa wrote: > > My idea is to let a pair numify to whatever the value numifies to. > > Same thing with stringification. In general I think that a pair should > > hide its key as far a

Re: r24325 - docs/Perl6/Spec

2008-12-15 Thread Uri Guttman
> "LW" == Larry Wall writes: >>> infix: does numeric comparison if both operands are numbers, and >>> string comparison otherwise. LW> That is a bit of an oversimplification. LW> Any type may define infix: however it likes for two arguments of LW> its own type. It may also defin

Re: What does a Pair numify to?

2008-12-15 Thread Uri Guttman
> "mab" == mark a biggar writes: mab> -- Original message -- mab> From: Larry Wall >> On Thu, Dec 11, 2008 at 02:24:54PM +0100, TSa wrote: >> > My idea is to let a pair numify to whatever the value numifies to. >> > Same thing with stringification. I

Re: What does a Pair numify to?

2008-12-15 Thread Jon Lang
Mark Biggar wrote: > The only use case I can think of is sorting a list of pairs; > should it default to sort by key or value? But this isn't a case of numifying a Pair, or of stringifying it - or of coercing it at all. If you've got a list of Pairs, you use a sorting algorithm that's designed f

Re: What does a Pair numify to?

2008-12-15 Thread David Green
On 2008-Dec-15, at 4:18 pm, Jon Lang wrote: If you've got a list of Pairs, you use a sorting algorithm that's designed for sorting Pairs (which probably sorts by key first, then uses the values to break ties). Agreed. If you've got a list that has a mixture of Pairs and non-Pairs, I think

Re: Working with files wish list

2008-12-15 Thread Dave Whipp
Leon Timmermans wrote: On Mon, Dec 15, 2008 at 5:43 PM, Richard Hainsworth wrote: a) I am fed up with writing something like open(FP, ">${fname}_out.txt") or die "Cant open ${fname}_out.txt for writing\n"; The complex definition of the filename is only to show that it has to be restated ident

Resume from exception

2008-12-15 Thread Stephen Weeks
do { die 'some text'; say 'after the exception'; CATCH { say 'caught the exception'; ...; # what goes here? } } My proposal is to call .resume() on the exception object. Thoughts?

Re: What does a Pair numify to?

2008-12-15 Thread Moritz Lenz
Larry Wall wrote: > On Thu, Dec 11, 2008 at 02:24:54PM +0100, TSa wrote: >> HaloO, >> >> Carl Mäsak wrote: >>> Pugs and Elf currently numify a Pair object to 2, and Rakudo currently >>> dies of despair. >>> >>> My guess is that the semantics of Pugs and Elf falls out naturally >>> form a pair being

Re: Working with files wish list

2008-12-15 Thread Leon Timmermans
On Mon, Dec 15, 2008 at 6:42 PM, jason switzer wrote: > It's lazy and kinda cheating, but for small simple tasks, it gets the job > done. I'm not up to speed with the IO spec, but a sort of auto-slurp > functionality would be nice. Something to the effect: > > @data = :slurp("mydatafile.txt"); A

Re: Resume from exception

2008-12-15 Thread Leon Timmermans
On Mon, Dec 15, 2008 at 8:47 PM, Stephen Weeks wrote: > do { >die 'some text'; >say 'after the exception'; >CATCH { >say 'caught the exception'; >...; # what goes here? >} > } > > My proposal is to call .resume() on the exception object. > > Thoughts? > The spec sa

Resume from exception

2008-12-15 Thread Stephen Weeks
do { die 'some text'; say 'after the exception'; CATCH { say 'caught the exception'; ...; # what goes here? } } My proposal is to call .resume() on the exception object. Thoughts?

Re: What does a Pair numify to?

2008-12-15 Thread Moritz Lenz
mark.a.big...@comcast.net wrote: > -- Original message -- > From: Larry Wall >> On Thu, Dec 11, 2008 at 02:24:54PM +0100, TSa wrote: >> > My idea is to let a pair numify to whatever the value numifies to. >> > Same thing with stringification. In general I think that

Re: r24325 - docs/Perl6/Spec

2008-12-15 Thread Moritz Lenz
Uri Guttman wrote: >> "LW" == Larry Wall writes: > > >>> infix: does numeric comparison if both operands are numbers, and > >>> string comparison otherwise. > > LW> That is a bit of an oversimplification. > > LW> Any type may define infix: however it likes for two arguments of >

Re: r24325 - docs/Perl6/Spec

2008-12-15 Thread Mark J. Reed
On Mon, Dec 15, 2008 at 5:41 PM, Moritz Lenz wrote: > I know at least of infix:(Num $a, Num $b) (which does the same as > Perl 5's <=>) and infix:(Pair $a, Pair $b) (which does $a.key cmp > $a.key || $a.value cmp $b.value), so numbers and pairs DWIM. Hm. Rakudo doesn't let me cmp pairs at all

Re: Working with files wish list

2008-12-15 Thread jason switzer
On Mon, Dec 15, 2008 at 6:59 PM, Leon Timmermans wrote: > On Mon, Dec 15, 2008 at 6:42 PM, jason switzer wrote: > > It's lazy and kinda cheating, but for small simple tasks, it gets the job > > done. I'm not up to speed with the IO spec, but a sort of auto-slurp > > functionality would be nice.