-
Notifications
You must be signed in to change notification settings - Fork 55
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
Restriction on annotation values to anydata #70
Comments
I think it would be very problematic to allow function values to be part of annotations (and thus type descriptors), given that they are mutable (because of closures and arguably references to module state). Maybe it would be sufficient to be able to refer to the module-level name of a function. Other annotations refer to names of variables and parameters. |
It might be possible to make compile time const function values work, which would effectively restrict them to names of module-level functions. |
Above works, but if annotation developer wants to type check an annotation value, he has to write compiler extension.
If we allow compile-time const function in an annotation value, it is no longer an anydata. Isn't it? Then we can't freeze an annotation value. |
@hasithaa Frozen mappings and other containers can contain inherently immutable values, even if they are not anydata. So it is not impossible to extend compile-time consts to include things that are inherently immutable. Values of compile-time consts are constrained both by what type we say they must have and by the kinds of expression we allow in compile-time consts. So we could support this by allowing variable-references in compile-time consts to refer to module-level functions, and by loosening the constraint on the type that compile-time consts must have. This raises the question of what exactly immutable means, and does it make sense to consider some (e.g. module level functions) or all functions as immutable. |
map<any>
instead of map<anydata>
in annotation tag
This can be addressed as part of #189 |
We can make the type be |
The Spec says,
ballerina-spec/lang/spec.html
Lines 5190 to 5193 in 0d4003e
But in the implementation, some annotations use function pointers values. (e.g: In the ballerina/transaction module)
To allow this, we have to use
any
instead ofanydata
. But that leads to other problems likeThe text was updated successfully, but these errors were encountered: