Add names to tuple fields of FixedPoint UDT
msoeken opened this issue · comments
Mathias Soeken commented
Add names to tuple fields of FixedPoint UDT
Current status
There are currently no tuple field names, which makes it not as easy to access, e.g., the qubit array field.
Proposal
New and modified functions, operations, and UDTs
Modify Microsoft.Quantum.Arithmetic.FixedPoint
UDT as follows:
newtype FixedPoint = (IntegerBits : Int, Register : Qubit[]);
Examples
Current status
operation MyOp(fp : FixedPoint) : Unit {
let register = Snd(fp!);
// do something with register
}
or
operation MyOp(fp : FixedPoint) : Unit {
let (_, register) = fp!;
// do something with register
}
Using proposed changes
operation MyOp(fp : FixedPoint) : Unit {
let register = fp::Register;
// do something with register
}
Cassandra Granade commented
Proposal
New and modified functions, operations, and UDTs
Modify
Microsoft.Quantum.Arithmetic.FixedPoint
UDT as follows:newtype FixedPoint = (integerBits : Int, register : Qubit[]);
Current style guide suggests using PascalCase
for UDT names:
newtype FixedPoint = (IntegerBits : Int, Register : Qubit[]);
I think that aligns with the examples below as well?
Using proposed changes
operation MyOp(fp : FixedPoint) : Unit { let register = fp::Register; // do something with register }
Mathias Soeken commented
Thanks for catching this @cgranade. PascalCase
was indeed intended. It's updated now.