Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Construct to mixed2018 (#511)
This set of changes completes the goals of the original construct-to-mixed branch. Function unfortunately worked with Constructs, rather than the Mixed interface. This was a violation of the Dependency Inversion Principal, which has prevented several critical improvements to the language. The problem is that in Java, there is not multiple inheritance, so while normal classes could easily extend Construct and then be added into the ecosystem, for other types of classes, where it's impossible to extend Construct (particularly because they are already extending another class, which is true in at least the cases of enums and exceptions), these objects simply could not be added into the ecosystem. Now, everything accepts and for the most part deals with Mixed, which is an interface. This has the unfortunate side effect of breaking binary compatibility with extensions, but this change has been in the works for at least three years. As part of this change, implementing enums was used as a test case. That has now also been done, and barring a few bugs, seems to mostly work. This allows access of enums as first class objects, rather than as arrays of strings as previously implemented through reflect_pull. The PR opens lots of possibilities in the future, and so is a welcome change to the base, but there are a few short term goals after this PR is merged: * Move exceptions into first class status. Currently they are implemented as arrays, but this is a shoehorn and not ideal. * Write up documentation for Enums. There is some documentation already available, and this may be mostly correct, but it should at least be read through to ensure it is correct, and then linked to the learning trail. It's also possible to iterate enums with foreach, and so this should be added as an example in various places. * There are still a few bugs with enums, particularly it is not possible to assign an enum class to a variable. ClassType @s = ArraySortType; should work, but @s remains null. (The same is true even if @s is auto typed). * Continue with object oriented notation. This provides a good framework to begin with. While it is possible to do EnumType[0] or EnumType['EnumName'], this is the reflective access mechanism, it should also be possible to access the enum by name like EnumType::EnumName. Since this breaks extensions, the version number has been bumped to 3.3.4, and this PR should not be merged without coordination with extension authors. Also, before merging this PR, one more change should be made, which is to deprecate concatenation of bare strings. * Start converting construct to mixed. Also, the first pass at introducing Enums to the object model has been done. This is not complete yet, until everything supports mixed, but most of the work for that should have been done now. * Finish implementing Mixed everywhere. Enums are first class. Previously, exec(s) accepted an array of Constructs. While this worked most of the time, it has serious limitations, because object types that cannot extend Construct (i.e. enums, exceptions, dynamically defined classes) cannot be passed around. Now, we use Mixed everywhere, instead of Construct (at least in the interfaces), and so now things like enums and other classes can implement Mixed, and be added into the ecosystem. As part of this change, enums are now proper ClassTypes. An interesting learning here is that we violated the Liskov Substitution Pricipal early on. Had we not done that, and used an interface up front, (depend on abstractions, not concretions) we would not have had to deal with any of this. Since this changes the interface of Function, this breaks ALL extensions, thus the version has been bumped to 3.3.4. I have decided to not add binary compatibility either, since that would introduce a runtime penalty for every single function call, in every single script. * This still doesn't work, due to a bug in the compiler There is a bug in ForceImplements that doesn't respect the fact that it's an interface. * Support MDynamicEnum, bump version MDynamicEnum is now supported, and these show up properly in the compiler and reflection mechanisms. This is still not entirely useful, but this sets the stage for some (now) easily implementable features. * Implement Enums as objects, rather than strings * Fix some bugs with class type system * Allow ClassTypes to be standalone usable values * Add a way for objects to provide a static constructor Previously, in NativeTypeList, there was no way to customize how an invalid instance was constructed. Now, if a subclass of Mixed provides a method named ConstructInvalidInstance, this will be called instead. For now, this is not necessary in any native classes, but since this picks up extension objects as well, it might be useful already. * enums extend mixed
- Loading branch information
1 parent
676db51
commit 4964181
Showing
288 changed files
with
5,752 additions
and
4,133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.