Description
Proposal:
duration and stretch type values should only be able to be declared as part of const declarations.
duration, stretch, and array[duration, ...] should not be allowed as parameters to function calls declared as part of def statements.
duration and stretch values should not be allowed as return values from extern defs.
- casting of
duration and stretch types and their allowed operations needs to be clarified.
- Clarify how
durationof calculates its span from the supplied scope.
Motivation
The spec says durations are real numbers that are manipulated at compile time; however, in order to be compile-time, the type and values of duration must be const.
The grammar allows for const and non-const decls of duration which conflicts with the above:
classicalDeclarationStatement: (scalarType | arrayType) Identifier (EQUALS declarationExpression)? SEMICOLON;
constDeclarationStatement: CONST scalarType Identifier EQUALS declarationExpression SEMICOLON;
scalarType:
....
| DURATION
| STRETCH
| ...
;
As far as I can tell, durations must always be const or durationof couldn't work as well. This also has downstream effects on arrays as you can have arrays with base type duration (but not stretch) and all values of that array must be const with the owning array type being non-const (as there is no such thing as a const array type).
Additionally, duration being compile time means that typed arguments of duration, stretch, and array[duration, ..] cannot be passed to def declared functions. For example:
def g(duration arg) {
const uint size = arg / 1ns;
bit[size] arr_2 = "10110";
}
If arg is const, we should be able to write the body of the function, and correctly typecheck the size of the bitarray declaration. But we don't know what arg is until we call the function with an actual duration value.
Continuing, duration and stretch values cannot cannot be returned from extern functions which conflicts with returnSignature: ARROW scalarType; from the grammar. For example:
extern f() -> duration;
const uint size = f() / 1ns;
array[bool, size] arr = {1, 2, 3};
This duration wouldn't be knowable at compile time.
How does durationof calculate the duration of the scope passed to it? Does it add the duration designators for all delay, gate call, and box statements in the supplied scope?
Authors
No response
Examples
No response
Description
Proposal:
durationandstretchtype values should only be able to be declared as part of const declarations.duration,stretch, andarray[duration, ...]should not be allowed as parameters to function calls declared as part ofdefstatements.durationandstretchvalues should not be allowed as return values fromexterndefs.durationandstretchtypes and their allowed operations needs to be clarified.durationofcalculates its span from the supplied scope.Motivation
The spec says
durations are real numbers that are manipulated at compile time; however, in order to be compile-time, the type and values ofdurationmust beconst.The grammar allows for const and non-const decls of duration which conflicts with the above:
As far as I can tell, durations must always be const or
durationofcouldn't work as well. This also has downstream effects on arrays as you can have arrays with base typeduration(but notstretch) and all values of that array must be const with the owning array type being non-const (as there is no such thing as a const array type).Additionally, duration being compile time means that typed arguments of
duration,stretch, andarray[duration, ..]cannot be passed todefdeclared functions. For example:def g(duration arg) { const uint size = arg / 1ns; bit[size] arr_2 = "10110"; }If
argisconst, we should be able to write the body of the function, and correctly typecheck the size of the bitarray declaration. But we don't know whatargis until we call the function with an actualdurationvalue.Continuing,
durationandstretchvalues cannot cannot be returned from extern functions which conflicts withreturnSignature: ARROW scalarType;from the grammar. For example:extern f() -> duration; const uint size = f() / 1ns; array[bool, size] arr = {1, 2, 3};This
durationwouldn't be knowable at compile time.How does
durationofcalculate the duration of the scope passed to it? Does it add the duration designators for alldelay,gate call, andboxstatements in the supplied scope?Authors
No response
Examples
No response