|
Jabor posted:
Oh duh; this is why I prefer to use the DOM: code:
Cocoa Crispies fucked around with this message at 05:40 on Sep 3, 2011 |
# ? Sep 3, 2011 05:37 |
|
|
# ? May 16, 2024 16:58 |
|
BonzoESC posted:Oh duh; this is why I prefer to use the DOM: Except your way doesn't work either. You are just getting the value of a single radio input by ID just like the other example: http://jsfiddle.net/WxThT/
|
# ? Sep 3, 2011 13:13 |
|
Was supposed to do 10-12 hours of work on it today. Woke up at 2.30pm, its now 5pm, and i really can't be arsed.
|
# ? Sep 3, 2011 16:54 |
|
var hasChanged = false; hasChanged |= module1.hasChanged() | module2.hasChanged() | module3.hasChanged() | module4.hasChanged(); if(hasChanged){ module1.reload(); module2.reload(); module3.reload(); module4.reload(); } Spoilers: Bitwise vs logical OR. Not a great horror, but if you are going to reload every module anyway, you might as well make use of short circuiting.
|
# ? Sep 5, 2011 07:16 |
|
Except knowing this code, at least one of those hasChanged() methods has some side effects that short circuiting would break.
|
# ? Sep 5, 2011 07:32 |
|
That or it's to defeat timing attacks of some kind. But realistically, no, the other thing.
|
# ? Sep 5, 2011 10:25 |
|
thanks, whoever worked on this project before me:code:
There's also gotos.
|
# ? Sep 6, 2011 19:40 |
|
gotos aren't evil and gently caress the guy who said they were. The only problem with them is when inexperienced programmers shovel them in every possible fragment of code, making reading that code look like you're watching a vertical tennis match. if...then...else combined with gotos were your first exception handlers.
|
# ? Sep 6, 2011 19:47 |
|
thelightguy posted:gotos aren't evil and gently caress the guy who said they were. The only problem with them is when inexperienced programmers shovel them in every possible fragment of code, making reading that code look like you're watching a vertical tennis match. gently caress Dijkstra? Okay...
|
# ? Sep 6, 2011 19:48 |
|
Dijkstra never explicitly said Gotos were "evil" and in fact, the letter that was published as an article wasn't even originally titled "Go To Statement Considered Harmful" it was just "A Case against the GO TO Statement." (which was later retitled upon article submission) And people who slavishly hold everything in that letter/article to be gospel are silly anyway. Dijkstra was right about a lot of things but the statementEWD posted:the go to statement should be abolished from all "higher level" programming languages (i.e. everything except -— perhaps -- plain machine code)
|
# ? Sep 6, 2011 20:00 |
|
Additionally if you actually read the paper quite a few of his arguments are specifically against FORTRAN-style line numbered GOTOs and not the textual labels found in modern languages and halfway decent assemblers.
|
# ? Sep 6, 2011 20:03 |
|
and really the paper is just an argument in favor of structured programming
|
# ? Sep 6, 2011 22:16 |
|
these are kind of dumb gotos, but really my primary horror was the reverse indentation.
|
# ? Sep 6, 2011 22:21 |
|
TasteMyHouse posted:these are kind of dumb gotos, but really my primary horror was the reverse indentation. Speaking of, and here's an opportunity to ask, I've seen code that aligns all preprocessor directives to the left no matter what. So you get stuff like code:
|
# ? Sep 6, 2011 23:26 |
|
I thought preprocessor tokens couldn't be indented, but apparently that hasn't been true since before I was born.
|
# ? Sep 6, 2011 23:31 |
|
pokeyman posted:Speaking of, and here's an opportunity to ask, I've seen code that aligns all preprocessor directives to the left no matter what. So you get stuff like It's probably because preprocessor tokens are "special," since they're more about the implementation of the software than the design of it.
|
# ? Sep 6, 2011 23:47 |
|
pokeyman posted:Speaking of, and here's an opportunity to ask, I've seen code that aligns all preprocessor directives to the left no matter what. So you get stuff like I know our latest coding standard at work calls for that block to be either: code:
code:
|
# ? Sep 7, 2011 00:42 |
|
Wheany posted:var hasChanged = false; Why not just use hasChanged && (module1.reload(), module2.reload(), module3.reload(), module4.reload()); (assuming this is js)
|
# ? Sep 7, 2011 00:52 |
|
Biowarfare posted:Why not just use hasChanged && (module1.reload(), module2.reload(), module3.reload(), module4.reload()); Because being cute with short-circuiting is way worse than using an if statement.
|
# ? Sep 7, 2011 01:42 |
|
thelightguy posted:gotos aren't evil and gently caress the guy who said they were. The only problem with them is when inexperienced programmers shovel them in every possible fragment of code, making reading that code look like you're watching a vertical tennis match. the guy who wrote about the use of gotos has contributed more to programming than you ever will in your lifetime.
|
# ? Sep 7, 2011 01:50 |
|
tef posted:the guy who wrote about the use of gotos has contributed more to programming than you ever will in your lifetime. I know, but that doesn't mean he wasn't wrong about gotos.
|
# ? Sep 7, 2011 02:01 |
|
I don't think he was wrong, I just think that people are stupid and sensationalized his statements to the extreme.
|
# ? Sep 7, 2011 02:19 |
|
eh. I think it's people taking it to extremes on either side. I haven't really, legitimately, needed to use a GOTO since my Atari BASIC days. Does that mean they are verboten and should never be used? Does that mean they are awesome and should always be used? Or does it mean that a guy wrote an article, which at the time, a lot of people were abusing GOTO and it pissed him off.
|
# ? Sep 7, 2011 02:30 |
|
Everything I've ever read by Dijkstra is hyperbolic, and it's probably because he just wants people to think critically about the issues he brings up. Some people take him at face value without noticing this and either leap to agreeing with him because he's Dijkstra or just as rashly conclude he's an rear end in a top hat who doesn't know what he's talking about. It's food for thought, not proclamations from on high.
|
# ? Sep 7, 2011 02:48 |
|
thelightguy posted:I know, but that doesn't mean he wasn't wrong about gotos. At the time, GOTO was used for *everything*. Every single branch was a GOTO, and most languages did not have the concept of a loop or conditional. He advocated that the constructs of IF, WHILE, etc, should be used in preference to GOTO. He didn't claim that all GOTOs were bad, just that languages of the time should be given features that relieved the programmer from having to think about manual branch management. He was so thoroughly correct that today, computer science undergrads claim he was wrong about GOTO because they can't even contemplate a world without structured programming.
|
# ? Sep 7, 2011 03:36 |
|
I just wrote a Fortran compiler for 'fun'. Here is a nontrivial program written in a language where the only meaningful flow control mechanism is a numbered goto. A language in which variable names cannot exceed two characters long and integral types must start with i, j, k, l, m or n. A language without facilities for named constants or procedure definitions. Read this horrible thing and ponder the fact that I'm not intentionally obfuscating my source- this is what programming used to look like.
|
# ? Sep 7, 2011 03:54 |
|
Internet Janitor posted:I just wrote a Fortran compiler for 'fun'. Here is a nontrivial program written in a language where the only meaningful flow control mechanism is a numbered goto. A language in which variable names cannot exceed two characters long and integral types must start with i, j, k, l, m or n. A language without facilities for named constants or procedure definitions. Why are you using > and not .gt., etc.? Softy.
|
# ? Sep 7, 2011 04:47 |
|
Biowarfare posted:Why not just use hasChanged && (module1.reload(), module2.reload(), module3.reload(), module4.reload()); Why not use hasChanged ? (module1.reload(), module2.reload(), module3.reload(), module4.reload()):0; Hey, it works, so why not!
|
# ? Sep 7, 2011 05:02 |
|
OddObserver posted:Why are you using > and not .gt., etc.? Softy. I based my implementation on this document, which does not indicate the use of stropped keywords or symbols. I thought that was mainly an ALGOL thing, anyway.
|
# ? Sep 7, 2011 05:22 |
|
Internet Janitor posted:I based my implementation on this document, which does not indicate the use of stropped keywords or symbols. I thought that was mainly an ALGOL thing, anyway. That thing is pretty awesome, thanks for the link (it's always fun to read those early document). As for .gt., etc.... well, I am pretty sure at least Fortran 77 required those: http://www.fortran.com/F77_std/rjcnf0001-sh-6.html#sh-6.3.1 .. and looking at WP articles on early Fortran dialects, seem likes they pretty much dropped the conditional feature in favor of a simpler version... Edit: or see Fortran 66: ftp://ftp.nag.co.uk/sc22wg5/ARCHIVE/Fortran66.pdf
|
# ? Sep 7, 2011 05:55 |
|
pokeyman posted:Speaking of, and here's an opportunity to ask, I've seen code that aligns all preprocessor directives to the left no matter what. So you get stuff like I used to do it because macros don't obey scoping rules and standard code formatting has indentation giving hints to the different scopes. As of now though I do it like that out of habit.
|
# ? Sep 7, 2011 08:50 |
|
Edison was a dick posted:I used to do it because macros don't obey scoping rules and standard code formatting has indentation giving hints to the different scopes. Preprocessor stuff should look ugly because it is ugly. If you want it to look not ugly make it less so, i.e.: code:
|
# ? Sep 7, 2011 09:25 |
|
thelightguy posted:I know, but that doesn't mean he wasn't wrong about gotos. He was pretty right about gotos. You use If and while and for, right? You wouldn't be using gotos for them? Dijkstras point was that goto is a form of unstructured programming and we should be using structured programming constructs. This was around the time where getting programmers to use subroutines was considered a challenge. Janin posted:He was so thoroughly correct that today, computer science undergrads claim he was wrong about GOTO because they can't even contemplate a world without structured programming. Agreeing with Janin here. People take if, while, and for for granted that the context of the argument is lost. A similar thing happens with BASIC. At the time, basic had 26 variables (A-Z), no structured programming and a lot of goto. The only way to write code was spaghetti. Basic at the time was closer to an assembly language (in terms of managing registers and control flow) than more high level language people know today as BASIC. But lo and behold 'basic cripples the mind' is read as if he was complaining about a modern variant. Internet Janitor posted:Everything I've ever read by Dijkstra is hyperbolic this means you've probably read two of this things - 'how do we tell truths that might hurt' and 'gotos considered harmful', and of those you haven't read the first closely. ewd wrote a *lot* of things, and you're judging them by a subset. I don't think anyone on something awful can call out dijkstra for being a little hyperbolic DIJKSTRA WAS RIGHT.
|
# ? Sep 7, 2011 11:55 |
|
Janin posted:He was so thoroughly correct that today, computer science undergrads claim he was wrong about GOTO because they can't even contemplate a world without structured programming. undergrads seem to be full of opinons without context
|
# ? Sep 7, 2011 11:58 |
|
I sighed aloudcode:
|
# ? Sep 7, 2011 19:00 |
|
tef posted:DIJKSTRA WAS RIGHT. Was (ha ha, only serious) e: He probably forgot more about programming than I will ever learn, but I don't dare to use gotos even when they make sense because I'm afraid of my coworkers preaching the holy gospel of Dijkstra during code inspection. Wheany fucked around with this message at 20:06 on Sep 7, 2011 |
# ? Sep 7, 2011 20:03 |
|
Amusing anecdote: I took class taught by Dijkstra when I was an undergrad. He didn't actually have a computer in his office, and all of his notes were handwritten (impeccably).
|
# ? Sep 7, 2011 23:19 |
|
TasteMyHouse posted:I sighed aloud
|
# ? Sep 7, 2011 23:30 |
|
I use retval a lot. I am a bad programmer. Actually I generally do that in terribad languages that have immutable strings and such, having to do dumb poo poo like code:
NotShadowStar fucked around with this message at 00:06 on Sep 8, 2011 |
# ? Sep 8, 2011 00:01 |
|
|
# ? May 16, 2024 16:58 |
|
If you ever come to a point where you think "A goto would be really easy here, otherwise I'll have to add in a bunch of boolean flags and conditionals to code my way around it" and then add in the boolean flags and conditionals, you're doing it wrong
|
# ? Sep 8, 2011 00:08 |