From a2df1e6733b5450cfcad573b8df744c362f5df58 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Fri, 11 Aug 2023 16:07:48 +0100 Subject: [PATCH] [std/exception] Use PANEL macro to group paragraphs --- std/exception.d | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/std/exception.d b/std/exception.d index 1d93d351d..713c8617b 100644 --- a/std/exception.d +++ b/std/exception.d @@ -416,13 +416,16 @@ void assertThrown(T : Throwable = Exception, E) Returns: `value`, if `cast(bool) value` is true. Otherwise, depending on the chosen overload, `new Exception(msg)`, `dg()` or `ex` is thrown. - Note: - `enforce` is used to throw exceptions and is therefore intended to + $(PANEL + $(NOTE `enforce` is used to throw exceptions and is therefore intended to aid in error handling. It is $(I not) intended for verifying the logic - of your program. That is what `assert` is for. Also, do not use + of your program - that is what `assert` is for.) + + Do not use `enforce` inside of contracts (i.e. inside of `in` and `out` blocks and `invariant`s), because contracts are compiled out when compiling with $(I -release). + ) If a delegate is passed, the safety and purity of this function are inferred from `Dg`'s safety and purity. @@ -870,11 +873,12 @@ return to!(string)(sneaky); // not that sneaky anymore The call will duplicate the array appropriately. -Note that checking for uniqueness during compilation is +$(PANEL +$(NOTE Checking for uniqueness during compilation is possible in certain cases, especially when a function is -marked as a pure function. The following example does not +marked (or inferred) as `pure`. The following example does not need to call `assumeUnique` because the compiler can infer the -uniqueness of the array in the pure function: +uniqueness of the array in the pure function:) $(RUNNABLE_EXAMPLE ---- @@ -894,6 +898,7 @@ For more on infering uniqueness see the $(B unique) and $(B lent) keywords in the $(HTTP www.cs.cmu.edu/~aldrich/papers/aldrich-dissertation.pdf, ArchJava) language. +) The downside of using `assumeUnique`'s convention-based usage is that at this time there is no