__PACKAGE__->add_columns( pid => { data_type => "CHAR", default_value => "", is_nullable => 0, size => 15, }, title => { data_type => 'TEXT', default_value => undef, is_nullable => 0, size => undef, }, type => { data_type => "VARCHAR", default_value => "", is_nullable => 0, size => 64, }. advertising => { data_type => 'ENUM', is_nullable => 0, }, syndication => { data_type => 'TINYINT', is_nullable => 0, size => 1, }, deprecation_date => { data_type => "DATETIME", default_value => "", is_nullable => 0, size => 19 }, );
This constantly breaks my code. It's not a syntax error, but I can't think of any circumstance under which I would ever want this behavior. Maybe I should write a vim plugin to try and auto-detect that.
What? You didn't see it right away? I wonder if that's relevant ...
I mean, I use "HASH(0x1731300)HASH(0x174c918)" all the time.
I think I saw it on the fourth read-through.
If not a syntax error, at least a warning.
-- dagolden
Re:kidding, right?
mpeters on 2009-07-17T14:37:23
I agree with Schern that it should be a warning, not a fatal error (I don't think it could be a syntax error since we don't know what's in those scalars at compile time).
A run time error would be bad for all the reasons Schern mentioned, but specifically because we all have debugging or logging code that does this. String interpolation shouldn't cause a run-time error. But since I've been bitten by this before I'm all in favor of it being a warning!
Re:kidding, right?
dagolden on 2009-07-17T15:59:48
I was thinking that the concatenation would be the warning, not the interpolation.
Re:kidding, right?
mpeters on 2009-07-17T20:39:57
But the concat is just one example of this problem isn't it? What about trying to use the wrong point in a nested data structure in a string? I've often used some 1 element array ref as a string because I missed something in some module's API.
Re:kidding, right?
tgape on 2009-07-19T17:21:52
Personally, I think that this is an example of something which should be another type of compile time error, which we don't have: semantic error. Specifically, the language technically allows it, but it has meaning that nobody would ever conceivably want.
As I understand that what I can conceive is limited, I'd probably add a runtime option to perl to disregard semantic errors. However, without that option, I'd have it complain about interpolating the literal hash and exit immediately.
http://www.nntp.perl.org/group/perl.perl5.porters/;msgid=20071228080833.9580.qm
Re:Wise men
Ovid on 2009-07-17T13:22:21
As soon as I say Dominus' email, I started thinking that it shouldn't apply to blessed objects due to overloading, but I see that Schwern already raised that case.
Still, other than that, I could see a warning or a new 'strict' type being added in future versions of Perl.
Re:Wise men
Aristotle on 2009-07-17T14:04:16
It could still just throw an error for any non-overloaded coercion.
I admit I didn't see it at first. So I copied the code into emacs. I have a habit of using perltidy in emacs to clean up my code, So I did that first. The problem jumped right out at me because of the indentation.
Then I tried just using cperl-mode indenting and it pointed the problem out to me also.
So does it really need to be a error/warning? or should we rely on our editor to find it.
Re:I didn't find it but emacs and perltidy finds i
Ovid on 2009-07-17T15:43:18
I argue in my roles talk (well, the one I'm giving in Lisbon) that complexity management tools should be pushed into the langauge (when possible), rather than relying on external tools. While I don't think this falls in the category of complexity management, I think that the principle of "language support, when possible" applies here. If someone doesn't have your editor setup, they could easily miss this. Personally, I think this problem is common enough that a warning is quite appropriate.
I still remember when we worked together at OnSite that I wrote a test asserting that no web pages contained text indicative of stringified references.
In a way, it's nice that everything can be converted to a string, but at least without something like autobox combined with overload, where you can have control what it converts into (at least, I hope that will do the trick), it's generally not very useful.