|
Boiled Water posted:don't be daft javascript sucks rear end but implicit semicolon insertion is the least of it
|
# ? Jul 31, 2020 14:57 |
|
|
# ? Oct 4, 2024 12:43 |
|
Private Speech posted:how do people feel about #pragma once? It's supported in the environments I write C, and harder to screw up than standards compliant defines, so I use it and it's good. My projects usually aren't complicated.
|
# ? Jul 31, 2020 15:02 |
|
Private Speech posted:how do people feel about #pragma once? I totally buy that it's incredibly difficult, and probably impossible, to implement #pragma once perfectly. as someone not implementing a c compiler, I'm not sure I care. though now I'm trying to come up with an example I'm remotely likely to run into that doesn't result in a compile or link error also wouldn't have a problem switching to include guards or whatever. seems weird to stan for the specific spelling of #pragma once
|
# ? Jul 31, 2020 15:26 |
|
it's C, just say the complicated edge cases are undefined behavior and let the user deal with the fallout.
|
# ? Jul 31, 2020 15:36 |
|
Blinkz0rz posted:javascript sucks rear end but implicit semicolon insertion is the least of it agreeing with both parts of this statement
|
# ? Jul 31, 2020 15:36 |
|
Private Speech posted:how do people feel about #pragma once? quote:#pragma once has no such safety net -- if the compiler is wrong about the identity of a header file, either way, the program will fail to compile. If you hit this bug, your only options are to stop using #pragma once, or to rename one of the headers. so, am I reading this right: - #pragma once has bugs - in the event you hit such a bug, your code won't compile and you will be forced to remove #pragma once - therefore, you should remove #pragma once ?
|
# ? Jul 31, 2020 15:41 |
|
NihilCredo posted:so, am I reading this right: well in that case you have to mix include guards and pragma once, or forego them for the file, so I guess the argument is you might as well use include guards in the first place of course if your include guard is just the filename then it's the same thing and not any easier to fix (in a systematic way that is) there's also the support argument but that seems to be near universal these days e: here's what cppcoreguidelines says on the topic: quote:Some implementations offer vendor extensions like #pragma once as alternative to include guards. It is not standard and it is not portable. It injects the hosting machine's filesystem semantics into your program, in addition to locking you down to a vendor. Our recommendation is to write in ISO C++: See rule P.2. but then cppcoreguidelines are edited by the same people as the C++ standard so Private Speech fucked around with this message at 17:03 on Jul 31, 2020 |
# ? Jul 31, 2020 15:46 |
|
Private Speech posted:how do people feel about #pragma once? it's still technically non-standard, although i've used it since forever and never had an issue with it and it's supported everywhere unless you are using something very old or obscure. the identical filename issue is resolved by resolving absolute paths for everything and using that as your identifier. i have had issues with #ifdef guards where a project might contain, say, it's own FOO_H guard which collides with a library header that also defines it's own FOO_H guard there were performance concerns with #pragma once a long time ago, although i would imagine that it's been addressed. in theory it should be faster since the compiler doesn't have to actually open and parse the header file before knowing if it should be ignored
|
# ? Jul 31, 2020 15:51 |
|
someone on the stackoverflow thread ran a test and it's indeed slightly faster these days, though it's on the order of seconds for something with thousands of files
|
# ? Jul 31, 2020 15:57 |
|
I use it, my coworkers use include guards and mix and match any number of leading or trailing underscores around the uppercase filename. Sometimes with a _H even though the header is .hpp, sometimes they don’t get the filename right. We’re going to have a CONFIG_H collision before any other scenario that breaks #pragma once.
|
# ? Jul 31, 2020 16:35 |
|
quote:(The short version of why this is unfixable is that neither the Unix nor the Windows filesystem API offer any mechanism that guarantees to tell you whether two absolute pathnames refer to the same file. If you are under the impression that inode numbers can be used for that, sorry, you're wrong.) am i reading this wrong or will you only hit this bug if you have hard-/softlinked .h files in your include path that refer to the same actual file? that seems like user error to me
|
# ? Jul 31, 2020 16:39 |
|
imo the situations where pragma once doesn't work are all things you shouldn't be doing anyway and if you ever manage to hit them (approximately zero percent of people will) then the fact that it forces you to unfuck your header inclusions is a feature
|
# ? Jul 31, 2020 16:58 |
|
is it really only filesystem fuckery that does it? i cant imagine actually hitting that manually unless you have some CI setup that does it, but even then your header should only be in 1 location.
|
# ? Jul 31, 2020 17:00 |
|
also if you're doing that you deserve to have your builds hosed up
|
# ? Jul 31, 2020 17:00 |
|
CRIP EATIN BREAD posted:also if you're doing that you deserve to have your builds hosed up
|
# ? Jul 31, 2020 17:12 |
|
CRIP EATIN BREAD posted:also if you're doing that you deserve to have your builds hosed up i'd even extend that to "if the filesystem is in a weird state i want the build to fail rather than pretending it's ok"
|
# ? Jul 31, 2020 17:40 |
|
error: your headers are all hosed up and your file system is poo poo
|
# ? Jul 31, 2020 18:05 |
|
quote:(Historical note: The only reason I didn't rip #pragma once and #import out of GCC when I had the authority to do so, ~12 years ago, was Apple's system headers relying on them. In retrospect, that shouldn't have stopped me.) of COURSE this was written by some breathtakingly arrogant Apple fuckstain, how am I not surprised "I would have unilaterally imposed my own opinions onto a very widely used piece of software, drat the consequences, were it not for the fact that Daddy would have been inconvenienced" Apple delenda est
|
# ? Jul 31, 2020 19:02 |
|
If your compiler doesn't special case classic include guards to behave like pragma once (that is, don't open the file), you need a better compiler. If your build runs into pragma once bugs, you either need a better platform (sorry Bloomberg guys), or stop doing stupid poo poo with your file system.
|
# ? Jul 31, 2020 20:14 |
|
Sapozhnik posted:of COURSE this was written by some breathtakingly arrogant Apple fuckstain, how am I not surprised uh, you read that incorrectly. he didn't rip out pragma once specifically because he didn't work for apple and so was unable to fix their system headers to not need it
|
# ? Jul 31, 2020 20:57 |
|
Indeed I did, fair enough
|
# ? Jul 31, 2020 21:22 |
|
echinopsis posted:
Use a linter. It will protect you from this and many other things.
|
# ? Jul 31, 2020 21:56 |
|
my favorite js linter is rm -rf *
|
# ? Jul 31, 2020 22:44 |
|
Doom Mathematic posted:Use a linter. It will protect you from this and many other things. is that something that makes it colourful
|
# ? Jul 31, 2020 23:18 |
|
jesus WEP posted:get used to putting a semicolon at the end of each statement, it’s good practice for if you migrate to an actually useable language someone set up the linter to make it an error to use a semicolon in js where not absolutely required and i don't think i've ever been so mad about a formatting decision
|
# ? Jul 31, 2020 23:22 |
|
Yeah unfortunately you have to pile a whole bunch of poo poo on top of JavaScript to make it even slightly bearable to work with. At an absolute bare minimum: Install and use Visual Studio Code (a text editor) Install nodejs so that you can use npm so that you can install stuff Install eslint into your project directory using npm Install the eslint plugin for vscode. VSCode will now yell at you if you do something dumb in JavaScript. Since JavaScript is extremely bad it is surprisingly easy to do something dumb in JavaScript. I would strongly recommend that you also install Prettier (using npm) and its associated vscode plugin, then configure vscode to automatically reformat your code every time you save. Doesn't seem like such a big deal but having continuous auto-formatting frees up your mind from having to do a whole lot of tedious formatting poo poo work.
|
# ? Jul 31, 2020 23:38 |
|
echinopsis posted:is that something that makes it colourful thats syntax highlighting a linter does code cleanup stuff. it might catch some errors & alert you to potential problems, but mostly its just to make your code look nice according to whatever standard you choose to configure it to
|
# ? Jul 31, 2020 23:51 |
|
also, for syntax highlighting, you should use a dark theme for maximum hackitude
|
# ? Jul 31, 2020 23:53 |
|
use webpack op
|
# ? Jul 31, 2020 23:59 |
|
Xarn posted:If your compiler doesn't special case classic include guards to behave like pragma once (that is, don't open the file), you need a better compiler. if you need to use special incantations to stop everything breaking due to a file being processed more than once, you need a better language
|
# ? Aug 1, 2020 01:52 |
|
Carthag Tuek posted:my favorite js linter is rm -rf *
|
# ? Aug 1, 2020 01:55 |
|
Soricidus posted:if you need to use special incantations to stop everything breaking due to a file being processed more than once, you need a better language but how will i win the trivia wars
|
# ? Aug 1, 2020 02:18 |
|
Sapozhnik posted:of COURSE this was written by some breathtakingly arrogant Apple fuckstain, how am I not surprised are you sure he was from apple, it sounded to me like he just didn't want to break compatibility for a major player but lol breaking compatibility sure as hell wouldn't ever stop apple from anything ever are c++ modules going to make this stupid problem go away?
|
# ? Aug 1, 2020 03:15 |
|
what is the point of d. it seems like at best a somewhat less warty c++?
|
# ? Aug 1, 2020 04:53 |
|
there is a brutal need for a less warty cpp d guy failed but it was worth a try. prolly rust peeps will make a solid dent
|
# ? Aug 1, 2020 04:54 |
|
Carthag Tuek posted:my favorite js linter is rm -rf *
|
# ? Aug 1, 2020 04:57 |
|
Bloody posted:what is the point of d. it seems like at best a somewhat less warty c++? sometimes the only way to learn is to fail. someone will take d (heh) and learn from the mistakes.
|
# ? Aug 1, 2020 05:21 |
|
Bloody posted:what is the point of d. it seems like at best a somewhat less warty c++? that was the point. it came out close to 20 years ago now, and it just never took off. e: it also made some mistakes too, but it was an iterative improvement to learn from
|
# ? Aug 1, 2020 05:21 |
|
c/c++ includes are some real plang poo poo
|
# ? Aug 1, 2020 06:00 |
|
|
# ? Oct 4, 2024 12:43 |
|
d’s point has always been that Walter bright had enough money to retire but he enjoyed his job enough that he kept doing it for fun
|
# ? Aug 1, 2020 06:02 |