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

Extensibility? #3

Closed
teoliphant opened this issue Dec 9, 2016 · 2 comments
Closed

Extensibility? #3

teoliphant opened this issue Dec 9, 2016 · 2 comments

Comments

@teoliphant
Copy link
Member

It is good to see progress on this library. One of the key aspects of this library is that it must be extensible from the beginning.

How would someone dynamically extend the available types? They need to be able to do this without recompilation.

@skrah
Copy link
Member

skrah commented Dec 9, 2016

Currently we have the ndt_typedef() function that creates a globally unique nominal type. Here is an example:

https://github.com/blaze/libndtypes2/blob/master/tests/runtest.c#L76

This type is matched by name only (as requested by @sklam). It carries the complete type description for informational purposes, but we can easily add an entirely opaque version, too -- or simply allow NULL as the type for opaque pointers.

Internally, the Nominal type is represented like this:

https://github.com/blaze/libndtypes2/blob/master/ndtypes.h#L223

As far as the higher level is concerned, there is a natural hierarchy in the types which I've attempted to highlight by indentation in the enum ndt definition:

https://github.com/blaze/libndtypes2/blob/master/ndtypes.h#L115

If at some point we want to expose this hierarchy via Python objects and allow inheritance, we could probably simulate that by adding a new type constructor, say Object. Then the inheritance on the Python level would be e.g.:

class Any: pass
class Real(Any): pass
class Float64(Real): pass
class MyFloat(Float64): pass

MyFloat would then need to be registered as an Object type, which would need to store the inheritance hierarchy.

@skrah
Copy link
Member

skrah commented Apr 5, 2018

I think this one is superseded by xnd-project/libgumath#4.

@skrah skrah closed this as completed Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants