|
MeruFM posted:Also python owns coffeetable fucked around with this message at 20:12 on Jan 18, 2014 |
# ? Jan 18, 2014 20:07 |
|
|
# ? May 23, 2024 04:53 |
|
List comprehension is neater than map reduce for anyone newRICHUNCLEPENNYBAGS posted:how are you tutoring people dude iunno, please tell me the difference so I won't spread my misknowledge.
|
# ? Jan 18, 2014 20:08 |
|
MeruFM posted:List comprehension is neater than map reduce for anyone new like a variable can be scoped to a block and not be accessible from outside that block or it can be globally scoped and be accessible from everywhere. idk you're the tutor you explain it.
|
# ? Jan 18, 2014 20:12 |
|
coffee table do you have a job yet
|
# ? Jan 18, 2014 20:14 |
|
RICHUNCLEPENNYBAGS posted:like a variable can be scoped to a block and not be accessible from outside that block or it can be globally scoped and be accessible from everywhere. idk you're the tutor you explain it. Yeah that's scope. But what about visibility?
|
# ? Jan 18, 2014 20:16 |
|
FamDav posted:coffee table do you have a job yet e: as much as it's lonely and goony as gently caress to be livin at home again as a grad, i kinda wish it could last longer because ive never been this productive in my life. six months straight of learning, day in day out. owns. coffeetable fucked around with this message at 20:25 on Jan 18, 2014 |
# ? Jan 18, 2014 20:17 |
|
MeruFM posted:Yeah that's scope. But what about visibility? public, private, protected
|
# ? Jan 18, 2014 20:22 |
|
I get it now. I thought scope covered both of those ideas and just called them all scope. Private scope, global scope, block scope.
|
# ? Jan 18, 2014 20:31 |
|
poo poo piss I thought my dumb bad code wasn't working and then I talked to atmel and their micro turned out to have a known bug that isn't documented unless you email them and they like you that won't be fixed until the changes go into the fab in like April Now I have to do awful bullshit instead of just using the hardware uggghhh
|
# ? Jan 18, 2014 20:48 |
|
it's OK man, i spent hours yesterday trying to get a dumb hd44780 LCD working with an ATmega32U4 and still haven't gotten the loving thing to work. i suspect it's my code, but hell if i could tell you why.
|
# ? Jan 18, 2014 21:34 |
|
MeruFM posted:I get it now. I thought scope covered both of those ideas and just called them all scope. Private scope, global scope, block scope. the concepts are similar enough that your mistake is perfectly reasonable. imo the fact that you noticed how they're both parts of name resolution indicates a deeper understanding than simply being able to repeat the terminology that RICHUNCLEPENNYBAGS wanted
|
# ? Jan 18, 2014 21:54 |
|
JewKiller 3000 posted:the concepts are similar enough that your mistake is perfectly reasonable. imo the fact that you noticed how they're both parts of name resolution indicates a deeper understanding than simply being able to repeat the terminology that RICHUNCLEPENNYBAGS wanted it would be pretty wack if python had "no scoping"
|
# ? Jan 18, 2014 23:48 |
|
JewKiller 3000 posted:the concepts are similar enough that your mistake is perfectly reasonable. imo the fact that you noticed how they're both parts of name resolution indicates a deeper understanding than simply being able to repeat the terminology that RICHUNCLEPENNYBAGS wanted thanks bro, i feel tingly and fulfilled now
|
# ? Jan 19, 2014 04:35 |
|
gucci void main posted:or better yet, don't use python at all
|
# ? Jan 19, 2014 04:51 |
|
Doc Block posted:it's OK man, i spent hours yesterday trying to get a dumb hd44780 LCD working with an ATmega32U4 and still haven't gotten the loving thing to work. i suspect it's my code, but hell if i could tell you why. b/c its crap code
|
# ? Jan 19, 2014 04:58 |
|
Bloody posted:b/c its crap code tested it with a different MCU and it worked fine (see my sig). the code may be crap, but at least it's working crap. bummer that the ATmega32U4 is probably trashed, though. ----------------
|
# ? Jan 19, 2014 05:29 |
|
Mr SuperAwesome posted:well yeah ofc we'd all use c# all the time if we could but sometimes u gotta fix someones lovely python project or interface some ancient mining software with a scripting language that is literally perl to your nice WCF service
|
# ? Jan 19, 2014 06:06 |
|
dumb c question #2: how does free manage to free whole arrays without the length being specified? i thought the point of, say, null terminators in strings was that you couldn't tell the length of the array?? i've been passing around the array length as a param along with the array itself, do i not need to do this?
|
# ? Jan 23, 2014 15:35 |
|
the allocator maintains its own metadata about allocations, because what it actually allocates may not always be exactly what you asked for
|
# ? Jan 23, 2014 15:46 |
|
AlsoD posted:dumb c question #2: how does free manage to free whole arrays without the length being specified? i thought the point of, say, null terminators in strings was that you couldn't tell the length of the array?? terrible programmer answer - everything in c is essentially an implicit pointer, free removes the pointer to the array but not the data inside it. you don't really need to pass the array length unless you need to know it for some reason
|
# ? Jan 23, 2014 15:49 |
|
well here's a sample of what i've got:code:
|
# ? Jan 23, 2014 15:57 |
|
AlsoD posted:well here's a sample of what i've got: This is basically the right way to go about it. You might want to make a function called something like "scale_by_gcd" to break it up a bit but otherwise yeah, that's C. You may also want to stick some asserts in to ensure the pointers are not null and n is > 0, going wild with asserts is never bad. If I'm being really picky n should be a size_t.
|
# ? Jan 23, 2014 18:27 |
|
Zombywuf posted:This is basically the right way to go about it. You might want to make a function called something like "scale_by_gcd" to break it up a bit but otherwise yeah, that's C. slap some restricts on those pointers and/or use c99 style code:
Malcolm XML fucked around with this message at 20:03 on Jan 23, 2014 |
# ? Jan 23, 2014 19:54 |
|
AlsoD posted:dumb c question #2: how does free manage to free whole arrays without the length being specified? i thought the point of, say, null terminators in strings was that you couldn't tell the length of the array?? well, when you requested space for the array with malloc or calloc, you requested N bytes total. malloc actually tries to find a block of size N + M, where M is the size of the malloc's header, which contains info about the size of the chunk and other stuff. malloc returns the address of whatever block it found + M, which to you looks like N bytes, and whenever you pass that block back to free, it can just subtract M from the address, read the header, and free however many bytes. at least thats how most allocators work
|
# ? Jan 23, 2014 21:09 |
|
Phobeste posted:poo poo piss I thought my dumb bad code wasn't working and then I talked to atmel and their micro turned out to have a known bug that isn't documented unless you email them and they like you that won't be fixed until the changes go into the fab in like April which micro and what is the bug?
|
# ? Jan 23, 2014 21:32 |
|
ahh why can't i just return a 4-tuple without having to mess around with defining a strut that'll only ever get used oncecode:
code:
also do i declare that string const? gonadic io fucked around with this message at 02:18 on Jan 24, 2014 |
# ? Jan 24, 2014 02:06 |
|
const all strings
|
# ? Jan 24, 2014 02:12 |
|
you either got const strings or const bitches or something like that
|
# ? Jan 24, 2014 02:21 |
|
also always postpend const char const * const supremacy
|
# ? Jan 24, 2014 02:21 |
|
presumably this is a 20 year old argument but 'char* file_name' seems to make so much more sense than anything else to me. you have the type (pointer to char) and then the name. then you have stuff like 'int *p1, *p2' as opposed to 'int* p1, p2' as it should be imo. being a pointer is a property of the type, not the name! but then, as established, i am a terrible and novice c programmer
|
# ? Jan 24, 2014 02:25 |
|
more like a 40 year old argument
|
# ? Jan 24, 2014 02:29 |
|
AlsoD posted:presumably this is a 20 year old argument but 'char* file_name' seems to make so much more sense than anything else to me. you have the type (pointer to char) and then the name. then you have stuff like 'int *p1, *p2' as opposed to 'int* p1, p2' as it should be imo. being a pointer is a property of the type, not the name! AlsoD was right
|
# ? Jan 24, 2014 02:32 |
|
AlsoD posted:presumably this is a 20 year old argument but 'char* file_name' seems to make so much more sense than anything else to me. you have the type (pointer to char) and then the name. then you have stuff like 'int *p1, *p2' as opposed to 'int* p1, p2' as it should be imo. being a pointer is a property of the type, not the name! int *p: p when dereferenced is an int int* p: p is pointer to an int i guess the former interpretation makes better sense than the latter if you learnt to program before types started showing up
|
# ? Jan 24, 2014 02:43 |
|
c was designed by a guy who wrote ed
|
# ? Jan 24, 2014 02:52 |
|
tbd back then they thought a text editor came from the typing pool
|
# ? Jan 24, 2014 02:55 |
|
AlsoD posted:'int* p1, p2' as it should be you may already know this but [given the thread we're in] that is actually legal c, it just won't result in what you think it will, which is why *p1 is the "standard" if you write "int* p1, p2" p1 is an int* and p2 is an int
|
# ? Jan 24, 2014 03:04 |
|
also maybe they made that less insane in c99 i haven't written c since 1995
|
# ? Jan 24, 2014 03:05 |
|
of course they didn't, that would break backward compatibility
|
# ? Jan 24, 2014 03:29 |
|
Dessert Rose posted:also maybe they made that less insane in c99 i haven't written c since 1995 Lets be honest, nobody has
|
# ? Jan 25, 2014 06:35 |
|
|
# ? May 23, 2024 04:53 |
|
Dessert Rose posted:also maybe they made that less insane in c99 i haven't written c since 1995 nope, you can still do everything the stupid way.
|
# ? Jan 25, 2014 20:34 |