Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I worked for many years with PHP and learned to live and succeed with its sometimes very "organic" structure and behaviour.

Its philosophy on work with Strings and Arrays is:
"We will copy safely everything, except in very special cases and only momentanely."
- So that a Reference on a String becomes a String again if you dont watch after it.
That results in that in Big abstracted Data Structures the Data gets copied again and once again.
Which creates Big Server Load for large texts.

Also assigning parts of Associative Array Trees would Copy the subbranch of the Tree.
Which in Big Structures would result again in heavy in-memory copying.

I found in Perl a Reference is always a Reference untill you dereference it.
Some find the Syntax weird but I think when you get it right it does exactly what you expect it to do.
It does not under the hood some hidden stuff which is not what you intended to happen!!

my $sstr = "my string"; my $rsstr = \$sstr; print "org str '$sstr'; addr: '" . \$sstr . "'\n"; $sstr .= " + my string add"; print "rs 1 str '$sstr'; addr: '" . \$sstr . "'\n"; $$rsstr .= " + add to ref"; print "rs 2 str '$sstr'; ref: '" . $rsstr . "'; addr: '" . \$sstr . "' +\n";
results in:
org str 'my string'; addr: 'SCALAR(0x22e8af8)' rs 1 str 'my string + my string add'; addr: 'SCALAR(0x22e8af8)' rs 2 str 'my string + my string add + add to ref'; ref: 'SCALAR(0x22e8 +af8)'; addr: 'SCALAR(0x22e8af8)'

When I assign a text to another text I still keep the same Address Space
And the text is not copied in-memory somewhere else, or destroyed and recreated! ... Hello Python!!

At first I felt quite bewildered by the Function Parameter Handling ...
but when you really get to dominate it it unleashes the Power of Real Polymorphism
wantarray() is another powerful tool for Polymorphism.
It gives you the right thing at the right time.

So its a really Powerful Tool to build beautiful stuff in the hands of a skilful programmer!!
So I feel also as finally being understood and given a Home.


In reply to Re: Perl, I'm coming home... by HugoNo1
in thread Perl, I'm coming home... by ait

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (6)
    As of 2020-04-07 20:23 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      The most amusing oxymoron is:
















      Results (43 votes). Check out past polls.

      Notices?