-
Notifications
You must be signed in to change notification settings - Fork 276
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
Add a writeup of current optional imports design #47
Conversation
design/weak-imports.md
Outdated
|
||
```wasm | ||
(func $statvfs (import "wasi:fs" "statvfs.weak")) | ||
(global $statvfs_is_present (import "wasm:fs" "statvfs.is_present") i32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we put the ".weak" and ".is_present" in the module name, rather than the field name? This is a little less intuitive, however it would address the concern about intruding on what would otherwise be the user's or compiler's namespace. (import "wasi:fs.weak" "statvfs")
and (import "wasi:fs.is_present" "statvfs")
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Kind of nasty but see you point. What do others think of this idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option would be to define a reserved character to use instead of .
. It's unlikely any system would want to use \0
for its symbol names, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some existing encoding that we could reuse here, e.g. url encoding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using null bytes in strings seems a like asking for trouble.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If any character (combination), then definitely something visible in ASCII.
I wrote up this as initially proposed by Dan, using name mangling rather than a custom section. I believe there is still room to switch a custom section if people feel strongly about it. The main downsides I see of using such mangling are: 1. It is that reserves the ".weak" and ".is_present" suffixes 2. It might not play nicely with possible future attributes we might want to add to imports. Fixes #36
I've updated this PR, going back the custom section design, as discussed in the last meeting. |
Update with name change to "optional" |
@sunfishcode ptal |
Looks like all the feedback has been addressed! If anyone has further feedback, please file issues in the issue tracker. |
Document how weak imports are specified and the contents of the new custom section
used for this purpose
Fixes #36