PRX-46: support qualified `new`, `is`, `~` (type cast) and static calls
The existing object creation fallback mechanism did not support qualified paths (`new a.b.c`) and retro-fitting it into that mechanism was not realistic. Mostly because it is highly context-dependent (which symbols are actually defined) and because back-tracking isn't really an option with the way both symbol resolution _and_ the parser generator are designed.
The solution is to start representing the "type operations" (creation, type check, type cast, static call) within the value universe of Prexonite (as ordinary Prexonite symbols). As we have dedicated byte code instructions and AST nodes, we don't want to implement these as commands. Instead, we have "built-in" macro commands that are parameterized and instantiated multiple times (once for each built-in type).
A consequence of this is that the `AstTypecheck`, `AstTypecast`, `AstGetSetStatic` and `AstObjectCreation` no longer show up directly in the AST. They only exist temporarily between macro expansion and code generation. This could be fixed with an earlier lowering pass, but such a thing needs to be considered carefully.
An alternative would have been to encode these operations directly in the symbol table (4 new `Symbol` sub-types), but that solution seemed to push _more_ logic into the compiler core as opposed to less.
Breaking changes:
- `AstTypecheck`: replace file-line-column constructor with `ISourcePosition` constructor. This means Prexonite code using `psr\macro` needs to construct instances using `ast3` instead of `ast`.
- `AstGetSetStatic`: replace file-line-column constructor with `ISourcePosition` constructor. This means Prexonite code using `psr\macro` needs to construct instances using `ast3` instead of `ast`.
- `AstConstant`: constant is now `readonly`
- `AstTypecheck` not longer has an `IsInverted` property. As a result, AST factory `UnaryOperation` no longer automatically handles partial application of `? is not T`. There is no replacement.
- In Prexonite Script 2, object creation, type checks, type casts and static calls require the import of `sys.*` (or `sys.rt.builtin.*` or `prx.core.rt.builtin.*`)
- Removed the concept of type expressions from the language. This means you can no longer pass e.g., `~String`, i.e. the concept of the type String, as a type parameter to another type. This feature has not been used at all since the inception of Prexonite. Constant and dynamic _value_ parameters are still supported.
- built-in types (or any registered PTypes) are no longer privileged over "fallback" functions. That means a locally defined `is_String` function will supersede the built-in `is String` implementation. (Previously, custom type operations were only used as a fallback if the type isn't registered)
- Type operations need to be declared at compile-time. For Prexonite 1, the loader automatically will declare symbols for each registered type. For Prexonite 2, symbols will have to be declared (e.g., by providing a companion module).
Miscellaneous Fixes:
- Delta left and right (`<|` and `|>`) are now supported in a `ModifyingAssignment` (AST Factory).
- Remove custom overrides of `CheckForPlaceholders`. Implementation based on `IAstPartiallyApplicable`.
- Allow multiple namespace transfers in export clauses even if the `()` of the subject namespace is not there.
- Bump version to 1.98
Follow-up: PRX-56 to resolve the confusing error message about missing `create_`, `is_`, `to_`, `static_call_` symbols.
PRX-46: support qualified `new`, `is`, `~` (type cast) and static calls
The existing object creation fallback mechanism did not support qualified paths (`new a.b.c`) and retro-fitting it into that mechanism was not realistic. Mostly because it is highly context-dependent (which symbols are actually defined) and because back-tracking isn't really an option with the way both symbol resolution _and_ the parser generator are designed.
The solution is to start representing the "type operations" (creation, type check, type cast, static call) within the value universe of Prexonite (as ordinary Prexonite symbols). As we have dedicated byte code instructions and AST nodes, we don't want to implement these as commands. Instead, we have "built-in" macro commands that are parameterized and instantiated multiple times (once for each built-in type).
A consequence of this is that the `AstTypecheck`, `AstTypecast`, `AstGetSetStatic` and `AstObjectCreation` no longer show up directly in the AST. They only exist temporarily between macro expansion and code generation. This could be fixed with an earlier lowering pass, but such a thing needs to be considered carefully.
An alternative would have been to encode these operations directly in the symbol table (4 new `Symbol` sub-types), but that solution seemed to push _more_ logic into the compiler core as opposed to less.
Breaking changes:
- `AstTypecheck`: replace file-line-column constructor with `ISourcePosition` constructor. This means Prexonite code using `psr\macro` needs to construct instances using `ast3` instead of `ast`.
- `AstGetSetStatic`: replace file-line-column constructor with `ISourcePosition` constructor. This means Prexonite code using `psr\macro` needs to construct instances using `ast3` instead of `ast`.
- `AstConstant`: constant is now `readonly`
- `AstTypecheck` not longer has an `IsInverted` property. As a result, AST factory `UnaryOperation` no longer automatically handles partial application of `? is not T`. There is no replacement.
- In Prexonite Script 2, object creation, type checks, type casts and static calls require the import of `sys.*` (or `sys.rt.builtin.*` or `prx.core.rt.builtin.*`)
- Removed the concept of type expressions from the language. This means you can no longer pass e.g., `~String`, i.e. the concept of the type String, as a type parameter to another type. This feature has not been used at all since the inception of Prexonite. Constant and dynamic _value_ parameters are still supported.
- built-in types (or any registered PTypes) are no longer privileged over "fallback" functions. That means a locally defined `is_String` function will supersede the built-in `is String` implementation. (Previously, custom type operations were only used as a fallback if the type isn't registered)
- Type operations need to be declared at compile-time. For Prexonite 1, the loader automatically will declare symbols for each registered type. For Prexonite 2, symbols will have to be declared (e.g., by providing a companion module).
Miscellaneous Fixes:
- Delta left and right (`<|` and `|>`) are now supported in a `ModifyingAssignment` (AST Factory).
- Remove custom overrides of `CheckForPlaceholders`. Implementation based on `IAstPartiallyApplicable`.
- Allow multiple namespace transfers in export clauses even if the `()` of the subject namespace is not there.
- Bump version to 1.98
Follow-up: PRX-56 to resolve the confusing error message about missing `create_`, `is_`, `to_`, `static_call_` symbols.
PRX-46: support qualified `new`, `is`, `~` (type cast) and static calls
The existing object creation fallback mechanism did not support qualified paths (`new a.b.c`) and retro-fitting it into that mechanism was not realistic. Mostly because it is highly context-dependent (which symbols are actually defined) and because back-tracking isn't really an option with the way both symbol resolution _and_ the parser generator are designed.
The solution is to start representing the "type operations" (creation, type check, type cast, static call) within the value universe of Prexonite (as ordinary Prexonite symbols). As we have dedicated byte code instructions and AST nodes, we don't want to implement these as commands. Instead, we have "built-in" macro commands that are parameterized and instantiated multiple times (once for each built-in type).
A consequence of this is that the `AstTypecheck`, `AstTypecast`, `AstGetSetStatic` and `AstObjectCreation` no longer show up directly in the AST. They only exist temporarily between macro expansion and code generation. This could be fixed with an earlier lowering pass, but such a thing needs to be considered carefully.
An alternative would have been to encode these operations directly in the symbol table (4 new `Symbol` sub-types), but that solution seemed to push _more_ logic into the compiler core as opposed to less.
Breaking changes:
- `AstTypecheck`: replace file-line-column constructor with `ISourcePosition` constructor. This means Prexonite code using `psr\macro` needs to construct instances using `ast3` instead of `ast`.
- `AstGetSetStatic`: replace file-line-column constructor with `ISourcePosition` constructor. This means Prexonite code using `psr\macro` needs to construct instances using `ast3` instead of `ast`.
- `AstConstant`: constant is now `readonly`
- `AstTypecheck` not longer has an `IsInverted` property. As a result, AST factory `UnaryOperation` no longer automatically handles partial application of `? is not T`. There is no replacement.
- In Prexonite Script 2, object creation, type checks, type casts and static calls require the import of `sys.*` (or `sys.rt.builtin.*` or `prx.core.rt.builtin.*`)
- Removed the concept of type expressions from the language. This means you can no longer pass e.g., `~String`, i.e. the concept of the type String, as a type parameter to another type. This feature has not been used at all since the inception of Prexonite. Constant and dynamic _value_ parameters are still supported.
- built-in types (or any registered PTypes) are no longer privileged over "fallback" functions. That means a locally defined `is_String` function will supersede the built-in `is String` implementation. (Previously, custom type operations were only used as a fallback if the type isn't registered)
- Type operations need to be declared at compile-time. For Prexonite 1, the loader automatically will declare symbols for each registered type. For Prexonite 2, symbols will have to be declared (e.g., by providing a companion module).
Miscellaneous Fixes:
- Delta left and right (`<|` and `|>`) are now supported in a `ModifyingAssignment` (AST Factory).
- Remove custom overrides of `CheckForPlaceholders`. Implementation based on `IAstPartiallyApplicable`.
- Allow multiple namespace transfers in export clauses even if the `()` of the subject namespace is not there.
- Bump version to 1.98
Follow-up: PRX-56 to resolve the confusing error message about missing `create_`, `is_`, `to_`, `static_call_` symbols.