in reply to Re^2: Why does "flush filehandle" work? (indirect object)
in thread Why does "flush filehandle" work?

Well obviously built-ins for print and say are needed for the non-method use.

I remembered patching IO::Handle::say , but this will only affect say STDOUT "text" if feature "say" is not activated. Otherwise it's not working.¹

This means the print and say built-ins are only mimicking the indirect object notation and completely ignoring the methods.

Kind of disappointing². :/

But seems like technically you are right.

(While I still remember being able to make it work, I can't find the thread anymore)

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

¹) NB STDOUT->say() will always call the patched version

²) because say $FH and $FH->say will diverge after patching say

Replies are listed 'Best First'.
Re^4: Why does "flush filehandle" work? (indirect object)
by etj (Priest) on Jan 30, 2025 at 00:12 UTC
    But seems like technically you are right
    This may be the least graceful way of acknowledging being under-correct that I have ever seen. Well done*.
Re^4: Why does "flush filehandle" work? (indirect object)
by ikegami (Patriarch) on Jan 30, 2025 at 03:06 UTC

    But seems like technically you are right.

    And you were under-correct. (Thanks etj!)

    If print SCALAR LIST, print BAREWORD LIST and print BLOCK LIST were method calls,

    • The first operand would have to refer to an object or class.
    • A method would be called.
    • Inheritance would come into play.
    • CORE overrides wouldn't come into play.
    • no feature qw( indirect ); would come into play.
    • They would be parsed differently.
    • etc.

    print, say, map, grep and sort are not indirect method calls despite having name BAREWORD and name BLOCK calling conventions like indirect method calls. They are not technically different; they are very different.

      IMHO this is all a result of piggybacking OO onto Perl 4 syntax° which already had filehandles, and I'm disappointed about the bad implementation.

      The fact that print $fh and $fh->print can divert is a serious design flaw in my books.

      Even if print is implemented as a special cased monster for backwards compatibility, print $fh should do the same like $fh->print

      Let me reiterate "you are technically correct" or in my words Perl is buggy here.

      > And you were under-correct. (Thanks etj!)

      Regarding etj, he hasn't contributed anything technical yet and has obviously beef with me.

      I have no problems admitting when I'm wrong, this is just a very ugly case to describe how wrong everything is.

      But if we want to get personal, you are the one notorious to fight till Re:50+ before admitting to be wrong or compromising that views may differ.

      > CORE overrides wouldn't come into play.

      ORLY? Please humor me and demonstrate a core override of print and say.

      They are not possible, exactly because of their weird implementation.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      see Wikisyntax for the Monastery

      °) For the record, I tried finding a Perl 4 language reference but failed, any hints/links?

      You're welcome!