print、put 和 say 之间的区别?

Difference between print, put and say?

在 Perl 6 中,printputsay 有什么区别?

我可以看出 print 5 有何不同,但 put 5say 5 看起来是一样的。

put $a 就像 print $a.Str ~ “\n”
say $a 就像 print $a.gist ~ “\n”

put 更具计算机可读性。
say 更易于阅读。

put 1 .. 8 # 1 2 3 4 5 6 7 8
say 1 .. 8 # 1..8

详细了解 .gist here

————
更准确地说,putsay 附加输出文件句柄的 nl-out 属性的值,默认情况下为 \n。不过,您可以覆盖它。感谢 Brad Gilbert 指出这一点。

Handy Perl 6 常见问题解答:How and why do say, put and print differ?

The most obvious difference is that say and put append a newline at the end of the output, and print does not.

But there's another difference: print and put converts its arguments to a string by calling the Str method on each item passed to, say uses the gist method instead. The gist method, which you can also create for your own classes, is intended to create a Str for human interpretation. So it is free to leave out information about the object deemed unimportant to understand the essence of the object.

...

So, say is optimized for casual human interpretation, dd is optimized for casual debugging output and print and put are more generally suitable for producing output.

...