Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Passing a ref to warn doesn't append file and line
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
"Father Chrysostomos via RT"  
View profile  
 More options Feb 6 2011, 4:59 pm
Newsgroups: perl.perl5.porters
From: perlbug-follo...@perl.org ("Father Chrysostomos via RT")
Date: Sun, 06 Feb 2011 13:59:47 -0800
Local: Sun, Feb 6 2011 4:59 pm
Subject: [perl #77384] Passing a ref to warn doesn't append file and line
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
> printed
> 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
> accepted
> 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
> printing
> 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.)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.