develooper Front page | perl.perl6.users | Postings from November 2020

Re: The ,= operator

Thread Previous | Thread Next
From:
Ralph Mellor
Date:
November 30, 2020 02:41
Subject:
Re: The ,= operator
Message ID:
CAPLR5Scb8ZZFrY-89FFyA0Vmr4Wem4KwT3UimQ5JxuZBprb_MA@mail.gmail.com
>  Ralph Mellor <ralphdjmellor@gmail.com> 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 specifically meant that you weren't likely
> to want the ",=" operator to create them.

Ah. OK.

My guess is that when they *are* constructed, they're almost always
constructed using `=` and `,`. And that would lead to the same result
and display that use of `,=` does. After all, the latter is just shorthand
for the former.

> But then really, I'm not too likely  ",=" for appending additional array
> elements, I'm more likely to reach for .push.

Indeed. (Or .append.)

My tentative strawman proposal based on discussion thus far is:

* The doc page showing use of `,=` with a hash might benefit from
a parenthetical remark that push/append is the right tool to use with
positionals rather than `,=` because, unlike associatives, for which
flattening is the only sensible semantics, positionals instead default
to *not* flattening (so they more easily retain structure, which is what
most folk want most of the time).

* Liz's "thoughts welcome" is applicable to all things, and in particular
to the gist of self-referential data.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About