News for hackers. Stuff that matters.
Re:C2x: the next real revision of the C standard by stinos on Monday November 12, 2018 @08:04AM (#18432334)
You can use C++ as some kind of C with destructors though :P Scoped cleanup is really a nice thing..

But then you also want templates of course to get rid of your void*. And oh, wait, what's that? A cross-platform thread implementation (well, sort of, depends on platform)? A string thing which I can search without strstr? Anonymous functions which capture? Auto? Gimme gimme :]

Re:C2x: the next real revision of the C standard by beefhash on Monday November 12, 2018 @08:32AM (#18432460)
> You can use C++ as some kind of C with destructors though :P Scoped cleanup is really a nice thing..

C++ is not a strict superset of C. You actually have to cast void pointers, for example.

> But then you also want templates of course to get rid of your void*.

No, actually, I think I can live without that, but thank you.

> And oh, wait, what's that? A cross-platform thread implementation (well, sort of, depends on platform)?

C11, threads.h. Been there, got that.

> A string thing which I can search without strstr?

Okay, I'll give you that, string handling is hell.

> Anonymous functions which capture?

Have their uses, but I'm not sure if C is really the right place for it.

> Auto?

auto (as used in C++11 and later) is a solution in need of a problem in C. When you don't have piles of templates and iterators, you also tend not to need to automatically derive types. In a world where signed/unsigned integer comparison can have fatal consequences, you probably do want to be very sure about your types.

Re:C2x: the next real revision of the C standard by stinos on Monday November 12, 2018 @11:50AM (#18433697)
> C++ is not a strict superset of C.

I know that. I use both C and C++ practically daily. The post was partly joking. But only partly (for example of course I could live without templates if really needed but seriously they make some jobs a lot better and easier). Hence I aptly phrased it some kind of C hoping (idly it seems) no one would trip over it because it's obviously not C.

Re:C2x: the next real revision of the C standard by rubber_duck on Monday November 12, 2018 @08:56AM (#18432587)
>C++ is not a strict subset of C.

I think you flipped this :) ?

Re:C2x: the next real revision of the C standard by saagarjha on Monday November 12, 2018 @09:02AM (#18432616)
I mean, it’s not wrong…
Re:C2x: the next real revision of the C standard by beefhash on Monday November 12, 2018 @09:59AM (#18432950)
Oops. Edited a fix in.
Re:C2x: the next real revision of the C standard by maxxxxx on Monday November 12, 2018 @11:17AM (#18433459)
Sometimes I wonder if a C++ without inheritance would be the right thing. All the crazy design abuses I have seen were around inheritance. Other things like auto and anonymous functions are just super useful and I wouldn't want to miss them.
Re:C2x: the next real revision of the C standard by Dylan16807 on Monday November 12, 2018 @09:25AM (#18432741)
I don't think those other features are half as compelling as you think they are.
Re:C2x: the next real revision of the C standard by stinos on Monday November 12, 2018 @11:41AM (#18433623)
Using both C and C++, each in their place, I actually do think they are.
Re:C2x: the next real revision of the C standard by Dylan16807 on Monday November 12, 2018 @06:07PM (#18436842)
Then why ever use C if they're that compelling? I'm not really understanding how wanting one little thing from C++ implies diving all the way in.
Re:C2x: the next real revision of the C standard by stinos on Tuesday November 13, 2018 @03:53AM (#18439624)
Then why ever use C

Because some platforms I've used it on did't have proper C++ support. Or because a project I contribute to is already written in C. Or because of limited resources. Etc.

I'm not really understanding how wanting one little thing from C++ implies diving all the way in.

It's just an example of a possible train of thought. And I wouldn't call something like templates 'one little thing'. So suppose there's a choice between both, and no limit on resources etc, and I could go for everything C but templates could make everything easier then just going for C++ instead is an option. Even when not going 'all in' and writing what looks like standard C + template support.

Re:C2x: the next real revision of the C standard by Dylan16807 on Tuesday November 13, 2018 @04:49AM (#18439832)
> And I wouldn't call something like templates 'one little thing'.

Agreed. But templates aren't the one little thing, they're something you said would be 'next'. The 'one little thing' is a way to replace the GOTOs used for releasing resources. I think it's an easy argument that when people are repeatedly building a pattern out of GOTO, there's a gap in the control flow tools that a language gives you.

Re:C2x: the next real revision of the C standard by jfoutz on Monday November 12, 2018 @12:04PM (#18433822)
Auto is already taken in C. It’s the default, rather than register or static, so you hardly ever see it
Re:C2x: the next real revision of the C standard by kazinator on Monday November 12, 2018 @01:49PM (#18434657)
auto was taken in exactly the same way in C++ until fairly recently. They re-purposed it because it was obsolescent.

auto was already in vanishing disuse in C at the time ANSI C came out in 1989.

The C++ use of auto resurrects an aspect of the way auto was used in the C predecessor languages B and NB.

In these pre-C languages, everything was an integer cell. A declaration of local variables looked like this:

   auto x, y;
the auto meant automatic storage (stack), but the real purpose here is syntactic: the auto is a declaration specifier, which makes the above construct a declaration. There is no indication of type, because it is implicit. Without the auto it would look like a comma expression with no effect.

This implicit typing survived into C for "implicit int" return values, like "main () {...}". But type specifiers were introduced and became mandatory in declarations, and so auto became unnecessary verbiage since all it did now was specify a storage class that was already the default one.

C++ resurrect the syntactic use of auto in a way: once again, it provides declaration syntax that allows the type specifier to be omitted. This time, of course, that type is inferred rather than assumed integer.

Re:C2x: the next real revision of the C standard by jfoutz on Monday November 12, 2018 @02:20PM (#18434883)
This is a great thoughtful reply to my terse, shallow comment. Thank you. It’s insightful