|
Plorkyeran posted:you're passing an array of points to something wanting a pointer to an array of points oh i am literally retarded thanks
|
# ? May 24, 2016 01:14 |
|
|
# ? May 24, 2024 17:43 |
|
Luigi Thirty posted:working on my C++ dos toy thing. i have some routines set up to draw lines... I'm trying to feed an array of points into a general polygon drawing routine but pointers are driving me nuts as usual It's nice to see someone else get bitten by the array syntax leading to implicit pointers. It makes sense when you know what it's doing, but if you don't know then it just seems like the compiler is trolling you. As you can see by the necessity of needing to pass the number of elements separately, C doesn't really have a fully-featured implementation of what you're probably used to thinking of as an array. Arrays in C are just pointers to 0-th element. So as far as C is concerned, a pointer to anything could be a pointer to a single item or it could be a pointer to an array of those type of items. Bracket array notation is just syntactic sugar for doing the pointer arithmetic. It does so implicitly, though. So when you say points[1], it's doing the pointer math to find the address, and then dereferencing the resulting pointer for you. This is why when you want to pass the actual address of a specific index you have to say &points[index]. So your Point* points[] in your function declaration is saying you want a pointer to the 0-th element of an array of Point type. That's why the compiler is saying your function is requesting a Point**(pointer to a pointer). The pointer part is implicitly being done for you already when you said "points[]" because you used the brackets. So if you drop the brackets or drop the star then it should work fine. You can do neat(or dangerous) stuff with it sometimes like if you wanted to chop off the first 3 chars of a null-terminated ASCII string before printing it you can just say printf("%s", &string[3]) without actually needing to munge the string. Since printf takes a pointer the same way anything that's expecting an array does, it doesn't care that the address of the 3rd element isn't actually the 0-th element. efb, but hopefully my explanation is helpful for avoiding future problems. ErIog fucked around with this message at 01:41 on May 24, 2016 |
# ? May 24, 2016 01:19 |
|
kalstrams posted:yea i cant find anything better both in price and length so getting this, as i doubt id read 400 page tdd book about python hope its good, i just linked it cuz the guy was a guest on another python podcast and seemed smart
|
# ? May 24, 2016 01:21 |
|
hmm judging by the table of contents it's more about how to use specific python testing frameworks than about, like, the concepts of unit testing. my "Critical Hit" is more of an "Epic Fail"! lol!
|
# ? May 24, 2016 01:27 |
|
yay i'm smart again and i can draw shapes on a VGA framebuffer
|
# ? May 24, 2016 01:38 |
|
Luigi Thirty posted:
that's pretty rad. you following a guide or using some special library or what?
|
# ? May 24, 2016 01:38 |
|
Notorious QIG posted:that's pretty rad. you following a guide or using some special library or what? nope i'm working it out as i go i downloaded the font from some asset library and looked at some other source code to work out how to get a 240Hz timer going but other than that it's just google and old documentation
|
# ? May 24, 2016 01:46 |
|
GameCube posted:whats up you idiots. how do i write good unit tests and make it easy for people to write their own loving unit tests instead of making me do it. what's a good book, or maybe blog. help me out here. come on. don't before you do traditional unit tests you should try * exhausitive testing pick a property like 'all apples are green' and examine all the apples. try all the things. 65000 items? test them all. four million things? test them all. computers are fast, edge cases are hard, don't think if you can avoid it * property-based testing - a.k.a. quickcheck after a haskell library sometimes you are dealing with 8 billion things. or 8 billion things cubed so testesting them all isn't going to happen. instead you throw random input at your functions both of these operate under the assumption that you are bad at figuring out where your code will break. this is probably true! otherwise you would have already fixed it you can get part of this effect by having a more senior person write the unit tests, but this is boring for the senior and maddening for the junior and i don't recommend it this only works with things that can be cobbled into effectly pure functions; you don't want to be testing how often the stars align. traditional unit testing has similar problems, but usually also comes with frameworks with well-defined setup and tear downs to manage state. sometimes this means every test gets its own process! expect weirdness in load ordering and resource allocation there is a place for traditional unit tests, in that you can take the tests that you'd traditionally put into mains and put them into unit tests instead. this is also known as smoke testing. it's fine to check these tests in since it lets everyone know that the code actually does something and also provides a working example if you find that you are writting the same tests over and over, figure out how to write less code! most of the time this means abstracting the thing you are doing and testing that if you hear 'code coverage', you know that somebody wants to chase a bonus/dopamine by making numbers go up. code coverage is the delusion that percentage of lines that are executed during your test has any predictive power. instead, you should think of how much of the state space is tested; how many of the configurations of all of the possible arguments and all relevant accessible states are run through your tests. it only takes two 32-bit integer argument for this count to be larger this number of grains of sand on the earth, where a traditional unit test probably goes through five of them. this combinatorial explosion should convince you that before you start to test iyou should reduce the state space as much as you can. you do this by making pure functions with no side effects, by reducing access to global state, in general by prefering simple things to easy things testing is a thing that you do with other people if you work with other people. if you start testing, your good tests can silently become bad because the code under test became more complex. you need to yell at people when they make things more complicated tests happen automatically or they will never be run. failing tests break the build and breaking the build needs to addressed right away. one way to test your tests automatically is to do mutation testing. this is where you automatically mutate the code under test and see how well your tests deal with the world going insane. here failing tests are good tests, since that means your tests match the assumptions in your code but even then testing your assumptions is not the same thing as testing for errors. use testing as a tool to check if you are wrong, not to assure you that you are are right
|
# ? May 24, 2016 02:05 |
|
i was under the impression that property-based testing was a form of unit testing, but i guess not (i'm still getting used to TDD)
|
# ? May 24, 2016 02:08 |
|
code:
this person desperately needs to be introduced to the "right margin river-of-punctuation" idea
|
# ? May 24, 2016 02:15 |
|
Luigi Thirty posted:nope i'm working it out as i go have you seen the Graphics Programming Black Book? it'll be right up your alley and it's all free.
|
# ? May 24, 2016 02:24 |
|
what is property based testing
|
# ? May 24, 2016 02:27 |
|
Brain Candy posted:sometimes you are dealing with 8 billion things. or 8 billion things cubed so testesting them all isn't going to happen. instead you throw random input at your functions also i know everyone's on pins and needles about my job hunt: first on-site interview is this wednesday
|
# ? May 24, 2016 02:40 |
|
Bloody posted:what is property based testing testing by logical properties "all humans have two legs" is a property "humans don't have more than two legs" is a property you could test either by examining all people. this is exhaustive testing. you are almost certain when you are done you could test either by examining a thousand people. this is property based testing. you are asymptotically sure traditional unit testing is where you test the same five people over and over again
|
# ? May 24, 2016 02:42 |
|
JawnV6 posted:also i know everyone's on pins and needles about my job hunt: first on-site interview is this wednesday congrats!
|
# ? May 24, 2016 02:48 |
|
JawnV6 posted:is "directed random testing" used outside ASICs? the idea is to take test content and randomize chunks of it, picking and choosing where to add randomness. you're still picking a part of an intractable state space and searching "close by," but it's better than running the same precise test case modern mutation testing to test your tests does this by homing in on any branches it can identify: code:
|
# ? May 24, 2016 02:48 |
|
Luigi Thirty posted:nope i'm working it out as i go neat
|
# ? May 24, 2016 02:56 |
|
JawnV6 posted:is "directed random testing" used outside ASICs? the idea is to take test content and randomize chunks of it, picking and choosing where to add randomness. you're still picking a part of an intractable state space and searching "close by," but it's better than running the same precise test case there is some insanely cool testing tools in that direction like American fuzzy lop (the fuzzer not the bun)
|
# ? May 24, 2016 03:22 |
|
LeftistMuslimObama posted:i'm not advocating writing a 40-line chain of if-then-else-else-else or whatever, but this guy is pathological to the point that he will not write the word "if", even when the thing he's doing is literally troll him by making a script that replaces his boilerplate garbage with if statements
|
# ? May 24, 2016 03:53 |
|
Bloody posted:interacting with a piece of hardware to update the state of some hardware connected to that hardware then reading back the state of that hardware to see if it matches what was set yeah at 93% it sounds like a race
|
# ? May 24, 2016 03:53 |
|
Progressive JPEG posted:troll him by making a script that replaces his boilerplate garbage with if statements #define while if
|
# ? May 24, 2016 03:57 |
|
Progressive JPEG posted:troll him by making a script that replaces his boilerplate garbage with if statements I'm not like a Good Programmer, but isn't the compiler already doing that? It seems like unless he's trying to deliberately obfuscate what he's doing then shouldn't his compiled code end up looking nearly the same as if he had just used an if statement? ErIog fucked around with this message at 04:01 on May 24, 2016 |
# ? May 24, 2016 03:57 |
|
Progressive JPEG posted:yeah at 93% it sounds like a race i was about to start enumerating possible origins of a ~7% failure rate bug in our system and literally the first piece of math i did involving the backpressure mechanism in a parallel-to-serial block gave a 1-in-18 5.6% error rate which is probably within the error margin of my tests and i bet i know at least where to start ripping poo poo apart. boy i love digital design
|
# ? May 24, 2016 03:59 |
|
bespoke artisanal serial protocols are absolutely miserable btw
|
# ? May 24, 2016 04:01 |
|
eschaton posted:congrats! Progressive JPEG posted:yeah at 93% it sounds like a race
|
# ? May 24, 2016 04:27 |
|
JawnV6 posted:nah, for a pure digital failure it's likely a race but especially with a serial protocol i'd check if either side detected a bit error and oh my, window open for a while oh yeah i havent done much hardware stuff outside of firstjob ps grats
|
# ? May 24, 2016 04:31 |
|
eschaton posted:have you seen the Graphics Programming Black Book? it'll be right up your alley and it's all free. neato there's just something cool about working out the best way to shovel pixels around in a 64kb frame buffer or optimize a string search that you don't get writing dumb Java business software at work or in my case spend an hour banging my head against Watcom trying to figure out how to turn a string of |-delimited integers I'm reading from a file into my Point objects Luigi Thirty fucked around with this message at 04:51 on May 24, 2016 |
# ? May 24, 2016 04:49 |
|
Luigi Thirty posted:nope i'm working it out as i go PC Game Programmer's Encyclopedia It's what I used when I had a DOS/Windows 3.1 machine and wanted to make games.
|
# ? May 24, 2016 04:53 |
|
Progressive JPEG posted:gaslight him by making a commit hook that replaces his boilerplate garbage with if statements
|
# ? May 24, 2016 06:06 |
|
Notorious QIG posted:#define while if a friend had this in his .signature for a long time: #define struct union /* space saver */
|
# ? May 24, 2016 06:08 |
GameCube posted:hope its good, i just linked it cuz the guy was a guest on another python podcast and seemed smart
|
|
# ? May 24, 2016 06:09 |
|
|
# ? May 24, 2016 06:16 |
GameCube posted:hmm judging by the table of contents it's more about how to use specific python testing frameworks than about, like, the concepts of unit testing. my "Critical Hit" is more of an "Epic Fail"! lol! nah, the concepts beyond "test every X" are needless circlejerkery for me
|
|
# ? May 24, 2016 06:16 |
|
unit testing as a field seems to be chock full of pointless dogma "avoid (thing that works perfectly well) at all costs! you should rewrite all your legacy code to follow the POOP principle where you contort all your code to avoid fnorbed methods"
|
# ? May 24, 2016 06:46 |
suffix posted:unit testing as a field seems to be chock full of pointless dogma what, you app startup doesnt use neo-randian functionally imperative narrative driven agile testless development?
|
|
# ? May 24, 2016 07:03 |
|
so what is the reasoning behind "never write if" in code? i understand trying to minimize the number of branches, so the code is easier to reason about, but never writing ifs ever? or never writing ifs speficifally, but switches and ?: being ok? i did do a coding excercise like that once, and it was pretty fun as a challenge
|
# ? May 24, 2016 07:33 |
Wheany posted:so what is the reasoning behind "never write if" in code?
|
|
# ? May 24, 2016 07:51 |
|
ive been using avro as a serialization format for some one-way record streaming stuff and its worked out p well. avro's nice for streaming because the spec defines a framing format so you dont have to invent your own every time. seriously why didnt protobuf at least define some kind of convention for like a size header to use when dealing with a list of multiple adjacent records, it could've just been '8 bits of magic followed by 24 bits of size' and itd have been plenty; lol at anyone with a 16mb proto message. also the avro schema can either be provided up-front with the data or in a separate channel, making the data fully self-describing, while the records themselves have little overhead since any decoding fully depends on the contents of the provided schema avro specifies its own socket protocol too, but afaict the only existing implementation of that, even among all the first party libs, only exists in the java lib, which sorta makes sense given the hadoop lineage. but im intending to support 4-5 or so different langs (which all do have good 1st-party or 3rd-party serialization implementations) and i dont want to require more diying than necessary for users of the interface so for the streaming over a socket part i ended up just going with 'send the data as avro object file format over a tcp session, and if the receiver doesn't like something it closes the socket, at which point the sender should get its poo poo together and attempt to reconnect/resume where it left off'. unlike the socket protocol this file format is pretty widely supported, and easy to diy given a serialization lib if it isnt. this 'protocol' isnt super robust in non-hiccup cases (eg say the receiver/sender are completely incompatible somehow, or say the sender is configured with the wrong port entirely and should stop sending to the wrong endpoint) but this is just for sending over localhost anyway so close enough. also the cool part of using a plain standard format over plain tcp is that it means i can test things by just using nc to send/recv data directly, and the files themselves have a bunch of tools thatll operate against them directly too anyway if you got a bunch of structured data to move around and/or store in a consistently standardized format then avro might be right for you
|
# ? May 24, 2016 07:59 |
|
Wheany posted:i understand trying to minimize the number of branches, so the code is easier to reason about, but never writing ifs ever? or never writing ifs speficifally, but switches and ?: being ok? e: like 20 minutes of messing around and gcc optimizes ternaries comparing structs as well as simple values into cmov, although it does have to copy the struct members around after figuring out the pointer to it https://godbolt.org/g/uQtFTN arm w/ gcc is branching w/ an ite, not sure if that's cheaper than a real branch
|
# ? May 24, 2016 08:09 |
|
|
# ? May 24, 2024 17:43 |
whoa i was sitting on some poo poo rear end old anaconda apparently, its all cloud and poo poo in this version i just set up
|
|
# ? May 24, 2016 08:19 |