-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 std/rtti
and getDynamicTypeInfo
#16963
Conversation
getDynamicTypeInfo
std/rtti
and getDynamicTypeInfo
This should be opt-in, the type names might not always be available (I can think of v2 implementations that use integers and modulo operations for the |
Is there any plan for the design of this module? I'm assuming users are going to want more functionality than just the single function retrieving and comparing type information objects for equality. |
This needs an RFC. |
As I said, this needs an RFC first. |
typeid
returning atype_info
refs https://en.cppreference.com/w/cpp/language/typeidtypeid
returning aTypeInfo
refs https://dlang.org/spec/expression.html#typeid_expressionsGetType
refs https://docs.microsoft.com/en-us/dotnet/api/system.object.gettype?view=net-5.0type(of:)
refs https://developer.apple.com/documentation/swift/2885064-typegetClass
https://www.tutorialspoint.com/java/lang/object_getclass.htmnimV2
(eg gc:arc|orc)use cases
notes
std/rtti
is a new module and hidden behind-d:nimExperimentalTypeInfoCore
so this module can more freely evolve until it stabilizes, while at same time allowing people to try it as opt-in, refsnimExperimentalFoo
for experimental modules/APIs timotheecour/Nim#575typeinfo
which is about theAny
type, whereasgetDynamicTypeInfo
is about runtime type information (in particular for polymorphic types, but also useful for non polymorphic ones), but both can be combinedError: system module needs: programResult
fortests/dll/nimhcr_integration.nim
hti
include module into a private import modulestd/private/hti
to avoid it being included more than once (and because imports are cleaner in general)future work
TNimTypeV2
to hti.nim now that hti is a proper import module, so that it can be deduplicated from system.nim and std/rtti (alternatively, I could do this in this PR)lib/system/cyclebreaker.nim
can reuse this proc instead of it defining its ownproc getDynamicTypeInfo[T](x: T): PNimTypeV2 {.magic: "GetTypeInfoV2", noSideEffect, locks: 0.}
getSize
,gteAlign
,getName
etc