kiselgra / c-mera

Next-level syntax for C-like languages :)
Other
405 stars 17 forks source link

Mapping of duplicate symbols #58

Closed kiselgra closed 7 years ago

kiselgra commented 7 years ago

We generally try to allow lispy names to be used while actually targeting C code, that is, we translate foo-bar to foo_bar. However, if I mix those two, that is, use foo-bar and foo_bar in my code, our name-fixing pass does the right thing for the identifier that is encountered first, but the second one will have a suffix _ attached to it.

This is sensible as we might have vastly different names mapping to the same C representation, but for this case I think it causes more confusion than it resolves. Think, e.g., about two people using push_back (from vector) inconsistently.

More problematic, I think, is that duplicates are also generated for the symbols of the same name, but from different packages. An example would be having a macro (from a library) that uses push-back be expanded in user code that uses push_back. In this case either one of the two will break. This causes all sorts of name-conflicts for libraries with code-generating macros.

I would argue to resolve those by allowing symbols to be equal in a broader sense, that is ignore - and _ differences and (more importantly) ignore packages for the translation.

What do you think, does this sound reasonable?

lispbub commented 7 years ago

Warnings will be shown when a generator is used with -Whyphen whenever a hyphen is changed to an underscore.

kiselgra commented 7 years ago

Awesome :)