HugoGranstrom / nimiSlides

A Reveal.js theme for nimib for making slideshow presentations in Nim
https://hugogranstrom.com/nimiSlides
MIT License
80 stars 6 forks source link

Syntax for Fragments #1

Closed HugoGranstrom closed 2 years ago

HugoGranstrom commented 2 years ago

Right now we have a impl with varargs but that is a bit messy and buggy to work with. Would an openarray/seq-based approach be viable instead? Examples:

# current approach:
fragment(@[fadeIn], @[highlightRed], @[fadeOut])

# seq-based approach:
fragment(@[@[fadeIn], @[highlightRed], @[fadeOut]])

The second approach is considerably uglier to me but easier to work with. Most importantly it would allow us to pass in more parameters to fragment, like end-animations that are applied at the end of a block.

I think using an all-seq implementation internally is needed, but then we can add sugary varargs functions for ease of use for common usecases. How should the distinction between them be API-wise then? Should the sugar or the low-level functions have the fragment name? (Both can't have it as varags and seq functions will clash with each other). So either we have fragmentSugar + fragment or fragment + fragmentLowLevel.

A third option would be to write a macro, but I'd rather not...

HugoGranstrom commented 2 years ago

After some thought, I think I will use the naming scheme fragmentCore for the low-level seq-based function and fragment for the higher-level ones.

HugoGranstrom commented 2 years ago

fragmentCore is the seq-based fundation that all varargs sugar is built on top of.