Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^4: Undocumented join() feature, now defunct? (++$i)

by Loops (Curate)
on Oct 30, 2014 at 03:12 UTC ( [id://1105577]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Undocumented join() feature, now defunct? (++$i)
in thread Undocumented join() feature, now defunct?

Yes, okay I see that. To expect otherwise would require the creation of a temporary every time you access a scalar more than once in your code. One implication of executable code being well defined as the first parameter to join, is that the following will fix johngg's code to work on old and new versions of Perl:

<c>say join $inc+0, @arr;

Where the creation of a temporary to hold the result is implied.

  • Comment on Re^4: Undocumented join() feature, now defunct? (++$i)

Replies are listed 'Best First'.
Re^5: Undocumented join() feature, now defunct? (++$i)
by FloydATC (Deacon) on Oct 30, 2014 at 09:22 UTC

    I think you've pointed out a very cool way join() and tie() could have been used together had this been a known/documented behavior of join() from the beginning and one could even imagine join accepting a {} block or a sub reference to determine how $a and $b should be joined together.

    Unfortunately, there's no indication that this was intended to be possible and so the documentation should IMHO clearly point out exactly what the limitations of join() are, and that this behaviour is broken in certain versions.

    OR, they could unoptimize the code and make it official from some future version of Perl while pointing out clearly that although this behaviour can be seen in certain earlier versions it can't be relied upon until this exact version.

    After all, tie() is a part of Perl and it's not so unreasonable to try and use it to pull off magic tricks. That's what it's there for, like it or not.

    -- FloydATC

    Time flies when you don't know what you're doing

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-18 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found