Developing nonstandard string literals

There is a special kind of macro for defining nonstandard string literals, which look like a literal string but instead a macro is called when it is referenced.

A good example would be Julia's regular expression literal—for example, r"^hello". It is not a standard string literal because of the r prefix in front of the double quote. Let's first check the data type of such a literal. We can see that Regex object is created from the string:

We can also create our own nonstandard string literals. Let's try to work through a fun example together here.

Suppose that, for development purposes, we want to conveniently ...

Get Hands-On Design Patterns and Best Practices with Julia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.