-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating vector.kk with an identifier named empty gives a strange compiler error #586
Comments
Unfortunately this is a pretty hard thing to fix. We don't want to mangle all the names in the program, because that would make C interop harder. At the same time, we do have some c definitions already. So you just happened to give your function a name that translates to
To fix this we have a few options:
Both of the last two are possible, but would require lots of renaming and fixing our extern definitions, or a large initial effort to document all C definitions, and a continual effort to keep that list maintained. (Also we have no guarantee that other people won't add their own C libraries and extern definitions that might conflict). |
... I guess we need to prevent clashes with the runtime defined functions; maybe generate |
I think changing the generated C code is probably the best option. We also should probably document the naming / calling convention for generated code and possibly allow some sort of function modifier or annotation to use a different raw name / (and possibly calling convention - for example to allow passing to a C function pointer without requiring a ctx parameter). This will make C library integration easier. |
How would our name generation work once Koka gets a proper package manager? I could imagine that several packages will have the same modules and identifiers in them. To avoid the same error in that case, we could prepend each name with the name of its package. The identifier in our standard library would then get a uniform prefix like |
pub val empty : forall<a> vector<a> = unit/vector()
(Changing the name of the file, or adding a qualifier to
empty
makes the error disappear)The text was updated successfully, but these errors were encountered: