|
Awia posted:what if it doesnt' work and you dont want to try again? the if statement will get executed once unless enclosed in some wider loop how is that different from the do while block
|
# ? Mar 25, 2016 17:25 |
|
|
# ? May 25, 2024 11:37 |
|
yes but in the do while(false) you'd enter the if and hit the break, leaving the do block and hitting the code after instead of the things you might have wanted to do if the call in the if had done it's job correctly
|
# ? Mar 25, 2016 17:29 |
|
goto is cool because it pisses off spergs who think they're "doing it the right way" and then linus rips into them for submitting a patch that has 4 levels of indentation in a device driver
|
# ? Mar 25, 2016 17:38 |
|
CRIP EATIN BREAD posted:goto is cool CRIP EATIN BREAD was right
|
# ? Mar 25, 2016 17:59 |
|
AWWNAW posted:people who write X Considered Harmful blog posts should be shot into space "Considered Harmful" Essays Considered Harmful
|
# ? Mar 25, 2016 18:02 |
|
AWWNAW posted:people who write X Considered Harmful blog posts should be shot into space Thanks for giving me an idea for my next blog post, titled: X considered harmful blog posts considered harmful e:^^^ gently caress. That'll teach me to reply to something before reading the next page of posts.
|
# ? Mar 25, 2016 18:27 |
|
CRIP EATIN BREAD posted:thats a pretty common pattern when you dont have goto. i've used goto twice in embedded applications. the first was in a parser and was essentially identical to the do { } while (false) thing so that it could exit with common cleanup code even if there was an error (this saved a nontrivial amount of program space on my 8-bit micro with 32 kb of program space over other solutions, and i actually needed those bytes for other things). the other was to break out of nested switch blocks in the command packet handler for a usb device stack. i'm not going to whitewash the latter case since it could probably have been done without nested switch-cases, but i would rather use goto in the former case over the do { } while (false) on the other hand my cs grad boyfriend refuses to accept goto because he learned in school it was bad and he wanted to disown me after i showed him those things back to back
|
# ? Mar 25, 2016 18:38 |
|
sund posted:one sentence answer please why do people think NULL is a travesty? a programming language where anything can be null is like a human language where every sentence comes with an attached ", or maybe not"
|
# ? Mar 25, 2016 18:56 |
|
BattleMaster posted:i've used goto twice in embedded applications. the first was in a parser and was essentially identical to the do { } while (false) thing so that it could exit with common cleanup code even if there was an error (this saved a nontrivial amount of program space on my 8-bit micro with 32 kb of program space over other solutions, and i actually needed those bytes for other things). the other was to break out of nested switch blocks in the command packet handler for a usb device stack. just use gotos when you need them. back when dijkstra wrote his letter, goto was the only choice, there was no do-while loop to use instead.
|
# ? Mar 25, 2016 19:02 |
|
Wheany posted:just use gotos when you need them. back when dijkstra wrote his letter, goto was the only choice, there was no do-while loop to use instead. i agree. i find gotos very helpful in languages without exceptions when i want to jump to cleanup code when im in a failure state. the kind of gotos that are dangerous are when you program like this is till ancient BASIC and the only kind of flow control you have is goto <line>. that poo poo gets impossible to trace really fast with any kind of complexity in the logic.
|
# ? Mar 25, 2016 19:22 |
|
BattleMaster posted:the other was to break out of nested switch blocks in the command packet handler for a usb device stack. ill admit that the majority of my goto usage was for urb_destroy
|
# ? Mar 25, 2016 19:29 |
|
Awia posted:id probably not use a goto just because at least with break you know it goes to the end of the block instead of somewhere else in the file if you have to ctrl-f the target it's probably too far away. i don't have a problem with local gotos as long as they aren't being used for cthulean control flow, but the jump target really does need to be obvious from the point of the goto and ideally on the same screen
|
# ? Mar 25, 2016 19:33 |
|
10 PRINT "i am a bad programmer" 20 GOTO 10
|
# ? Mar 25, 2016 19:36 |
|
Plorkyeran posted:if you have to ctrl-f the target it's probably too far away. i don't have a problem with local gotos as long as they aren't being used for cthulean control flow, but the jump target really does need to be obvious from the point of the goto and ideally on the same screen quite true i suppose
|
# ? Mar 25, 2016 19:37 |
|
I imagine people treated for and while the same way they currently treat option types " why bother with while and for when I have goto "
|
# ? Mar 25, 2016 19:59 |
|
The point is, ladies and gentlemen, that goto, for lack of a better word, is good. Goto is right, goto works. Goto clarifies, cuts through,
|
# ? Mar 25, 2016 20:14 |
|
JewKiller 3000 posted:a programming language where anything can be null is like a human language where every sentence comes with an attached ", or maybe not"
|
# ? Mar 25, 2016 20:15 |
|
Condiv posted:I imagine people treated for and while the same way they currently treat option types
|
# ? Mar 25, 2016 20:17 |
|
kotlin looks kinda nice, definitely a more palatable java replacement than scala. maybe I'll give it a go for my next terrible side project
|
# ? Mar 25, 2016 20:34 |
|
Soricidus posted:kotlin looks kinda nice, definitely a more palatable java replacement than scala. maybe I'll give it a go for my next terrible side project i love scala. does kotlin have any type class capability?
|
# ? Mar 25, 2016 20:40 |
|
ok bad programmer braintrust, riddle me this: i have a String object that i need to be a regular string, should i just cast it or call ToString()?
|
# ? Mar 25, 2016 21:05 |
|
Soricidus posted:kotlin looks kinda nice, definitely a more palatable java replacement than scala. maybe I'll give it a go for my next terrible side project it targets jvm 1.6 so it works on blandroid (lol), but also will compile to javascript. also it has inline functions, overloading of methods with generic parameters (although only during compile time), and has some other nice stuff. i like it.
|
# ? Mar 25, 2016 21:13 |
|
Condiv posted:i love scala. does kotlin have any type class capability? no, but it has extension functions and you can add extension functions to a class without inheriting it so you can have some of that functionality
|
# ? Mar 25, 2016 21:17 |
|
HoboMan posted:ok bad programmer braintrust, riddle me this: i have a String object that i need to be a regular string, should i just cast it or call ToString()? is it a String or an object? String is string. if it's an object, just call object.ToString() as long as it's not null, IT'S NOT NULL IS IT?
|
# ? Mar 25, 2016 21:27 |
|
HoboMan posted:ok bad programmer braintrust, riddle me this: i have a String object that i need to be a regular string, should i just cast it or call ToString()? string and String are the same thing
|
# ? Mar 25, 2016 21:27 |
|
not according to visual studio apparently e: i got a thing that needs a string and when i pass it a String it's complaining about getting an object HoboMan fucked around with this message at 22:11 on Mar 25, 2016 |
# ? Mar 25, 2016 21:52 |
|
netcat posted:string and String are the same thing not quite. String is the .net implementation of the string object. strictly speaking, string is the C# alias to String. right now if you declare a string you'll get a String, but this isnt required to be the case and you could see a change of implementation in the future
|
# ? Mar 25, 2016 22:00 |
|
today i learned how to define a list that holds objects that implement a specific typeclass in scalacode:
Condiv fucked around with this message at 22:21 on Mar 25, 2016 |
# ? Mar 25, 2016 22:17 |
|
let me say that all the sample code that is all butts and turds and farts makes me laugh every time
|
# ? Mar 25, 2016 22:26 |
|
Condiv posted:i love scala. does kotlin have any type class capability? i hope not, because the main thing i don't like about scala is that it has too many features. i mean fancy type system hacks where you write the cleverest code you can are great fun and all, but at the end of the day i just want to be writing code that i'm going to be able to understand again in six months' time, and i personally find that having something with limitations - like java - is useful for that. all i really want from a new language is java but with most of the warts removed and some modest improvements like var and properly designed nullable types
|
# ? Mar 25, 2016 22:32 |
|
so c#?
|
# ? Mar 25, 2016 22:36 |
|
c# doesn't have properly designed nullable types (only for value types), and also i should perhaps have specified that by "java, but with ..." i mean it runs on the jvm and builds with maven.
|
# ? Mar 25, 2016 22:38 |
|
Soricidus posted:i hope not, because the main thing i don't like about scala is that it has too many features. i mean fancy type system hacks where you write the cleverest code you can are great fun and all, but at the end of the day i just want to be writing code that i'm going to be able to understand again in six months' time, and i personally find that having something with limitations - like java - is useful for that. utilizing the typesystem to make union types, or type functions, etc is p nice when i have a project that needs a strong type system
|
# ? Mar 25, 2016 22:42 |
|
HoboMan posted:not according to visual studio apparently post some code, somethin' ain't right
|
# ? Mar 25, 2016 22:45 |
|
Soricidus posted:c# doesn't have properly designed nullable types (only for value types), and also i should perhaps have specified that by "java, but with ..." i mean it runs on the jvm and builds with maven. oh sorry i missed the "properly designed" part. gently caress i love maven. it's the only thing i miss about being a java dev. is there anything remotely similar for c#? e: ^i just called ToString() and called it a day. this is the terrible programmers thread HoboMan fucked around with this message at 22:48 on Mar 25, 2016 |
# ? Mar 25, 2016 22:45 |
|
HoboMan posted:oh sorry i missed the "properly designed" part. nuget, depending on how flexible you're willing to get with "remotely"
|
# ? Mar 25, 2016 22:48 |
|
Condiv posted:today i learned how to define a list that holds objects that implement a specific typeclass in scala ive been meaning to learn a scala, what's that Ev stuff about
|
# ? Mar 26, 2016 00:25 |
|
fritz posted:ive been meaning to learn a scala, what's that Ev stuff about basically, typeclasses in scala are not a first class form of polymorphism. I can't say "val x: List[Buttlike] = List(new TinyButt, new BigButt)" because neither TinyButt or BigButt are subtypes of Buttlike. since my list is composed of multiple types with no common supertype other than Any (scala's slightly more powerful Object), the type of my list will end up as Any if I put them in the list normally. the Ev class is there to contain type evidence (basically, to prevent the underlying types from being completely erased) so i can still use the types in the list with the typeclass Buttlike. anyway, none of this is really very important to get use out of scala. i'm just mucking about with the type system to see what i can get scala to do while still maintaining type safety Condiv fucked around with this message at 01:13 on Mar 26, 2016 |
# ? Mar 26, 2016 00:59 |
|
hackbunny posted:compilers won't even warn you if you forget to check though the clang static analyzer can actually, and you can use its annotations on your own code too one problem in the UNIX world though is that there's almost 40 years of code now that assumes allocation can't fail due to VM overcommit, so nobody actually checks the result of malloc/calloc/realloc or anything built on top of them then you run on a system without a pager and oops! you just need to have processes die instead of gracefully recover because evidently the knowledge of how to do that went away with the 80s
|
# ? Mar 26, 2016 01:08 |
|
|
# ? May 25, 2024 11:37 |
|
LeftistMuslimObama posted:at least 0 as null has historical reasoning behind it. outside of some exceptional architectures the page starting at 0x0 is off-limits typically so if you dereference a pointer with a value of 0 it's likely you've messed up. this historically wasn't the case though, it's a recent thing; many systems used low-memory globals because CPUs had specific instructions for accessing the zero page 68K kept its vector table at 0, for example, 6502 had short zero-page instructions, and TMS9900 didn't even have registers just shorthand (and on-chip cache) for locations 0-15
|
# ? Mar 26, 2016 01:14 |