in reply to Re^2: curly braces around a lexical file handle
in thread curly braces around a lexical file handle

$a.print: $b;   # treat $a as a file handle
Good thing you added the comment. I would have taken $a.print to mean the value of $a is to be printed out -- probably to handle $b.

Replies are listed 'Best First'.
Re^4: curly braces around a lexical file handle
by moritz (Cardinal) on May 31, 2010 at 13:08 UTC
    Well, it's new syntax, so it's no surprise you need to learn somthing about it.

    It becomes clearer if you think more about: A method call (and $a.print: $b is a method call) can have one invocant, but many ordinary arguments. Which one is special, the invocant or the first, ordinary argument?

    When you see

    $a.print: $b, $c, $d, $d;

    Do you still think that $a is printed to file handle $b? Or to all of the arguments, all treated as file handles?

    That would be a very bad huffman coding...

      That would be a very bad huffman coding...

      Only if you think $o.print: $fh; precludes $fh.print: $o; from existing. There's no reason both can't exist. That said, I would call the former "dump" rather than "print".

      $o.dump; $o.dump: $fh;