From a2005fce889285abe52c289c7a9bbc935246ed32 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 1 Jan 2020 17:36:08 -0800 Subject: [PATCH] =?UTF-8?q?Add=20note=20to=20coding=20guidelines=20about?= =?UTF-8?q?=20using=20the=20magic=20error,=20oldValue,=20and=20newValue=20?= =?UTF-8?q?variables.=20It=E2=80=99s=20totally=20okay=20to=20use=20these.?= =?UTF-8?q?=20Fix=20#1512.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Technotes/CodingGuidelines.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Technotes/CodingGuidelines.md b/Technotes/CodingGuidelines.md index c106167ec..80e623299 100644 --- a/Technotes/CodingGuidelines.md +++ b/Technotes/CodingGuidelines.md @@ -36,6 +36,8 @@ Functions should tend to be small. One-liners are a-okay, especially when the fu We mostly avoid Swift generics, since generics is an advanced feature that can be relatively hard to understand. We *do* use them, though, when appropriate. +It’s totally okay to use the magic `error` variable when catching errors. In accessors, use of the magic `oldValue` and `newValue` is expected when you need the old or new value. + We use assertions and preconditions (assertions are hit only when running a debug build; preconditions will crash a release build). We also allow force-unwrapping of optionals as a shorthand for a precondition failure, though these should be used sparingly. Extensions, including private extensions, are used — though we take care not to extend Foundation and AppKit objects too much, lest we end up with our own Cocoa dialect.