Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
1. I don't know if it's the same reason why that particular symbol was chosen, but I find the appearance of [\ ] to be extremely representative of the "take partial results" thingie since it looks much like a triangle which is maximally evident here, given that the output "is also a triangle" but has more general sense with common reduction situations one may naturally feel psychologically at ease with, charachterized by "results that grow." (Sorry for the sloppy parliance, which I believe to be appropriate here, though.)
Indeed, language design is "sloppy", which is why almost nothing goes into the design unless there are multiple good reasons for it. But yes, the triangular visual metaphor was certainly one of the reasons for picking the backslash. Another reason is simply that very few infix operators (read "zero" in standard Perl 6) begin with backslash. Another visual or psychological consideration is that a more complicated result should be represented by a "larger" operator. A very minor consideration is that backslash tends to "escape" things into their "meta" equivalent, though what exactly is being "escaped" here is not at all clear. As for the use of square brackets on both this and the unbackslashed forms, that is justified by the cultural association with list constructors and subscripts that come from the earliest days of Perl (not to mention the fact that many functional programming languages denote lists using square brackets). And in the backslashed form, it needs something with a vertical feel on the left representing the "left margin", or we lose much of the triangular feeling, so square brackets work nicely together with backslash that way. It all adds up to an almost overwhelming feeling of necessity--which is why the language designer must also guard against adding up too many apples and then comparing them to orangutans.
2. I also wonder if the same behaviour can be obtained by means of a suitable adverb (i.e. whether one such adverb is provided!) acting on [ ]... well if adverbs do apply to meta-operators at all, that is, which I ignore altogher;
I personally believe that adverbs are more usefully applied to the base operator, and currently such adverbs must really go outside the metaoperator since metaoperators are designed to be parsed as tokens, which don't like spaces or other complicated syntax inside, or it becomes impossible to follow the longest token rule. If we consider [min] to be a single token, then what will the lexer make of something like: [min :cmp{ $^a leg $^b }]? So currently I consider metoperators to be transparent to adverbs. (And again, there are other considerations--multiplicative factors on the number of meta-modified lexemes tends to result in an explosion of possibilities for the DFA matcher that is feebly trying to figure out the next token without using up gigabytes of stack and heap.)
3. last and perhaps most importantly, given that [\ ] returns the list of partial reductions, shouldn't it for completeness also include the 0-th one? Namely, the neutral element for the bynary operation passed to it, if any. (I already can feel that the "if any" bit could prompt for a negative answer, yet I feel that a positive one would be mathematically more appropriate.)
Funny thing, I was just thinking about that myself. As usual, I can argue it all three ways:
  • Completeness demands that we return the 0th element, and consistency demands that we do so even for operations that have no neutral element, which should therefore return undef for the 0th result. The user can always throw it away.
  • The whole point of definedness is to tell you when something is defined, so rely on that to decide whether to return the neutral element. Nobody is going to go around comparing two such lists to see if they're the same, since they're potentially infinite, and even if they did, they'd want to normalize out any initial undefined element on the assumption that different ways of specifying the same sequence might or might not produce such an element.
  • Look, you two idiots, the current behavior is the sanest, insofar as, if the user really wants the stupid neutral element to come out first, all they have to do is supply it as the first argument!
So maybe we should decide this in the next PerlMonks poll. :)

In reply to Re^4: Generate the perl sequence 1, 11, 111, .... by TimToady
in thread Generate the perl sequence 1, 11, 111, .... by alih110

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 all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (4)
    As of 2018-04-26 13:16 GMT
    Find Nodes?
      Voting Booth?