|
necrotic posted:Also someObject['!+#%'] works found one
|
# ? Nov 18, 2014 22:54 |
|
|
# ? May 28, 2024 08:35 |
|
necrotic posted:Also someObject['!+#%'] works but someObject.!+#% will definitely not. Can't tell you how many times that's come in handy because it never has.
|
# ? Nov 18, 2014 22:55 |
|
You can also set properties dynamically using someObject[someStringVariable]. Since someStringVariable can be any string, including the empty string or something with spaces or slashes, you might need someObject[''] etc. to get the value back out again.
|
# ? Nov 18, 2014 23:02 |
|
DimpledChad posted:Can't tell you how many times that's come in handy I'm not saying its useful at all.
|
# ? Nov 18, 2014 23:22 |
There's plenty of valid reasons to hate on javascript, but this isn't one of them
|
|
# ? Nov 18, 2014 23:31 |
|
DimpledChad posted:Can't tell you how many times that's come in handy You, uh, just did.
|
# ? Nov 19, 2014 00:29 |
|
KARMA! posted:someObject['name' + i] and someObject[anotherVariable]. That's obviously the correct use for accessing properties in objects like that, but I specifically said, "You already know the property name." necrotic posted:Also someObject['!+#%'] works but someObject.!+#% will definitely not. That... Sorta makes sense.
|
# ? Nov 19, 2014 00:37 |
|
code:
|
# ? Nov 19, 2014 00:39 |
|
DimpledChad posted:Can't tell you how many times that's come in handy Oh really, you've never accessed a Javascript array like xs[0]?
|
# ? Nov 19, 2014 01:28 |
|
Deus Rex posted:Oh really, you've never accessed a Javascript array like xs[0]? JavaScript array indexing and JavaScript object property access are different things, despite having identical syntax.
|
# ? Nov 19, 2014 02:16 |
|
Deus Rex posted:Oh really, you've never accessed a Javascript array like xs[0]? I meant accessing an object property like foo['*&Q#$^*']. I'm not really saying that in particular is a misfeature. It's actually sometimes useful to access an object property as a string. But if someone gave a property a name that could ONLY be accessed that way, I would punch them in the face.
|
# ? Nov 19, 2014 02:37 |
|
You'd punch me in the face if I ever used a hash map in JS?
|
# ? Nov 19, 2014 02:40 |
|
No, if you deliberately named an object property with special characters like that. It's petty, I know, but it offends my sensibilities. Okay, if you had a really good reason... But yeah I guess it would be fine in the context of a plain hash map, if you needed special characters in the keys. The thing I was thinking of that would make me mad is the following: code:
|
# ? Nov 19, 2014 02:49 |
|
In older versions of javascript, you needed to de-reference an object property in that way if it was a javascript reserved word. This was an unnecessary flaw in the original language spec. This flaw is also the reason why the json spec requires you to put quotes around the object property.
|
# ? Nov 19, 2014 03:23 |
|
GrumpyDoctor posted:JavaScript array indexing and JavaScript object property access are different things, despite having identical syntax. Probably sarcasm considering the smiley, but nope. Try arr["0"].
|
# ? Nov 19, 2014 04:02 |
|
"... and a 534 other ways to reload the page with JavaScript"
|
# ? Nov 19, 2014 04:03 |
|
GrumpyDoctor posted:JavaScript array indexing and JavaScript object property access are different things, despite having identical syntax. No, they are the same get-property operation. Try arr["0"], for example. e: Sir Dish
|
# ? Nov 19, 2014 04:15 |
|
Ithaqua posted:The people who don't care about being paid a fair market value for their skills are almost always lovely; the reason they don't care is because they're just grateful that they were able to convince someone to hire them. Well i took my current medium paid role in a large enterprise company for job security. I was on 50,000 UKP a year on previous jobs and have taken a 15,000 UKP pay cut for my current job, but i am guaranteed a position until the end of 2015 and very probably for the next 10 years if i want it. I have had too many jobs where i have been in a short term role for 6 months to a year. but its time to settle down. the pay was nice but hey job security is even better.
|
# ? Nov 19, 2014 08:34 |
|
I found this gem yesterday.code:
|
# ? Nov 19, 2014 14:00 |
|
Illusive gently caress Man posted:
This is what I don't understand. Dealing with endianness is so bloody easy in C, so why do people gently caress it up? Here, do it like this: code:
It's really not hard to get right. Why do people gently caress it up?
|
# ? Nov 19, 2014 17:24 |
|
Doesn't that violate aliasing or something? Use a union.
|
# ? Nov 19, 2014 17:42 |
|
Why are you reimplementing be32toh() and what does that have to do with the coding horror posted?
|
# ? Nov 19, 2014 17:47 |
|
sarehu posted:Doesn't that violate aliasing or something? Use a union. Or use masks and shifts like god intended.
|
# ? Nov 19, 2014 17:54 |
|
With regard to using macros here, you might not always know the endianness of your target system at compile time. Some processor architectures (I'm looking at you PowerPC) can run in both little and big endian modes depending on a flag you can set in a register.
|
# ? Nov 19, 2014 18:06 |
|
quote:It's really not hard to get right. quote:Doesn't that violate aliasing or something? quote:Why are you reimplementing be32toh() be32toh is nonstandard. The Android libc/NDK didn't (use?) to have it, for example. astr0man posted:With regard to using macros here It would've worked (or not) with an if just as well. Totally orthogonal to the issue.
|
# ? Nov 19, 2014 18:20 |
|
astr0man posted:With regard to using macros here, you might not always know the endianness of your target system at compile time. Some processor architectures (I'm looking at you PowerPC) can run in both little and big endian modes depending on a flag you can set in a register. Now I want a solution that just sets the appropriate flag instead of byte swapping.
|
# ? Nov 19, 2014 18:23 |
|
sarehu posted:Doesn't that violate aliasing or something? Not if the referencing pointer is char *, right? I think that's the C99 rule.
|
# ? Nov 19, 2014 18:24 |
|
NFX posted:Now I want a solution that just sets the appropriate flag instead of byte swapping. An operating system that regularly did this would be appropriate for this thread
|
# ? Nov 19, 2014 18:28 |
|
Skuto posted:be32toh is nonstandard. The Android libc/NDK didn't (use?) to have it, for example. htonl?
|
# ? Nov 19, 2014 18:29 |
|
astr0man posted:An operating system that regularly did this would be appropriate for this thread To my hilariously non-expert knowledge, if you were byte-swapping a ton of data and the penalty for changing the current CPU mode was low enough, it might make sense to do it. But I'm guessing you're right.
|
# ? Nov 19, 2014 18:37 |
|
Subjunctive posted:Not if the referencing pointer is char *, right? I think that's the C99 rule. I think you can cast it to char* but after that aren't allowed to touch it again as the int? There's some reason why it's not recommended, anyway. Just use unions. e: http://cellperformance.beyond3d.com/articles/2006/06/understanding-strict-aliasing.html Ah, what I was thinking of is casting the char* back to something else. Admiral H. Curtiss fucked around with this message at 18:43 on Nov 19, 2014 |
# ? Nov 19, 2014 18:39 |
|
Skuto posted:be32toh is nonstandard. The Android libc/NDK didn't (use?) to have it, for example. The original horror is using it, the reason why it is a horror is the overly convoluted pointer manipulation to byteswap the array.
|
# ? Nov 19, 2014 18:42 |
|
Admiral H. Curtiss posted:I think you can cast it to char* but after that aren't allowed to touch it again as the int? There's some reason why it's not recommended, anyway. Just use unions. No, char * is special as char is always assumed to alias other types.
|
# ? Nov 19, 2014 18:45 |
|
pseudorandom name posted:Why are you reimplementing be32toh() and what does that have to do with the coding horror posted? The bikeshed in question was for a freestanding kernel (no standard library and certainly no POSIX implementation), so I had to write the code. And isn't the original horror a byte-swapper? I actually didn't read it too closely, but whenever I see impenetrable code saying something about "endian" followed by weird address and/or shift manipulations, I assume that someone misunderstood endianness.
|
# ? Nov 19, 2014 18:47 |
|
EDIT: nvm
|
# ? Nov 19, 2014 18:47 |
|
rjmccall posted:EDIT: nvm aw, c'mon man, I can take it.
|
# ? Nov 19, 2014 18:50 |
|
astr0man posted:With regard to using macros here, you might not always know the endianness of your target system at compile time. Some processor architectures (I'm looking at you PowerPC) can run in both little and big endian modes depending on a flag you can set in a register. ARMv7 allows this too. My employer did a big-endian ARM port of a Linux distribution for a customer where that was easier than porting all their existing software. The fun bit was that rather than building a Linux compiled for big-endian and doing some magic to make the CPU start in big-endian mode, rather than defaulting to little, as part of boot the first thing the kernel did was to swap the endianness to big, so the majority of the kernel and all of the userland could operate in big-endian mode. I think we could even switch to little-endian in userland, but you'd have to switch back to big to make system calls.
|
# ? Nov 19, 2014 18:52 |
|
linusBorlaug posted:I found this gem yesterday.
|
# ? Nov 19, 2014 20:28 |
|
Does this qualify as a coding horror? https://github.com/naetech/nightrainquote:Create your next OS X, Windows or Linux desktop application in pure PHP, CakePHP, Laravel, or whatever PHP framework you like. PHP Nightrain is a packager written in Python for the PHP Programming Language. Using this tool you can convert your PHP/HTML/CSS/Javascript application to a Native Desktop Application. Currently, PHP Nightrain supports the Windows, Mac (OS X) and the Linux operating systems.
|
# ? Nov 19, 2014 21:55 |
|
|
# ? May 28, 2024 08:35 |
My only question is why
|
|
# ? Nov 19, 2014 21:57 |