On Thu, 26 Feb 2009, David Green wrote:
On 2009-Feb-26, at 7:46 pm, Timothy S. Nelson wrote:
# Object has .print and .say.
[...]
My question is, would we be better off having the string conversion routine
for arrays worry about the input/output record/field separators, rather
than the IO object? The downside I can see is that you couldn't have
separate separators for different IO objects; you'd have to code specially
if you wanted that functionality.
What about having separators that exist in different scopes? Objects could
define their own separators, or if they don't, default to those defined on
the IO item, which in turn could default to whatever is defined in the
current block, working outwards from there.
This is interesting, but I think separators should probably just be
defined in one place, whether this be Object, scopes, or IO.
This may also mean we don't need .print and .say methods on Object. Am I
missing the reason why such methods would exist, other than to allow certain
objects to define their own special distinctions between printing and saying
(presumably because simply adding a newline wouldn't be suitable)?
In that case, all the object would need to do is to define its own
record-separator.
I would've suggested this, but this seems to be widely used. The
specs write things like:
(for 1..100 { $_ if .prime}).say
I suspect 99% of objects will use the .print and .say methods from
Object, and simply override stringification if they need to change things.
:)
---------------------------------------------------------------------
| Name: Tim Nelson | Because the Creator is, |
| E-mail: wayl...@wayland.id.au | I am |
---------------------------------------------------------------------
----BEGIN GEEK CODE BLOCK----
Version 3.12
GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V-
PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y-
-----END GEEK CODE BLOCK-----