Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chirp templates: for statement #94

Open
nicopap opened this issue Sep 27, 2023 · 0 comments
Open

chirp templates: for statement #94

nicopap opened this issue Sep 27, 2023 · 0 comments
Labels
C-chirp relates to the cuicui_chirp file format crate specifically T-enhancement New feature or request

Comments

@nicopap
Copy link
Owner

nicopap commented Sep 27, 2023

We need a way to insert several entities from a list. But one of the issues is that statements are supposed to correspond to exactly one entity.

One option is for for loops to expand to a single entity, but spawn several entities within that entity. But I'm not quite sure how to express that in term of syntax. See:

BoxContent(column rules(1.*, 1.2*)) {
    BoxSelectedText(style(OptionBoxChoice) text(default_choice_text))
    for [size, content] in options_sizes in BoxTicks(row rules(1.3*, 1*)) {
        Tick(rules(size, 3px) option_tick(content))
    }
}
RArrow(style(OptionBoxRArrow) height(25px))

Maybe it's worthwhile to make an exception for for loops on the one entity rule? If so, this becomes a bit more sensible:

BoxContent(column rules(1.*, 1.2*)) {
    BoxSelectedText(style(OptionBoxChoice) text(default_choice_text))
    BoxTicks(row rules(1.3*, 1*)) {
      for [size, content] in options_sizes {
          Tick(rules(size, 3px) option_tick(content))
      }
    }
}
RArrow(style(OptionBoxRArrow) height(25px))

Other options

So what we really want is:

  1. Define a Query (using a dynamic query)
  2. Define a binding so that we can use the query return values
  3. Define a single statement
// rust-like syntax
// We could use <> instead of () in this particular instance
for (foo, bar) in Query((Foo, Bar), With(Baz)) {
    FooBarItem(method(foo))
}

// haskell-like syntax
let (foo, bar) = Query<(Foo, Bar), With<Baz>> in FooBarItem(method(foo))

I'll probably go with the rust-like syntax.

@nicopap nicopap added T-enhancement New feature or request C-chirp relates to the cuicui_chirp file format crate specifically labels Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-chirp relates to the cuicui_chirp file format crate specifically T-enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant