|
MeruFM posted:Also python owns coffeetable fucked around with this message at 20:12 on Jan 18, 2014 |
![]() |
|
![]()
|
# ? Jun 16, 2024 09:02 |
|
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.
|
![]() |
|
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.
|
![]() |
|
coffee table do you have a job yet
|
![]() |
|
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?
|
![]() |
|
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 |
![]() |
|
MeruFM posted:Yeah that's scope. But what about visibility? public, private, protected
|
![]() |
|
I get it now. I thought scope covered both of those ideas and just called them all scope. Private scope, global scope, block scope.
|
![]() |
|
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
|
![]() |
|
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.
|
![]() |
|
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
|
![]() |
|
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"
|
![]() |
|
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
|
![]() |
|
gucci void main posted:or better yet, don't use python at all
|
![]() |
|
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
|
![]() |
|
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. ----------------
|
![]() |
|
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
|
![]() |
|
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?
|
![]() |
|
the allocator maintains its own metadata about allocations, because what it actually allocates may not always be exactly what you asked for
|
![]() |
|
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
|
![]() |
|
well here's a sample of what i've got:code:
|
![]() |
|
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.
|
![]() |
|
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 |
![]() |
|
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
|
![]() |
|
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?
|
![]() |
|
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 |
![]() |
|
const all strings
|
![]() |
|
you either got const strings or const bitches or something like that
|
![]() |
|
also always postpend const char const * const supremacy
|
![]() |
|
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
|
![]() |
|
more like a 40 year old argument
|
![]() |
|
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
|
![]() |
|
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
|
![]() |
|
c was designed by a guy who wrote ed
|
![]() |
|
tbd back then they thought a text editor came from the typing pool
|
![]() |
|
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
|
![]() |
|
also maybe they made that less insane in c99 i haven't written c since 1995
|
![]() |
|
of course they didn't, that would break backward compatibility
|
![]() |
|
Dessert Rose posted:also maybe they made that less insane in c99 i haven't written c since 1995 Lets be honest, nobody has
|
![]() |
|
![]()
|
# ? Jun 16, 2024 09:02 |
|
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.
|
![]() |