Rephrased 'read-only' as recommended by @MDLC01

This commit is contained in:
Ullrich Koethe 2025-03-04 21:04:44 +01:00 committed by GitHub
parent 262ec96a90
commit 7f9ddfbd80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -69,12 +69,12 @@ When a property is changed, the response to the query changes accordingly:
#context text.lang #context text.lang
``` ```
The output of a `#context ...` call is _read-only_ in the form of opaque The output of a `#context ...` call is static in the form of opaque
`content`. Write access is prohibited, as it would often result in `content`. Write access to context output is prohibited, as it would
invalid code: If the context changes between read and write, overwriting often result in invalid code: If the context changes between read and
a property would cause an inconsistent system state. In fact, write, overwriting a property would cause an inconsistent system state.
context-dependent property fields are read-only even within the context In fact, context-dependent property fields are immutable constants even
itself: within the context itself:
```example ```example
#set text(lang: "en") #set text(lang: "en")
@ -88,12 +88,13 @@ itself:
Both calls have the same output 'en', because `text.lang` is assigned Both calls have the same output 'en', because `text.lang` is assigned
upon entry in the context and remains constant until the end of its scope upon entry in the context and remains constant until the end of its scope
(the closing `]`). Compare this to the previous example: there we (the closing `]`). It does not "see" the `#set text(lang: "fr")` before
got two different results because we created two different contexts. call 2. Compare this to the previous example: there we got two different
results because we created two different contexts.
However, the read-only restriction only applies to the property fields However, immutability only applies to the property fields themselves.
themselves. Content creation instructions _do_ see the effect of the Content creation instructions within a context _do_ see the effect of
set rule. Consider the same example with font size: the set rule. Consider the same example with font size:
```example ```example
#set text(size: 50pt) #set text(size: 50pt)
@ -105,13 +106,12 @@ set rule. Consider the same example with font size:
] ]
``` ```
The second call still outputs '50pt', because `text.size` is a constant. Call 2 still outputs '50pt', because `text.size` is a constant.
However, this output is printed in '25pt' font, as specified by the set However, this output is printed in '25pt' font, as specified by the set
rule before the call. This illustrates the importance of picking the rule before the call. This illustrates the importance of picking the
right insertion point for a context to get access to precisely the right right insertion point for a context to get access to precisely the right
styles. styles. If you need access to updated property fields after a set rule,
If you need access to updated property fields after a set rule, you can you can use nested contexts:
use nested contexts:
```example ```example
#set text(lang: "en") #set text(lang: "en")
@ -171,8 +171,9 @@ original size
``` ```
but convenient alternatives like this do not exist for most properties. but convenient alternatives like this do not exist for most properties.
For example, to double the spacing between the lines of an equation block, This makes contexts a powerful and versatile concept. For example,
you can use the same technique in a show rule. In this case, explicitly to double the spacing between the lines of an equation block, you can
use the same resizing technique in a show rule. In this case, explicitly
adding the `context` keyword is not necessary, because a show rule adding the `context` keyword is not necessary, because a show rule
establishes a context automatically: establishes a context automatically: