-
Notifications
You must be signed in to change notification settings - Fork 82
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
Are instances local compile-time known? #1309
Comments
"local compile-time known" is more restrictive than "compile-time-known", so this is more a matter of instances being allowed to be local compile time known, even though their constructor arguments may not be. |
I see, but I think allowing instances to be local compile-time known may some subtlety, since there are some cases where only local compile-time values are expected. e.g., there are some cases like And of course, instances cannot be used in any places where local compile-time value is expected, as of the current spec. But for the sake of clarity and future language extensions, I believe defining instances as compile-time known also makes sense. |
Well, those specific examples that require local compile-time known values also require numeric type values, and instances are non-numeric (they are controls, parsers, externs, or actions), so there's no intersection. However, it does bring up a point -- should it be possible to define methods in an extern such that a call of such a method on a locally compile-time known instance is itself compile-time known (locally or not)? I don't think anyone has tried that yet, but it might well make sense for metaprogramming purposes to have methods defined on an extern that return constant info about the instance (its size, for example, or maybe something target specific, like precision). |
It seems to me that if one of these things:
depends in any way upon the value of a constructor parameter of the enclosing parser or control, then it doesn't really make sense to call it local compile-time known. My first question would be, should we move the bullet item "Instances constructed by instance declarations (Section 11.3) and constructor invocations." from the local compile-time known list, to the compile-time known list, as a correction to the spec? If we wanted to have any instance declarations, or constructor calls, considered as local compile-time known, then it seems that we should further restrict it so that everything parameter to it is also local compile-time known. |
A follow-up issue from #1305.
Section 18.1. Compile-time known and local compile-time known values lists,
as a local compile-time known value.
But since constructor arguments are compile-time known, shouldn't instances also be compile-time known?
Or are there cases where we need instances to be local compile-time known?
The text was updated successfully, but these errors were encountered: