Live data from Hacker News

Carbon’s most exciting feature is its calling convention

foonathan.net

221–223 of 223 posts

Re: Carbon’s most exciting feature is its calling convention

#221
post #217

Earlier quoted context omitted.

They are the same value , but with different identities . vs[0], vs[1] etc. are different objects , but they are all initialized with the same value. The difference is kind of irrelevant for a constant object like an empty tuple. But imagine the following program: fn main() { let mut vs = [(1,), (1,), (1,), (1,), (1,)]; vs[0].0=2; for v in vs { println!("{:?}", v); } } Here we can see that identity is in fact importa…

> They are the same value, but with different identities. vs[0], vs[1] etc. are different objects What allows you to say that they have different identities? They are zero-sized types. Literally zero. `()` is a type and `()` its the only possible value. log(1) = 0 bit. If you look into machine code you will not find anything that you can call an object. The very existence of `()` is a shared dream of a programmer and…

> What allows you to say that they have different identities?

Syntactic analogy with non-zero sized types. If you want a special case that says "there is a single object of the zero-sized type" that's ok, but it's a special case. All other types have a difference between object identity and value equality.

> Will all addresses be equal?

No, because C++ doesn't optimize for ZSTs, and it doesn't modify semantics for const. I agree that C++ pays a price for these two things, but I don't think it's because it "insists all objects have different addresses", I believe that is just a consequence to not giving special semantics to const beyond disallowing writes.

Re: Carbon’s most exciting feature is its calling convention

#222
post #170

Earlier quoted context omitted.

[edit due to the above edit I just saw: wasn't me, I didn't see what you said as being inherently bad and so deserving of downvoting, otherwise I wouldn't have bothered replying :-/] That sounds like what you're saying is that gcc or clang fail to conform to the platform ABI, which is a compiler bug. If a compiler wishes to ignore platform ABI, it doesn't make the ABI not a thing. But if you are comparing ABI compati…

Thanks for your reply! First off, I work mainly in C++ (Windows, Linux, macOS and some embedded) and I don't hate the language. I really wished that C++ had a well-specified ABI, but the sad reality is that it doesn't. > if the code generated by a compiler targeting a given platform, does not match the ABI used by that platform, the problem is the compiler is generating broken code. The compiler only has to correctly…

BTW, MSVC has repeatedly broken its ABI in the past. Only since 2015 they guarantee binary compatibility across compilers versions - with certain restrictions: https://docs.microsoft.com/en-us/cpp/porting/binary-compat-2...

Re: Carbon’s most exciting feature is its calling convention

#223
post #30

Maybe I'm missing something, but I don't see what's special about Carbon here. In C++ the compiler can also optimize pass-by-const-reference to pass-by-value, and they do. It just can't do it across an ABI boundary, but that should only be an issue with dynamic libraries, and Carbon has to follow the standard ABI there as well. Just make sure the compiler knows it doesn't have to follow the standard ABI for every sym…

I think the alias analysis “pro” is overblown, it’s UB to take the address of a parameter via any mechanism other than explicitly taking the address - which a compiler obviously sees, and because it’s UB the compiler optimizes is free to assume no one is taking the address. Then for any parameters that are passed by reference the compiler has to assume there are other references so there’s no gain. Honestly the only…

Why not just use parentheses, because, you know, templates are just AOT-functions behind the scenes! Try to come up with an example where this syntax is worse than (angle or square) brackets...
Post reply on HN