Mutating methods

2004-03-10 Thread Juerd
Perlists, In Perl 5, lc, lcfirst, quotemeta, uc and ucfirst don't mutate. chomp and chop do mutate. I imagine these will all be methods in Perl 6: $foo.lc $foo.quotemeta $foo.chomp I'd like a mutating version of lc, and a non-mutating version of chomp. With some nice syntax, if poss

Re: Mutating methods

2004-03-10 Thread Luke Palmer
Juerd writes: > Perlists, > > In Perl 5, lc, lcfirst, quotemeta, uc and ucfirst don't mutate. > chomp and chop do mutate. > > I imagine these will all be methods in Perl 6: > > $foo.lc > $foo.quotemeta > $foo.chomp > > I'd like a mutating version of lc, and a non-mutating version of

Re: Mutating methods

2004-03-10 Thread Brent \"Dax\" Royal-Gordon
Luke Palmer wrote: The reason we couldn't just decalre it with C is because its right hand side is not a usual expression. Isn't that what macros are for? macro infix:.= ($lhs, $rhs) is parsed(//) { return Perl::assignment_expression.new( lhs => $lhs, rhs => Per

Re: Mutating methods

2004-03-10 Thread Larry Wall
On Wed, Mar 10, 2004 at 05:39:33PM +0100, Juerd wrote: : Perlists, : : In Perl 5, lc, lcfirst, quotemeta, uc and ucfirst don't mutate. : chomp and chop do mutate. : : I imagine these will all be methods in Perl 6: : : $foo.lc : $foo.quotemeta : $foo.chomp : : I'd like a mutating ver

Re: Mutating methods

2004-03-10 Thread Larry Wall
On Wed, Mar 10, 2004 at 11:19:52AM -0800, Brent Dax Royal-Gordon wrote: : Luke Palmer wrote: : >The reason we couldn't just decalre it with C is because its : >right hand side is not a usual expression. : : Isn't that what macros are for? : : macro infix:.= ($lhs, $rhs) is parsed(//) { Metho

Re: Mutating methods

2004-03-10 Thread Luke Palmer
Larry Wall writes: > On Wed, Mar 10, 2004 at 11:19:52AM -0800, Brent Dax Royal-Gordon wrote: > : Luke Palmer wrote: > : >The reason we couldn't just decalre it with C is because its > : >right hand side is not a usual expression. > : > : Isn't that what macros are for? > : > : macro infix:.=

Re: Mutating methods

2004-03-10 Thread Damian Conway
Luke Palmer wrote: Hooray! That was something I had been worried about. But C doesn't seem to fit visually. What's "questionable" about that? Nothing questionable, but everything hypothetical: captures to the $?foo hypothetical variable Damian

Re: Mutating methods

2004-03-10 Thread Larry Wall
On Wed, Mar 10, 2004 at 12:42:00PM -0700, Luke Palmer wrote: : > (Also, these days you have to say to collect the results into $0.) : : Hooray! That was something I had been worried about. : : But C doesn't seem to fit visually. What's "questionable" about : that? It's questionable insofar as

Re: Mutating methods

2004-03-10 Thread Luke Palmer
Larry Wall writes: > On Wed, Mar 10, 2004 at 12:42:00PM -0700, Luke Palmer wrote: > : I can think of a couple that I like better: > : > : <^foo> > : <*foo> > : > : <^foo> is my favorite at the moment (even though <*foo> is more > : visually pleasing), because it looks like it's transferri

Re: Mutating methods

2004-03-10 Thread Damian Conway
Luke Palmer wrote: I understand the association with C<$?foo>. But most of the time, when I'm writing a grammar, I'm catching these rules in order to stick them in the parse tree, not to do tests on them later on in the rule. The very essence of rules is hypotheticality, where nothing is permane

Re: Mutating methods

2004-03-10 Thread Brent \"Dax\" Royal-Gordon
Damian Conway wrote: / $foo:=(abc) $bar:=(def) / Am I misreading, or are you suggesting that $foo may contain 'abc' after running this example, even if the match wasn't successful? -- Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker Oceania has always been at war with Easta

Re: Mutating methods

2004-03-10 Thread Damian Conway
Brent "Dax" Royal-Gordon wrote: / $foo:=(abc) $bar:=(def) / Am I misreading, or are you suggesting that $foo may contain 'abc' after running this example, even if the match wasn't successful? No. I re-checked with Larry this morning and he confirmed that all bindings in rules only "stick" if

RE: Mutating methods

2004-03-10 Thread matt
I was thinking along the lines of... String $foo = "hello"; $foo.scramble! print "$foo\n"; $foo = "hello" print $foo.scramble ~ "\n"; print $foo; OUTPUT (or close): elhlo hloel hello Also, along these same things.. is there a way to apply a method to all variables/objects of a certain type (e.g.

Re: Mutating methods

2004-03-10 Thread Larry Wall
On Wed, Mar 10, 2004 at 10:46:05PM -0500, matt wrote: : I was thinking along the lines of... : : String $foo = "hello"; : $foo.scramble! That would be $foo.=scramble in the current scheme of things. : print "$foo\n"; : $foo = "hello" : print $foo.scramble ~ "\n"; : print $foo; : : OUTPUT (or cl

RE: Mutating methods

2004-03-10 Thread Austin Hastings
> -Original Message- > From: Damian Conway [mailto:[EMAIL PROTECTED] > Sent: Wednesday, 10 March, 2004 09:48 PM > To: [EMAIL PROTECTED] > Subject: Re: Mutating methods > > > Brent "Dax" Royal-Gordon wrote: > > >> / $foo:=(abc) $bar:=(def) / > > > > Am I misreading, or are you suggesti

Re: Mutating methods

2004-03-10 Thread Larry Wall
On Thu, Mar 11, 2004 at 01:09:59AM -0500, Austin Hastings wrote: : : : > -Original Message- : > From: Damian Conway [mailto:[EMAIL PROTECTED] : > Sent: Wednesday, 10 March, 2004 09:48 PM : > To: [EMAIL PROTECTED] : > Subject: Re: Mutating methods : > : > : > Brent "Dax" Royal-Gordon wrote