On Mon Jan 31 06:17:01 2011, jesse wrote:
> I've just had a chat with Zefram about the intentionality here. He gave
> me permission to post the log:
> 09:06 <Zefram> we've got a historical problem that warn and die used to
> be pure string operations, then they got extended to handle refs in some
> situations, but the consequences weren't fully thought through
> 09:08 <Zefram> in recent changes I've been trying to build a consistent
> behaviour that mostly maintains the old behaviour on strings while also
> giving sensible behaviour on refs
> 09:08 <Zefram> stringifying a ref is usually not sensible
> 09:08 <obra> Except it's pretty standard behavior when it's being
> 09:08 <obra> which is what die and warn do by default.
> 09:08 <Zefram> yes, but that happens at the last stage, just before
> actual output
> 09:09 <obra> and, if it's stringified and has no trailing newline, we
> should be printing the line number, right?
> 09:09 <Zefram> if your exceptions are refs then there are much more
> interesting things you can do than print them
> 09:09 <obra> I don't disagree with that statement
> 09:10 <obra> But if you _are_ printing them, they should behave like
> strings have always behaved and get line numbers, no?
> 09:10 <Zefram> a ref to a blessed object has the opportunity to
> stringify to something sensible for printing
> 09:10 <obra> Right. And we have a well-accepted convention for how to
> decide whether to add line numbers once something is a string.
> 09:11 <obra> admittedly it's a kind of icky convention. but it's well
> 09:11 <Zefram> the printing behaviour is certainly up for debate, and we
> can distinguish between overloaded and non-overloaded cases if we think
> that's a good idea
> 09:11 <Zefram> but line numbers are difficult to do selectively
> 09:11 <Zefram> with a string exception, the line number gets appended
> *first*, and then the printing of an uncaught exception is just plain
> 09:12 <Zefram> with a ref, if you don't immediately stringify it to
> append the line number, then you soon lose track of the line number and
> it's not at all straightforward to apply it later just before printing
> 09:13 <obra> "It's hard to do it 'right'" is different from "We
> shouldn't even want to do that"
> 09:13 <Zefram> indeed
> 09:13 <obra> Do you feel that we shouldn't want to do that?
> 09:13 <Zefram> no, I think it's a sane desire
> 09:14 <Zefram> but afaics the best way to do it is to put that behaviour
> in the exception object
But what if the reference is not an object?
If I simply go ahead and append file and line number whenever an error
is printed, in what cases will the they be off? Will it be harmful?
My main concern is that ‘warn $foo’ is not going to work for me any more
(I use it mostly for debugging), since STDOUT and STDERR will no longer
come out in the right order, making test scripts difficult to debug.
(Yes, ‘warn "$foo"’ is another solution, but it is sufficiently annoying
that I would probably avoid upgrading instead.)