How to assign a different counter for each frame type in frame-it package?

Hello, i wish to create different frames, each of which has a different counter. So far, i’ve been unsuccessful :

#import "@preview/frame-it:1.2.0": *

#let example-counter = counter("example")
#let comment-counter = counter("comment")
#let preparation-counter = counter("preparation")
#let manipulation-counter = counter("manipulation")

#let (example, comment, preparation, manipulation) = frames(
  example: (
    title: "Exemple",
    counter: example-counter
  ),
  comment: (
    title: "Commentaire",
    counter: comment-counter
  ),
  preparation: (
    title: "Préparation",
    counter: preparation-counter
  ),
  manipulation: (
    title: "Manipulation",
    counter: manipulation-counter
  )
)

it gives Error: Assertion failed

Hello,
This should work:

#import "@preview/frame-it:1.2.0": *

#let (example,) = frames(
  example: (
    "Exemple",
  ),
  kind: "example",
)

#let (comment,) = frames(
  comment: (
    "Commentaire",
  ),
  kind: "comment",
)

#let (preparation,) = frames(
  preparation: (
    "Preparation",
  ),
  kind: "preparation",
)


#let (manipulation,) = frames(
  manipulation: (
    "Manipulation",
  ),
  kind: "manipulation",
)

#show: frame-style(styles.boxy, kind: "example")
#show: frame-style(styles.boxy, kind: "comment")
#show: frame-style(styles.boxy, kind: "preparation")
#show: frame-style(styles.boxy, kind: "manipulation")



#comment[this is a comment][hello]
#comment[this is a comment][hello again]

#manipulation[this is a manipulation][this has another counter]

Which gives this:

Thank you, this works.
However, i do not understand the following caveat :

When I do :

#let (preparation,) = frames(
  preparation: (
    "Preparation",
  ),
  kind: "preparation",
)

it works.

But when i remove the comma in #let (preparation) :


#let (preparation) = frames(
  preparation: (
    "Preparation",
  ),
  kind: "preparation",
)

i get the following error :

Expected function, found dictionary (line 11)
#preparation[Préparation 1][

Is that how typst is intended to function ? Is there a hidden reason behind why it has such an original syntax ? I would’ve expected a programming language compiler to yell when I leave a trailing comma, but not when there is none.

I don’t know anything about frame-it, but I can help you with your last question:

Typst tells you what is going on. frames returns a dictionary of frame making functions, not a single function, that’s why it’s called frames and not frame (which exists BTW). If you want just a single frame, you need to unpack this dictionary. In this case, this destructuring is done by the let binding #let (a_dictoniary_key,another_key) = dictionary which binds the value of dictionary.at("a_dictionary_key") to the name a_dictionary_key and the value of dictionary.at("another_key") to another_key. (IMHO this syntax is crazy but I’m just a Typst beginner.)

See also Scripting – Typst Documentation, look for #let(Austen,) = books

Hi, thanks for the insight and for the link to the wiki page.