mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 23:14:13 +01:00
doc: Update STYLE.
This commit is contained in:
parent
9f75f80c21
commit
5e9fbe78f3
1 changed files with 18 additions and 1 deletions
19
doc/STYLE.md
19
doc/STYLE.md
|
@ -93,7 +93,6 @@ If the compiler can't figure out the auto, that's when you indicate the type.
|
|||
|
||||
#### RAII will be in full force
|
||||
|
||||
|
||||
All variables, whether they're function-local, class-members, even globals,
|
||||
must always be under some protection at all times. There must be the
|
||||
expectation at *absolutely any point* including *between those points*
|
||||
|
@ -111,6 +110,24 @@ This means when a variable, or member (a **resource**) first comes into scope,
|
|||
i.e. it is declared or accessible (**acquired**), it must be **initialized**
|
||||
to a completely consistent state at that point.
|
||||
|
||||
* Window shade analogy:
|
||||
>
|
||||
> Imagine pulling down a window shade to hide the sun. As you pull down, the canvas
|
||||
> unrolls from its spool at the top. Your goal is to hook the shade on to the nail
|
||||
> at the bottom of the window: that is a commitment. If you slip and let go, the
|
||||
> shade will roll back up into the spool at the top: that is an exception.
|
||||
>
|
||||
> What you can't do is prepare work on the way down which needs _any_ further pulling
|
||||
> to be in a consistent state and not leak. You might slip and let go at any time for
|
||||
> any reason. A `malloc()` on one line and a `free()` following it is an example of
|
||||
> requiring more pulling.
|
||||
>
|
||||
> Indeed slipping and letting go is an accident -- but the point is that *accidents
|
||||
> happen*. They're not always your fault, and many times are outside of your control.
|
||||
> This is a good approach for robust and durable code over long-lived large-scale
|
||||
> projects.
|
||||
>
|
||||
|
||||
|
||||
#### Exceptions will be used
|
||||
|
||||
|
|
Loading…
Reference in a new issue