#Is #import supposed to allow side effects?

23 messages · Page 1 of 1 (latest)

formal gust
#

Let's say a module (or package in LaTeX's term) has calls that have side effects

#set text(font: "Linux Libertine")
#show heading: set text(navy)

#let foo = "foo"
  1. Do these two calls affect files that import the file, i.e. are the fonts and heading colors supposed to be changed in the importing file?
  2. #import "file.typ": foo still have side effects, right? But maybe the user just wants foo without changing the font and heading color.
  3. What if there are collisions among multiple imported files?
lunar plaza
#

I at least know that #include does not have side effects other than on locally-defined elements

#

it's like inserting

#[ // the included thing ]

#

regarding #import, im not sure of the semantics here, but I think it won't have side effects in general

#

that requires some testing

tidal tusk
#

set and show rules only apply for the rest of the scope, they don't actually have side affects (they just transform what's coming after them). a file always has its own scope, so importing or including it does not mean that internal set or show rules extend into the importing or including scope

lunar plaza
#

though

#

could be nice to be able to import rules too

#

optionally

#

:p

#

maybe some sort of modifier to export them

#

idk

#

pub from Rust

#

lol

#

or just export

#

lol

tidal tusk
#

you can always define a template function in the imported file and then use it afterwards in the importing file.

lunar plaza
#

well you're right

tidal tusk
#

i think #show: it => {...} is one the best features of typst, actually

lunar plaza
#

you sure about that?

tidal tusk
#

next to kebab-case

lunar plaza
#

I think she- I mean, typstguy is the best feature

tidal tusk
#

:D