@@ -291,6 +291,73 @@ Note that an alternative approach to implementing a phase-kickback pattern, whic
291291not require the use of ` free ` , is to encapsulate the calls to ` H ` in a function
292292with an as unchecked _ const_ parameter.
293293
294+ ## Drop
295+
296+ The _ drop_ statement is used to declare that a quantum variable is no longer
297+ used and should be exluded from any future uncomputation. Subsequently, the
298+ variable becomes uninitialized, while its qubits retain their current
299+ state &mdash ; which may be dirty and entangled with functional qubits &mdash ; and cannot be reused.
300+
301+ ### Syntax
302+
303+ === "Python"
304+
305+ [comment]: DO_NOT_TEST
306+ ```python
307+ def drop(var: Input[QVar]) -> None:
308+ pass
309+ ```
310+
311+ === "Native"
312+
313+ **drop** **(** _var_ **)**
314+
315+ ### Semantics
316+
317+ - Prior to a _ drop_ statement _ var_ must be initialized, and subsequently it
318+ becomes uninitialized.
319+ - Local variables that are explicitly dropped are not considered uncomputation candidates,
320+ and are not restricted to permutable use contexts. See more under
321+ [ Uncomputation] ( https://docs.classiq.io/latest/qmod-reference/language-reference/uncomputation/ ) .
322+
323+ ### Example
324+
325+ Explicitly dropping a variable is typically not needed and is only used for specific purposes.
326+ The following example demonstrates the use of ` drop ` in a swap test algorithm,
327+ where the two quantum states cannot be uncomputed, yet we do not wish to measure
328+ them.
329+
330+ === "Python"
331+
332+ ```python
333+ from classiq import *
334+
335+
336+ @qfunc
337+ def main(test: Output[QBit]):
338+ state1 = QArray("state1")
339+ state2 = QArray("state2")
340+ prepare_state([0.1, 0.5, 0.3, 0.1], 0.0, state1)
341+ prepare_state([0.2, 0.1, 0.4, 0.3], 0.0, state2)
342+ swap_test(state1, state2, test)
343+ drop(state1)
344+ drop(state2)
345+ ```
346+
347+ === "Native"
348+
349+ ```
350+ qfunc main(output test: qbit) {
351+ state1: qbit[];
352+ state2: qbit[];
353+ prepare_state([0.1, 0.5, 0.3, 0.1], 0.0, state1);
354+ prepare_state([0.2, 0.1, 0.4, 0.3], 0.0, state2);
355+ swap_test(state1, state2, test);
356+ drop(state1);
357+ drop(state2);
358+ }
359+ ```
360+
294361## Concatenation Operator
295362
296363The _ concatenation operator_ is used to combine a sequence of quantum objects
0 commit comments