5 ms·
I hate when c++ does this. I don't want automatic typedefs, keep the struct so I know what it is. Also causes annoying name conflicts ...
by Cloudef 4y ago
I hate when c++ does this. I don't want automatic typedefs, keep the struct so I know what it is. Also causes annoying name conflicts ...
- boardwaalk 4y agoThe number of languages that have separate namespaces for the two things is very small. See all the C descendants that discarded that idea: C++, C#, Java, Rust, Go. You probably ought to just find a decent naming scheme to avoid those conflicts…
- Ontonator 4y agoI can’t speak for the others, but Rust definitely has separate namespaces for them. See https://doc.rust-lang.org/beta/reference/names/namespaces.html https://doc.rust-lang.org/beta/reference/names/namespaces.ht...
- Bytewave81 4y agoNot the type of namespace being referred to. In this case, it's referring to the requirement to refer to all types of a certain category with a keyword, as in `struct Foo`. In Rust, you can refer to a struct named Foo as just `Foo`.
- Ontonator 4y agoI disagree. There may not be a keyword required to refer to `struct`s specifically, but the namespace that is searched when resolving a symbol is determined by the syntax used to refer to it. For example, in C++, you cannot determine whether `a` is a type or a value in the statement `a * b;` without knowing how it is declared, and C also has this ambiguity once `typedef`s are involved. In Rust, there are no such ambiguities (unless there's something I've missed).
- hvdijk 4y agoC++ didn't discard that idea entirely, you can have a struct tag and a function with the same name and you need to be able to do that in order to use stat().
- deleted 4y ago[deleted]
- xigoi 4y agoWhy would you want to expose implementation details?
- lwswl 4y agoc++ just understands that the only purpose you could e using it for is "struct foo". if you have a function "int foo()" as well, then you'll still need the struct tag(which really is necessary because you can do things like call structs like functions)