6 ms·
Oof that's not a good look. You can trivially avoid this by just prefixing all variable names with a salt. By the way this (or a variant thereof) is called "avo
by lou1306 2mo ago
Oof that's not a good look. You can trivially avoid this by just prefixing all variable names with a salt. By the way this (or a variant thereof) is called "avoiding unwanted name capture" if you want to sound all sophisticated :)
- bruce343434 2mo agoC++ compilers do this too, thats why so many to-be-linked symbols start with "Z"
- ventana 2mo agoNot only for the conflicts, but mostly to encode the parameter types into the name for method overloading, because the linker has no idea about it.
- ventana 2mo agoI think maybe the idea of all these transpilers is to keep the generated code readable and as close to the original code as possible. Mangling names into unreadable garbage is not difficult, but that would also make the the transpiler act more like an obfuscator, which is probably what the authors want to avoid. Protobuf has similar problem: whatever names you use for your proto messages should be translated to the target language as is, and with multiple target languages, chances are that you'll hit a keyword in one of them; each language plugin should figure out how to resolve this. $ cat test.proto syntax = "proto3"; package test; message TestMessage { int32 register = 1; int32 foo = 2; } $ protoc --cpp_out=. test.proto $ grep 'register\|foo' test.pb.cc | head -n 2 : register__{0}, foo_{0}, (I may understand `register__`, but why `foo_`? no idea)