- Joined
- Dec 12, 2022
Use the right tool for the job, I say.i should man up and start writing everything in C89
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Use the right tool for the job, I say.i should man up and start writing everything in C89
to be fair until reading the article i thought this was already in the standard, since i'm pretty sure i have written code that used itThe new if declaration thing is a welcome intrusion of Go into C
50 years after the creation of the language, we finally have true and false in Cto be fair until reading the article i thought this was already in the standard, since i'm pretty sure i have written code that used it
C23 added a lot of nice things, like binary literals or that you can make enums not int-wide, some guy even sent a letter thanking for #embed (sorry for using the tranny furfag as the source, its the only one i could find)
also constexpr variables are useful, since theyre typechecked macros
the addition of digit separators also makes reading some values easier
in general C23 added a lot of nice things to C, while still keeping it C, instead of making it C++
I like the labeled break personally, I've often used goto in a similar capacity to break out of multiple layers. I think while the new syntax doesn't do anything new, the explicitness of it is really nice.Technically, sure, but I know Common Lisp and Ada both provide the option to name certain program units specifically to avoid this problem of leaving nested units. Ada in particular allows the programmer to name just about anything, to an extreme degree, however. I've used goto in Ada once, when writing some Task exiting code that wasn't as pretty as I'd like. The Ada solution to goto is to make the labels ugly; they look like this:
It's clear, at least. There are also the usual rules about not jumping into the middle of control constructs from outside of them and things like that.Code:goto Label; -- Damn, no Ada syntax for code blocks here. No Pascal either. ... <<Label>>
Amusingly, Common Lisp only has goto as its iteration construct, good oldTAGBODYandGO, they're just wrapped up in so many macros that the programmer never has to deal with them unless he feels like it.
int sneed;
if (!(sneed = get_sneed)) {...}
50 years after the creation of the language, we finally have portable generic ways to check for overflow. Except that MSVC will probably take until 2040 to implement it, lol lmao.50 years after the creation of the language, we finally have true and false in C
amazing
I still don't use bool lol, The ! and !! operators compile into single instructions that use a single bit register in x86 cpus anyhow50 years after the creation of the language, we finally have true and false in C
It's hilarious to me how with all the HM type inference being added everywhere, the older and more well-understood restricted boolean inference traditional to C syntax is seen as a "bad thing".we finally have true and false in C
t.It's hilarious to me how with all the HM type inference being added everywhere, the older and more well-understood restricted boolean inference traditional to C syntax is seen as a "bad thing".
//boolean.h
#ifndef BOOLEAN_H
#define BOOLEAN_H
#define FALSE 0
#define TRUE !FALSE
#endif
#define TRUE in C is an antipattern that breaks logic, eg.int a=2;
if(a==TRUE){printf("never reached\n");}
? It executes the print#define TRUEin C is an antipattern that breaks logic, eg.
Code:int a=1; if(a==TRUE){printf("never reached\n");}
Doesn't stop people from doing it but neither did Rust.
a=2 then, ought to be "true" but not TRUE.? It executes the print
He's pointing out that, while falsehood has a canonical value, truth doesn't.? It executes the print
Yes it does, it's not 0He's pointing out that, while falsehood has a canonical value, truth doesn't.

a=2 then, ought to be "true" but not TRUE.
Both true from bool.h or later C standards and #define behave the same way (in a = 1 and in a = 2 cases) therefore #define TRUE cannot be considered anti pattern.He's pointing out that, while falsehood has a canonical value, truth doesn't.
The antipattern is that two variables that are functionally equivalent in value are not recognized as such by the syntax. It has nothing to do with whether an approach is canonical or not.therefore #define TRUE cannot be considered anti pattern.
If you were to have the way that you want it you would end up with JavaScript.The antipattern is that two variables that are functionally equivalent in value are not recognized as such by the syntax. It has nothing to do with whether an approach is canonical or not.
Yeah, it's not as if the C language is filled with shit that's got big glaring Do Not Touch warnings all over it.Both true from bool.h or later C standards and #define behave the same way (in a = 1 and in a = 2 cases) therefore #define TRUE cannot be considered anti pattern.
⍳4 ⍝ Iota generates an array of numbers starting from zero or one to the provided value.
1 2 3 4
0 1 0 1/⍳4 ⍝ A forward slash acts as a filter, where true keeps the element and false discards it.
2 4
(⍳4)/⍳4 ⍝ However, we're not limited to true and false.
1 2 2 3 3 3 4 4 4 4
Absolutely not. What I am proposing here is nothing more or less than asserting that defining TRUE on a C platform is semantically-inaccurate and obfuscating. Acceptable values of TRUE involve anything that is not zero. What I'm saying is that using defines and constants for this purpose is niggerlicious, not divine intellect.If you were to have the way that you want it you would end up with JavaScript.
Such as? C design is perfectly sensible for single-pass compiled procedural language - most of the cases that i have seen people complaining about it is because either they haven't thought about what the alternatives are or because they do not understand with being single-pass entails.Yeah, it's not as if the C language is filled with shit that's got big glaring Do Not Touch warnings all over it.
One word:Such as?
gets. The interface is desirable, but not easy to provide as in other languages, although I'm aware GNU provides both getline and the more general getdelim, which are neat.