-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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: Some kind of type-of operator #1948
Comments
Yes, I remember @pcwalton @brson and I talked about this problem a while back and I forget what we decided would be best. It seems like you've enumerated the options, though. Even if we get rid of tydesc/intrinsics, I think we will need sizeof() and alignof() operators, if nothing else, and you kind of have the same problem there---but perhaps they could be added as keywords to the language? |
FWIW, I'm ok with either hard-coding |
I don't prefer hard-coding the name of something in core. What about leaving it a "rust-intrinsic" native ABI function but just having the compiler recognize it by name and generate it on demand? The intrinsic functions are all special and, from an end-user perspective, appear to be generated by rustc anyway. |
Agreed. This is exactly the sort of thing "intrinsic" is for: stuff that "looks like a function" but only a compiler can generate. |
@marijnh Is this resolved? |
Yes, there's the |
Monomorphization (assuming I'll be able to land it anytime soon) has removed the need to pass type descriptors to generics. The only place were we still are passing type descriptors is to rust-intrinsic functions. I'd like to switch those over to explicit type-descriptor passing (most of them don't even use their type descriptors), but
sys::get_type_desc
is currently implemented as an intrinsic that returns the type descriptor it is passed. Thus, we'd have to provide some other way to get at tydescs.Ideally, this would be some hack in core and not add anything to the language. But when our compiler stops passing tydescs to things, it becomes very hard to get hold of them. You can box something and then unsafely fetch the tydesc from the box, but that's definitely not how we want to create tydescs. So the compiler will have to cooperate in some way.
I'm having trouble coming up with a non-invasive way to do this. We could hard-code
core::sys::get_type_desc
to always magically return the type desc of its type parameter. We could do something with attributes.Do others have ideas? Do you think I'm even going in the right direction here? The code to handle passing tydescs to intrinsics is very awkward, now that normal functions no longer take tydescs. It seems like an undesirable wart.
The text was updated successfully, but these errors were encountered: