-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
Augmenting Composite Types and Default Type Data #1672
Comments
I definitely understand not being allowed to change types at run-time (some languages like Python with reflection allow it, while others such as the .NET family do not). However, because Julia does not allow creating subtypes of concrete types this makes it either impossible or messy to use existing typed code but have your objects carry around additional tagging information. While composition can be a good alternative it would be nice if there was something like an interface so that all of the functions that need to be implemented to properly subtype, for example, String were all listed in one place. Without interfaces, subtyping seems pretty difficult to get right since there could always be some function you were supposed to implement that you forgot about. Additionally, if the Function type is not going to be augmentable then maybe it should be an AbstractKind with a CompositeKind implementation so that there can be other types of Functions. |
Interfaces are fine but have absolutely nothing to do with mutating types. |
Occasionally there has been talk about allowing overloading The key thing is, even if there were other kinds of functions, there still must be some underlying mechanism that involves passing arguments to some piece of code, and that's what |
Also, in all such things it is typically very helpful to talk at the level of what one wants to accomplish, rather than mechanism detail like whether |
Suppose you have a type
and then you decided that you wanted to change the type by doing the following:
Then it is possible to both create new SomeIntegers and augment existing SomeIntegers as follows:
However, the below gives a segmentation fault
This is likely due to the fact that Int gets some sort of irrelevant default data, whereas String does not. As a result, this error also occurs with many other types (for example a custom Composite Type that only contains an Int).
Some interesting things to notice:
The text was updated successfully, but these errors were encountered: