Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

comment on

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

Your example in Python illustrates one of its major downfalls though. Certainly you can tell what's going on when you see

foo = (1, 2, 3) bar = [1, 2, 3]

What happens after that when you use foo or bar? You have to know what it is, but not only what type of data it has, but how it was created.

This was my biggest stumbling block with Python: I couldn't use the variable names I wanted and I had to remember extra things about the variables I did see. Some people don't like sigils, but I love them. People keep trying to invent them with various notations and styles of variable naming.

The trick to any language is to think like the language and forget anything you think is "reasonable" or "makes sense". Instead of fitting the language into the way that you think, just take the language for the way it is.

For instance, the length() function operates on a scalar and is documented that way. The documentation is very clear on that. It doesn't matter to me what I think it should do as long as I know what it does do. Think like that and all sorts of problems disappear. You might still be offended by some missing symmetry, but life is messy.

As for your list cases, it's not that Perl allows those cases in particular, but that Perl allows these cases:

@array = SCALAR; # promotes to ( SCALAR ); ... SCALAR, SCALAR ... # comma operator in scalar context

Once you have those general expressions, you can put them into larger expressions. It's actually more consistent to keep those because they are extensions of the same rules that allow other things (that you probably don't object to). Once you start adding special cases and exceptions, things get a lot more complicated and a lot harder to explain or remember.

They can't be syntax errors because they follow the rules. They might be candidates for warnings, however (just as an array slice with one element is legal, but generates a warning).

brian d foy <>

In reply to Re: Some Insights from a Traveler Between Languages by brian_d_foy
in thread Some Insights from a Traveler Between Languages by skyknight

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?

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

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (7)
    As of 2020-07-08 11:37 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found