- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
That looks like VB to me. I can find nothing like a 'default return' in the documentation (there can be no such thing). If Request.QueryString("x") is a list of strings, then it's not a string. It may have an implicit cast to string (bad. Implicit casts should never lose information).
In fact, the QueryString.Item property is the same as the index or whatever, so QueryString["a"] is the same as QueryString.Item["a"]. Item returns a string. Always. If you want the list of strings, use QueryString.GetValues("a"), which returns a string array.
If VB has other atrocities which let this work in strange and wonderful ways, I really don't want to know. I don't know of any language that does things based on the "expected return type" - type inference almost always goes one way. That's why languages don't let you overload functions differing only in return type. Otherwise, you get braindead results like (int)(float)f(), which may or may not be different from (int)f().
Admin
If you're reloading the page anyway, the server can set the 'checked' property of the checkboxes fine, all by itself.
Maybe there are sensible reasons, but only if the javascript parses the value later on the same page.
And the rule about JavaScript? The page should work just fine without it. If it needs javascript, it's badly designed, obviously by someone who knows nothing about http.
Admin
It *is* compatible with existing programs. Really. Existing programs can use blah[] if they really want to. Sensible programs can use _GET_ARRAY. Servers can be configured to allow the old behaviour.
And if PHP was half decent, it could return the empty array for anything that isn't defined, which is the only sensible abstraction.
But having had to use PHP, it's broken anyway. I don't know if it reparses pages or caches them, but it has shortcomings that makes ASP.NET leaps and bounds better, even though ASP.NET isn't perfect (it's like programming in VB or JavaScript or CF - people who use it tend to have no idea what's going on).
Admin
Wrong! Then, when it *is* february, and you set the date to march 29, first it sets it to feb 29 -> mar 1 (on a normal year) and then to march 1 again.
This is why I hate badly designed date classes.
Java's Date is designed decently, though it should be renamed Time (distinct concept from TimeOfDay). They moved all Calendar functions to Calendar, and there are different calendars, not all of which have months (I think?).
What someone really needs to do is design something that handles TAI, UTC, and timezone-settings correctly. Calling anything "UTC" on a computer that isn't actively recieving leap-second info is wrong - you get a one-second error if you miss a leapsecond. The better way would be to store the difference to TAI in the timestamp as well (this also lets you deal with times a few years into the future)
Most unfortunately, the POSIX spec says that time() and gettimeofday() effectively replay leap second as the next second (it returns day*86400+seconds, so day 0 second 86400 and day 1 second 0 are equal). NTP replays leapseconds as the previous second. And other really bad designs.
I call for all timestamps to be TAI.
I propose "t-tw_t-assh_l_", with a stutter. Blanked because I don't know if it'll be deleted if I don't (or even if I do).
Admin
Perl allows a function to tell whether it was called in list, scalar or void context, and change its behaviour accordingly: http://search.cpan.org/dist/perl/pod/perlfunc.pod#wantarray. Haskell allows overloading on the return type, for example http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3AfromInteger. There are probably other languages that have something similar - IIRC someone here mentioned a while back that Ada could do it.
Do you mean this one: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html? Because it behaves the same as JavaScript's Date in this case, and IIRC the JavaScript one is actually just a straightforward translation of the Java one.
Admin
They realised it was a WTF and deprecated anything to do with calendars in Date (except toString(), which is an allowable exception, though perhaps it should display UTC). A Date is an instant in time (to some precision), and functions to convert it to calendar dates and back are in Calendar. And if you use Calendar's set() methods, you won't get this WTF. GregorianCalendar improves on it a bit more - one month after Jan 31 is Feb 28/29.
.NET has yet to make the distinction.