#Interaction between included files

1 messages · Page 1 of 1 (latest)

pastel crown
#

I was doing some testing using include files, to see how they interacted together.
I also read this doc: https://typst.app/docs/reference/scripting/#modules

Lets say there is a file "Main.typ" which #includes two files, "A.typ" and "B.typ":

// In Main.typ
#include "A.typ"
#include "B.typ"

From my testing, there can be no interaction between any of the 3 files, except that the contents represented by files "A.typ" and "B.typ" are inserted at their include location within "Main.typ".
Specifically, definitions created within the files are not observed outside the files when they are #included.

I really like this. It prevents symbols from clobbering each other, and from devs creating inter-file spaghetti.

But, besides my testing, I wanted to confirm that I'm not leaving some interaction out.

Does this generally sound correct?

Typst

Automate your document with Typst's scripting capabilities.

tawdry mason
#

and content includes state, metadata , stuff like that

#

so if A.typ has state("a", 0).update(5) and B.typ has contex t state("a", 0).get(), that will print 5 and not 0

#

in this sense, files work exactly like a #[ scope ]

#

definitions and rules are scoped to it, but the content inside goes outside

pastel crown
#

Thanks. That example of #[...] is illustrative.

sinful flower
#

Also, show/set rules from Main are applied to A and B