Remove deprecated `using` qubit allocation syntax (#777)

This commit is contained in:
meltyness 2022-04-06 17:50:16 -05:00 коммит произвёл GitHub
Родитель 14071e2a04
Коммит 79ad94dc7b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@ -341,7 +341,7 @@
"source": [
"<details>\n",
" <summary><b>Click here for the complete answer validation code</b></summary>\n",
"<code> using (y = Qubit()) {\n",
"<code> use y = Qubit() {\n",
" oracle(register, y);\n",
" if (MResetZ(y) == One) {\n",
" Message(\"Correct!\");\n",
@ -437,7 +437,7 @@
" GroversAlgorithm_Loop(register, oracle, iterationCount);\n",
" set finalAnswer = ResultArrayAsBoolArray(MultiM(register));\n",
" Message($\"Verifying answer {finalAnswer}\");\n",
" using (y = Qubit()) {\n",
" use y = Qubit() {\n",
" oracle(register, y);\n",
" if (MResetZ(y) == One) {\n",
" set isAnswerCorrect = true;\n",
@ -550,7 +550,7 @@
"for (i in 1 .. 100) {\n",
" GroversAlgorithm_Loop(register, oracle, iterationCount);\n",
" let answer = ResultArrayAsBoolArray(MultiM(register));\n",
" using (y = Qubit()) {\n",
" use y = Qubit() {\n",
" oracle(register, y);\n",
" if (MResetZ(y) == One) {\n",
" set successCount += 1;\n",

Просмотреть файл

@ -160,14 +160,14 @@
"// The qubit is deallocated once it's not used any longer\n",
"```\n",
"\n",
"> Before Q# 0.15 the syntax for qubit allocation was different:\n",
"> An alternative syntax for qubit allocation defines the scope in which the allocated qubits are available explicitly:\n",
"```c#\n",
"// This statement allocates a qubit, and binds it to the variable q\n",
"using (q = Qubit()) {\n",
"use q = Qubit() {\n",
" // You can work with the qubit here\n",
" // ...\n",
"}\n",
"// The qubit is no longer allocated outside of the 'using' block\n",
"// The qubit is no longer allocated outside of the 'use' block\n",
"```\n",
"\n",
"Freshly allocated qubits start out in state $|0\\rangle$, and have to be returned to that state by the time they are released. If you attempt to release a qubit in any state other than $|0\\rangle$, your program will throw a `ReleasedQubitsAreNotInZeroStateException`. We will see why it is important later, when we look at multi-qubit systems."