Re: The ,= operator

2020-12-07 Thread Ralph Mellor
> > @fib[1, 5, 10..15, 20] > (1 8 (89 144 233 377 610 987) 10946) > ^ > > Why??? As Joe noted in his last email: > remember, back in perl-land the default behavior is to flatten, > in raku ... by default [raku is] oriented toward building up > complex structures like

Re: The ,= operator

2020-12-07 Thread Aureliano Guedes
I didn't understood > my @fib = 1,1, * + * … *; [...] > @fib[1] 1 > @fib[5] 8 > @fib[1..5] (1 2 3 5 8) *> @fib[1, 5, 10..15, 20](1 8 (89 144 233 377 610 987) 10946)* * ^* Why??? On Mon, Dec 7, 2020 at 2:27 AM William Michels via perl6-users < perl6-us...@perl.org>

Re: The ,= operator

2020-12-06 Thread William Michels via perl6-users
On Sun, Nov 29, 2020 at 6:38 PM Ralph Mellor wrote: > > Zen slicing as a possible way of 'de-containerizing' : > > https://docs.raku.org/language/subscripts#index-entry-Zen_slices > > A zen-slice only affects the single reference it's applied to. > > And it is a no op when applied to anything oth

Re: The ,= operator

2020-12-06 Thread Joseph Brenner
ToddAndMargo via perl6-users wrote: > I am a little late to this conversation, but `,=` > looks a lot like `push` to me. Yes that was my first impression, if you read ahead a bit in the discussion you'll see it explained. In summary: the = shortcuts all work in a precisely parallel way, so @r

Re: The ,= operator

2020-12-05 Thread ToddAndMargo via perl6-users
Hi All, I am a little late to this conversation, but `,=` looks a lot like `push` to me. Am I missing something? -T

Re: The ,= operator

2020-11-30 Thread Joseph Brenner
William Michels wrote: > Joe, what would you expect the code below to produce? > %h<> ,= c => 3; > @a[] ,= 'd'; Well *I* expect it to error out, but that's my p5 brain talking. The Raku approach is if you ask for nothing it gives you everything, so an empty index like that essentially doesn'

Re: The ,= operator

2020-11-29 Thread Ralph Mellor
> Ralph Mellor wrote: > >> > @r = @r , 'd'; > >> > >> There isn't anything very useful in this behavior though, is there? > > Just to be clear, I wasn't saying I didn't think circular references > should be forbidden, I just spe

Re: The ,= operator

2020-11-29 Thread Ralph Mellor
> Zen slicing as a possible way of 'de-containerizing' : > https://docs.raku.org/language/subscripts#index-entry-Zen_slices A zen-slice only affects the single reference it's applied to. And it is a no op when applied to anything other than a `Scalar`. So it'll have no effect when applied direct

Re: The ,= operator

