Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: A list assignment gotcha (Updated)

by LanX (Cardinal)
on Jul 30, 2020 at 14:48 UTC ( #11120069=note: print w/replies, xml ) Need Help??


in reply to Re^2: A list assignment gotcha
in thread Not understanding 2 sentences in perldoc

Hi

> A bit trickier than I originally thought.

I was about to update that one needs :lvalue and returning a tied scalar then.

Surprised you made it without tie , my last use case must have been different than. :)

update

> You can use [3, 2, 1] on the RHS, as well.

Nice! :)

> on both the listifier and constructor.

Genius!!! that's how you avoided using Tie::Scalar! :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^4: A list assignment gotcha (Updated)
by jcb (Vicar) on Jul 31, 2020 at 01:32 UTC

    Great work by both of you, and the possible syntax tricks nicely show TIMTOWTDI, but the original motive for trying LIST += LIST was a hoped-for performance gain from the interpreter completing the whole set in one opcode, instead of add...add...add....

    I suspect that overloaded objects like this will cause problems if used in inner loops. :-) Neat tricks, though...

      > will cause problems if used in inner loops

      performance won't be great unless implemented in XS.

      But that's the way I would implement new features in Perl.

      • a nice syntactic sugar which does the job in pure Perl and stays fully backwards compatible.
      • speed it up in XS for newer versions
      • if it becomes popular, consider including it into CORE.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        Even with an XS implementation, you will still have the dispatch overhead for the overloaded operator. Eventually including it in core perl would allow the parser to resolve the dispatch at compile-time, but until then I wonder how long the list needs to be to make up that difference?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11120069]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2021-01-17 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?