in reply to Re^2: Perl style: Arguing against three-argument join() (++join '')
in thread Perl style: Arguing against three-argument join()

we fixed the precedence of concatenation with respect to + (at your suggestion)

Thanks! And you're welcome. ;)

I like your first example. It is nice to have a "concat this list" option so compactly.

One of the things that I really learned to like about join '', ... is how low the precedence of comma is, so I don't have to put parens around even 'the ternary'. I agree that ?? :: should bind looser than concatenation but that also means I probably won't be doing direct concatenation of long lists of expressions. (Which is not a problem since there are better options.)

And the rest of the options are lovely.

Well, we fixed the indent part at least, though you're still on your own with trailing whitespace.

I'll have to review the lastest proposal on handling of indenting as I wasn't sold on some of the previous versions. But why don't you ignore trailing whitespace after the delimiter? I've decided that it is almost always better to do s/\s+$// over chomp because trailing whitespace is invisible and really deserves to be ignored. Tell me which line has the extra leading space and which one has the extra trailing space:

LINE LINE LINE LINE LINE

Sure, you can do it, if you know to look specifically for it, but it just sucks to have things that break due to such. At the very least, Perl 6 should shout "I noticed you had trailing whitespace after what would have otherwise ended your here-doc, but I didn't ignore it and that is probably why I couldn't find the end of your string". (:

Is there some value to allowing trailing whitespace to make the delimiter not the delimiter? The only value I come up with is a way to include something that looks like the delimiter in the output. I'd much prefer that be done in a much more visible way. Using such a subtle trick deserves a comment pointing out what is going on. But it is worse because (having worked even in a small company where my editor actually shows me trailing whitespace) I know that lots of editing situations don't give trailing whitespace much respect. Lots of things strip it or add it with little justification.

Surely, several of the above interpolation techniques would be better methods for including a line equal to the delimiter in the here-doc:

my $string= <<END; You end your here-doc with a line like: {''}END but be sure to prevent any trailing whitespace from sneaking in! END

What purpose am I missing?

- tye        

Replies are listed 'Best First'.
Re^4: Perl style: Arguing against three-argument join() (Perl 6)
by TimToady (Parson) on Jan 25, 2008 at 06:26 UTC
    But why don't you ignore trailing whitespace after the delimiter?
    We do. I was talking about trailing whitespace within the string.

      Oh, I agree with that decision (at least most days; simple enough to do that yourself, too). Cool.

      - tye        

Re^4: Perl style: Arguing against three-argument join() (Perl 6)
by BrowserUk (Patriarch) on Jan 25, 2008 at 03:38 UTC
    my editor actually shows me trailing whitespace

    I have my editor set to strip trailing whitespace on save for most filetypes and all 17 language filetypes I have it configured for.

    Are there any languages where trailing whitespace can be significant? (Other than the above example.)


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.