In Perl 6, you can say which is even shorter than print, as it includes the newline character. That is in 5.10 now, too.

Looking at why the Perl was even shorter than the Lisp: not needing delimiters does not change the number of function points or size of the parse tree, just makes it easier to type. And still declaring parameters but not having to list them all at the top as well saves effort but does not eliminate the information from the source code.

In Perl 6, there are indeed more meanings, but the symbols are used more consistently and uniformly. In my article, you saw how ^$n was clearly related to 0..^$n so it registers mentally as an abbreviation, even though it concerns different operators. And the use of the caret there is obliquely related to the anchor in a regex, conceptually. Backwards, but it makes me think "relates to the endpoint", or in a character range it means "exclude".

The colon character does have a few totally different uses, but they are familiar and unconfusing: statement labels, package namespace, etc. The new use of :( ) as the delimiter for a signature is kind of arbitrary, but it makes qualified (overloaded) function names read well, and still using parens rather than some new bracket makes parameter list declarations familiar, with the : optional where a signature but not an expression is expected. A lot of milage comes from its use in "pair" syntax, but that is one use. It is pairs that have many uses, in hash items, named parameter passing, flags, etc.

So, I think that learning the meanings systemattically rather than just picking them up one at a time would enable you to better see the organization behind it. ? means boolean/bistate/optional, + means numeric, ~ means string. So $x? is an optional parameter, just as it means 0-or-1 occurances in a regex, and ?| is a boolean "or" as distinguished from +| which is a bitwise "or", and ? as a prefix converts to Bool and imposes boolean context. So, you can guess what infix ?& means, right? You might not guess what $obj.?foo() does, but the use of the symbolism is clear once you are told, and you won't forget. It optionally calls the method, if it exists on the object, but is not an error if it doesn't exist.

—John

In reply to Re^4: A Romp Around addn by John M. Dlugosz
in thread A Romp Around addn by John M. Dlugosz

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, details, 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, summary, 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.