Skip to content

Conversation

stasm
Copy link
Collaborator

@stasm stasm commented Oct 12, 2023

After some more thinking and offline discussions, I'd like to extend the beauty contest (#485) with the following 3 approaches:

  • 0a is a hybrid mode which allows for simple patterns to be unquoted (...) Renamed to 2a.

  • 1b is a variant of the text-first 1, but with the syntax directly inspired by existing templating languages.

    {% match {$foo} {$bar} %}
    {% when foo bar %} Hello {{ $foo }} you have a {{ $var }}
    {% when * * %} {{ $foo }} hello you have a {{ $var }}
    
  • 2a is a hybrid mode which allows for simple patterns to be unquoted (Hello!), and switches to the "complex" mode when the message is wrapped in {{ }}. The complex mode then uses the current syntax verbatim.

    {{ match {$foo} {$bar}
       when foo bar {Hello {$foo} you have a {$var}}
       when * * {{$foo} hello you have a {$var}}
    }}
    
  • 3b is a variant of keyword-based 3, but it uses #[...] for all control-flow-related syntax.

    #[match {$foo} {$bar}]
    #[foo bar] Hello {$foo} you have a {$var}
    #[  *   *] {$foo} hello you have a {$var}
    

@stasm stasm requested a review from aphillips October 13, 2023 06:38
@aphillips aphillips added the fast-track Editorial change permitted to use fast-track merge rules label Oct 13, 2023
@aphillips aphillips merged commit 9a294d1 into main Oct 13, 2023
@aphillips aphillips deleted the more-beauty-contestants branch October 13, 2023 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fast-track Editorial change permitted to use fast-track merge rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants