|
seiken posted:Woah, why have I never thought of the !! operator before? Since it doesn't do anything you can pepper it around your code to indicate the important bits! Why stop at !! when you can prefix the really important bits with !!!!!!!!!!!!
|
# ¿ Nov 11, 2010 14:35 |
|
|
# ¿ Apr 28, 2024 18:58 |
|
Golang has a gofmt command that automatically reformats code so you can just run it in a pre-commit hook and never even think about it ever again.
|
# ¿ Jul 29, 2011 12:44 |
|
The Gripper posted:Why is this? Python Reference posted:Formally, if a, b, c, ..., y, z are expressions and op1, op2, ..., opN are comparison operators, then a op1 b op2 c ... y opN z is equivalent to a op1 b and b op2 c and ... y opN z, except that each expression is evaluated at most once. So (2 > 1 is True) evaluates to (2 > 1 and 1 is True) which is False. The parenthesis stop the expansion. (This one took me a while to figure out.)
|
# ¿ Jan 19, 2012 20:13 |
|
Whenever I see ~/fn~ I think It's so unique
|
# ¿ Jan 30, 2012 15:16 |
|
I like to think of php variables as one big name mangling (for local variables!) hash map and $ is the accessor method. I'm not sure if that makes it more or less of a horror. At this point the value could overflow at any time anyway.
|
# ¿ Feb 14, 2012 04:03 |
|
pseudorandom name posted:The could've made format strings use "yyyy", "mm", "dd" etc. instead, which would be both easy to remember and easy to read. Why is using a bunch of different character codes that necessarily will have overlap (minutes vs months, the number of different ways of shortening a day/month) easier to read than reading a date in the format you want it to look like? I don't see why its such a terrible idea. It feels like the backlash against it is just because it's different.
|
# ¿ Apr 12, 2012 01:17 |
|
The Gripper posted:If you look at code with a datetime format string from any other language you immediately know "hey, that's the format of a datetime". So your argument is that because it's different people might be confused by it? There's only one way to format dates in Go with the standard library, so if you're familiar with Go that's a non-issue. Imagine if Go was the standard way and they came out with strftime. You could make the same argument the other direction.
|
# ¿ Apr 12, 2012 11:29 |
|
The Gripper posted:My argument is that using an actual date/time as a format string is confusing, because everywhere else (and I mean everywhere, not just in Go) a written date or time means "this date or time" not "any date that fits this format". Using HH:nn:ss also has the benefit of differentiating a format string from a date or time; in Go the meaning of "12:34:56 2006-01-01" different (literal datetime or datetime format string) depending on where it is used. To not be pedantic, the only time the context changes is when it is used in a specific method of a specific type. It's not like format strings are littered throughout code confusing people as to if they are specifying a date or not. There are literally two functions that accept a layout and in both cases it is clear from the local context that it is a format string, if not just by the calling method, but by the fact that it is specifying a specific date/time that if you are familiar with Go is clearly a format time. The Gripper posted:Edit; it's a novel idea and simplifies creating format strings, but in practice it is confusing (hang around in the #go-nuts irc channel and see how often people come in confused about this exact thing). The Gripper posted:Also I wasn't arguing that it's confusing because it's different to strftime, just that when I see a date I expect the interesting part to be the date, not the formatting of it's elements.
|
# ¿ Apr 12, 2012 15:11 |
|
The Gripper posted:I honestly couldn't tell you which digits represent minutes and seconds, and the same with which digits represent days and which represent months. I could have them backwards, I just guessed at their order. Compared to strftime where mixing up %M and %s is obvious, mixing up 03 and 04 in go is not. The Gripper posted:There have been numerous that have mistaken the use of Format() and related methods, maybe not mistaking the format string with date in the code, but definitely mistaking the required parameter as being "a date" rather than "a format string". So because they were unfamiliar with this different system they had an issue with how the format was specified. Once they learned about how the system worked, there were no more problems. There could be an argument for better documentation on the methods that take a layout, but that's not a problem with the system. The Gripper posted:Honestly it tries to solve a problem ("time format strings are confusing") and instead makes a carbon copy of the problem with more confusing element names (digits instead of %X). It's a net negative for the developer (you still need to know the substitutions as you would with strftime, however they no longer have a letter attached that gives it meaning) and there's marginal benefit to an observer (you can see what the result will look like immediately).
|
# ¿ Apr 12, 2012 15:45 |
|
Golbez posted:PHP, is_readable(), has a curiosity in its documentation. The bigger horror is that it exists at all. There is no way to provide that function without creating a race condition. What if someone deletes the file in between that call and your attempt to read it?
|
# ¿ Jul 25, 2012 20:48 |
|
Golbez posted:And if I try to run fopen() on a non-existent file, it throws a warning. Keep in mind that it also returns false. The documentation even helpfully suggests using @ to suppress the warning. Perhaps PHP functions should throw exceptions, because this seems like a reasonable place for that. The point is that you have to assume that the fopen() call could raise a warning regardless of how much checking you do because by the time you get to actually opening the file the state of the filesystem could be different, so why bother doing the checking? It's a completely worthless function.
|
# ¿ Jul 25, 2012 21:38 |
|
bobthecheese posted:
How would you define March 31st - 1 month? Feb 31st and normalizing seems reasonable to me.
|
# ¿ Oct 31, 2012 22:24 |
|
Zombywuf posted:BRB posting "sort a list" exploits to Stack Overflow. It doesn't consider anything posted after the xkcd comic.
|
# ¿ Mar 19, 2013 13:28 |
|
|
# ¿ Apr 28, 2024 18:58 |
|
Medical records and gibberish? Gotta be MUMPS.
|
# ¿ Jul 29, 2014 05:42 |