Skip to content
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

RFC: Singleton types #37

Merged
merged 3 commits into from
May 28, 2021
Merged

Conversation

alexmccord
Copy link
Contributor

No description provided.

@alexmccord alexmccord added the rfc Language change proposal label May 5, 2021
@zeux
Copy link
Collaborator

zeux commented May 11, 2021

strings are meant to be constant, so we just have to hash the string exactly once and then use this hashed value to compare for the rest of type analysis

I don't think this works because of hash collisions. I suspect we would have to use a full string representation atm, since our type checker lacks cross-module interned strings.

Copy link
Collaborator

@zeux zeux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, this is waiting for adjusting the "drawbacks" since that implementation strategy isn't robust to collisions.

@alexmccord
Copy link
Contributor Author

alexmccord commented May 19, 2021

Yeah I suppose the point of it is to show that it's possible to not increase the time complexity when comparing strings in the type checker. Pointer address is certainly the most robust strategy one can take. You're right that the best way to implement this is to follow same direction we took for AstLocals, but with global interning support.

I'll update the proposal in a way that talks about the time complexity being a non-issue, but without any concrete implementation detail.

Reword to exclude O(1) claims
@zeux zeux merged commit cc399fa into luau-lang:master May 28, 2021
zeux added a commit that referenced this pull request Nov 19, 2021
- Improve error recovery during type checking
- Initial (not fully complete) implementation for singleton types (RFC RFC: Singleton types #37)
- Implement a C-friendly interface for compiler (luacode.h)
- Remove C++ features from lua.h (removed default arguments from luau_load and lua_pushcfunction)
- Fix lua_breakpoint behavior when enabled=false
- Implement coroutine.close (RFC RFC: coroutine.close #88)

Note, this introduces small breaking changes in lua.h:

- luau_load env argument is now required, pass an extra 0
- lua_pushcfunction now must be called with 3 arguments; if you were calling it with 2 arguments, pass an extra NULL; if you were calling it with 4, use lua_pushcclosure.

These changes are necessary to make sure lua.h can be used from pure C - the future release will make it possible by adding an option to luaconf.h to change function name mangling to be C-compatible. We don't anticipate breaking the FFI interface in the future, but this change was necessary to restore C compatibility.

Closes #121
Fixes #213
@alexmccord alexmccord deleted the rfc-singleton-types branch February 2, 2022 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfc Language change proposal
Development

Successfully merging this pull request may close these issues.

2 participants