2020-11-29 Thread William Michels via perl6-users
On Sun, Nov 29, 2020 at 9:16 AM Joseph Brenner wrote: > > William Michels wrote: > >> > "Perhaps more importantly, what improvement do you propose?" > > > > Apologies for top-posting, but what immediately comes to my mind upon > > encountering the creation of a self-referential (circular/infinite

Re: The ,= operator

2020-11-29 Thread Joseph Brenner
William Michels wrote: >> > "Perhaps more importantly, what improvement do you propose?" > > Apologies for top-posting, but what immediately comes to my mind upon > encountering the creation of a self-referential (circular/infinite) > object is proverbially 'going-down-a-level' and trying again. S

Re: The ,= operator

2020-11-29 Thread Joseph Brenner
Joseph Brenner wrote: > Just to be clear, I wasn't saying I didn't think circular references should be forbidden, Sorry about the double-negative. It could use another "not" to triple it.

Re: The ,= operator

2020-11-29 Thread Joseph Brenner
s there? > > Yes. > > Here are some relevant results from a search for "self referential" in > the #perl6 and #raku logs. Just to be clear, I wasn't saying I didn't think circular references should be forbidden, I just specifically meant that you weren't likely

Re: The ,= operator

2020-11-29 Thread Parrot Raiser
y very desirable. It's so > much easier to teach and learn a rule like "op= has the same effect, > whatever "op" is; it takes the variable on the LHS, applies the > operator to its contents and the other value on the RHS, then puts the > result back on the LHS side.

Fwd: The ,= operator

2020-11-29 Thread Parrot Raiser
Having a consistent ("regular", in the linguistic sense), structure for something like the op= form is obviously very desirable. It's so much easier to teach and learn a rule like "op= has the same effect, whatever "op" is; it takes the variable on the LHS, applies th

Re: The ,= operator

2020-11-28 Thread William Michels via perl6-users
> > "Perhaps more importantly, what improvement do you propose?" Apologies for top-posting, but what immediately comes to my mind upon encountering the creation of a self-referential (circular/infinite) object is proverbially 'going-down-a-level' and trying again. So I tried 1. 'decontainerizing'

Re: The ,= operator

2020-11-28 Thread Ralph Mellor
> > @r = @r , 'd'; > > Okay, that makes sense. So the circular reference I thought I > was seeing is really there, and it's working as designed. > > There isn't anything very useful in this behavior though, is there? Yes. Here are some relevant results from a search for "self referential" in the

Re: The ,= operator

2020-11-27 Thread Joseph Brenner
About the documentation in general... > > that particular pair-input syntax is my least favorite. > > Flipping around the order of key and value when the value is a numeric...? > > > > And it isn't needed to demo the operator, any pair input syntax works. > >

Re: The ,= operator

2020-11-27 Thread Joseph Brenner
First off, much thanks to Ralph Mellor for his detailed explanations. Ralph Mellor wrote: > @r ,= 'd'; > > The above expands to: > > @r = @r , 'd'; Okay, that makes sense. So the circular reference I thought I was seeing is really there, and it's working as designed. There isn't anything very

Fwd: The ,= operator

2020-11-27 Thread Ralph Mellor
I accidentally sent this privately. -- Forwarded message - From: Ralph Mellor Date: Fri, Nov 27, 2020 at 6:06 PM Subject: Re: The ,= operator To: William Michels > I can reproduce your results on Rakudo_2020.10, but I'm afraid I don't > have much more

Re: The ,= operator

2020-11-27 Thread Ralph Mellor
that value "inside" the `Scalar` container. This is what it means to "assign to" a `Scalar`. In all other cases the compiler passes *a list of values* at runtime to the receiver. What that receiver does with the list depends on the receiver's class. > th

Re: The ,= operator

2020-11-27 Thread William Michels via perl6-users
Hi Joe, I can reproduce your results on Rakudo_2020.10, but I'm afraid I don't have much more to say about the ",=" operator since I'm unfamiliar with it. Do the "docs" page(s) make more sense changing the phrase "class-dependent" behavior to "ha

The ,= operator

2020-11-26 Thread Joseph Brenner
I was going through the operator list in the documentation the other day, and I noticed this one: postfix ,= Creates an object that concatenates, in a class-dependent way, the contents of the variable on the left hand side and the expression on the right hand side: my %a = :11a

Re: The "=" operator and context

2012-04-03 Thread Daniel Carrera
On 3 April 2012 20:38, Moritz Lenz wrote: > which version of Rakudo are you using? (I've tried on the last > development version from git) Rakudo Star 2012.02 % perl6 --version This is perl6 version 2012.02 built on parrot 4.1.0 revision 0 >> Hmm...  So you'd have to mess with the STORE method

Re: The "=" operator and context

2012-04-03 Thread Moritz Lenz
On 04/03/2012 08:24 PM, Daniel Carrera wrote: > On 3 April 2012 17:24, Moritz Lenz wrote: >> You can, very nearly. You just need to write >> >> my @vec is Vector; >> >> because you really want to change the type of the container, not just of the >> contents (my Vector @vec would be an array contai

Re: The "=" operator and context

2012-04-03 Thread Daniel Carrera
On 3 April 2012 17:24, Moritz Lenz wrote: > You can, very nearly. You just need to write > > my @vec is Vector; > > because you really want to change the type of the container, not just of the > contents (my Vector @vec would be an array containing Vector objects). Another option might be to jus

Re: The "=" operator and context

2012-04-03 Thread Moritz Lenz
ntactic. In the case of list assignment, @foo.STORE(1..10) is called under the hood. For example, imagine hat I create a 'Vector' class to do basic linear algebra. Imagine that it works this way: my @vec = Vector.new( 1,2,3,4 ) @vec * 3 # => ( 3,6,9,12 ) In other words, the &#

The "=" operator and context

2012-04-03 Thread Daniel Carrera
is way: my @vec = Vector.new( 1,2,3,4 ) @vec * 3 # => ( 3,6,9,12 ) In other words, the '*' operator is overloaded to behave like scalar x vector multiplication in linear algebra. I was thinking that it would be neat if instead you could do this: my Vector @vec; @vec = 1,2,3,4; @v

Re: Catching exceptions with the // operator

2008-08-08 Thread TSa
HaloO, Yaakov Belch wrote: I believe that ---from a usability point of view--- it's very important to: * classify exceptions by "severity" or other characteristics, * provide named adverbs/pragmas to modify default CATCH handlers, * make them configurable by "outer scopes". > [..] The program

Re: Catching exceptions with the // operator

2008-08-08 Thread Yaakov Belch
Thank you very much! my $bill = try ack() orelse try thpp() orelse do ppt(); This certainly does what I asked for, and it's short enough (even if we need to add a few brackets). Yes, the basic problem with the proposal is that it catches all exceptions willy nilly and u

Re: Catching exceptions with the // operator

2008-08-06 Thread John M. Dlugosz
Yaakov Belch perl6-at-yaakovnet.net |Perl 6| wrote: Let me explain why this is useful and why I think this is "the right thing": First of all, it provides a very light-weight exception handling using well-known ideoms like: $file_content=read_file($filename) // $default_value; compute_statist

Re: Catching exceptions with the // operator

2008-08-06 Thread Larry Wall
C doesn't handle the type of exception thrown, should : C be called immediately, or only if C. so how do i signify that my exception has been : handled, and that i can now assign a default value to C<$bill>? : : in my mind, this strays too far from the meaning of C and adds : ambigu

Re: Catching exceptions with the // operator

2008-08-06 Thread Paul Seamons
> in my mind, this strays too far from the meaning of C and adds > ambiguity that makes the operator unusable. perhaps there's room for > an operator that gives some sugar for > > my $bill = try { ack() CATCH { thpp() } }; > > but to me that code is concise enou

Re: Catching exceptions with the // operator

2008-08-06 Thread jerry gay
On Wed, Aug 6, 2008 at 8:58 AM, Yaakov Belch <[EMAIL PROTECTED]> wrote: > In a little language that I wrote some time ago, I found it very useful to > let the // operator catch exceptions: > > f(x) // g(y) does: > * If f(x) returns a defined value, use this value. > * If f

Catching exceptions with the // operator

2008-08-06 Thread Yaakov Belch
In a little language that I wrote some time ago, I found it very useful to let the // operator catch exceptions: f(x) // g(y) does: * If f(x) returns a defined value, use this value. * If f(x) returns an undefined value, use the value of g(x) instead. * If f(x) throws an exception, catch and keep

[perl #53100] The ** operator like in ** ',' is missing from PGE. would be a nice feature for writing parsers and minimizing rules

2008-04-20 Thread via RT
# New Ticket Created by Stephane Payrard # Please include the string: [perl #53100] # in the subject line of all future correspondence about this issue. # http://rt.perl.org/rt3/Ticket/Display.html?id=53100 > I will give it a try but does not promise anything. -- cognominal stef

[Semi-OT] The ^^ operator

2004-03-18 Thread Brent 'Dax' Royal-Gordon
Did anybody notice that Larry has slipped in an anime smiley operator? Between "^^" and the recent musing about "wa"... On a closely related note, how long do you think it'll be before someone puts this on CP6AN? class n { method n() is classmethod {# Or whatever it turns out to