microsoft / QuantumLibraries

Q# libraries for the Quantum Development Kit

Home Page:https://docs.microsoft.com/quantum

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add names to tuple fields of FixedPoint UDT

msoeken opened this issue · comments

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
}

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
}

Thanks for catching this @cgranade. PascalCase was indeed intended. It's updated now.