Metadata and uniform declarations #1858
joaosigma
started this conversation in
Language design
Replies: 2 comments 12 replies
-
Carbon doesn't use |
Beta Was this translation helpful? Give feedback.
10 replies
-
Could you please change that to "programmer"? C++ and Carbon programmers aren't necessarily "guys". |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
After reading the design specification I have the feeling that the language can become as verbose, and therefore as difficult, as C++ eventually became. For an initial design, there are already a lot of keywords, and (in my opinion) weird things like ! for generics: why are we negating them?
I think that (and I hope it isn't already too late), one should try and come up with a way to express all the different options that the language offers (and even future ones) in a more clean and easy way.
Taking into account that in Carbon,
<>
isn't used (well, at least not as in C++), why not use it to declare "metadata" in vars, classes, functions, etc.? For example:Forget about
let
,mut
and other stuff. There's justvar
, that simple. We can change the behavior of thatvar
by specifying options inside<>
. There's no need to create a:
operator to indicate the type.Inside the
<>
scope, the options are not keywords, and user-defined types must be prefixed with:
(or some other keyword).For the hardcore C++ programmer, one could do:
Also, I don't think that using
<>
would make the parser more complex, because the pair would have to come aftervar
,class
,fun
, or whatever keyword that needs to be "configured".Applying this design to classes:
If we want that class to extend another class and be abstract / base or sealed:
What about generics?
I used
?
instead of!
: I think it's more readable because we simply don't know the type.For example, a specialization:
Remove the
impl as Data {}
, just declare the class has being a POD (and also with packing alignment specified):To have the class be an interface:
And what about functions?
In the parameter list and return type, the
var
is implicit before the<>
pairs.A generic function, with a constraint, and also marked pure:
Other stuff might include "tail return", "build: development", etc.
In class methods:
The syntax allows us to "extend" declarations, like for example:
More "random" stuff (geared towards gaming):
I could give more examples, but I think this is enough for the point I'm trying to make.
Beta Was this translation helpful? Give feedback.
All reactions