[Pitch] Regular Expression Literals

I'm :100: with @AliSoftware 's answer.
A type with prefix func / and postfix func / will conflict with /foobar/ regex syntax.


One extra note I want to add is that we might want to also consider about syntactic-level-macro like Rust has.

I won't push this macro idea further here in detail (because it's off topic), but when taking a look at its example:

let stylesheet: Stylesheet = css! {
  .root {
    width: 500px;
    height: 120px;
    flex-direction: row;
    padding: 20px;
  }
  .image {
    width: 80px;
    margin-right: 20px;
  }
  .text {
    height: 25px;
    align-self: center;
    flex-grow: 1;
  }
};

let node: DOMNode = rsx! {
  <view style={stylesheet.take(".root")}>
    <image style={stylesheet.take(".image")} src="..." />
    <text style={stylesheet.take(".text")}>
      Hello world!
    </text>
  </view>
};

New DSL can be designed and written inside the macro scope.
This is almost analogous to #regex(...) being discussed so far, except that DSL design can be made by any developers (Rust) or compiler-internal only (Swift).

I'm OK with compiler-internal for now, but we could probably make them scalable to open syntactic-macro for any developers in future with minimal changes.

1 Like

Found there's also regex builder pitch (just now!)

(Probably orthogonal to this thread's literal discussion though)