Raw Strings and String Interpolation
Our declarative modeling language Rel has been expanded to include new string functionalities to better handle and manipulate string data.
Two new string literal forms are now supported: raw string literals and interpolation expressions inside string literals.
Raw string literals are string literals that keep their contents verbatim.
This allows users to provide complex strings (for example, for regular expressions) without any extra steps. No processing is applied and there is no need to escape special characters.
Complex strings are denoted by the
raw identifier, immediately followed by some amount of odd quotes. The same amount of quotes must be used to terminate the literal. Anything in between is taken as is.
Special characters can appear without escaping, and escaping a character simply means two characters (
\ and the escaped character). Any number of quotes that are less than the delimiting quotes can appear inside the literal.
Some examples are below.
The empty string. Note that this is the only form allowed for empty strings. Using more quotes results in a parser error:
Using quotes without escaping:
raw"""say, "hello" now"""
No need to use triple quotes for multiline strings:
raw"this is a multi line text "
Leading spaces are not discarded (as would be the case in “normal” string literals):
raw" Hello And bye "
Using multiple quotes inside the string:
raw"""""many """"quotes here"""""
Rel also now supports the arbitrary interpolation of expressions inside string literals.
The operator used for interpolation is
%. As such, if the actual percent character is needed instead, it has to be escaped (or alternatively, be used in a raw string literal).
The result of the interpolation is a string, so arbitrary “nesting” is allowed too, as shown in the examples below.
Alternative to using
raw"100% success rate":
"100\% success rate"
Interpolating values from an expression:
def names = "Alice"; "Bob" def output = "hello %(names)"
If the interpolated expression is a single variable, parentheses are optional:
def output = "hello %names"
The outer string literal is interpolating an expression that itself is using string interpolation:
def from_id = ("user_1", "Alice"); ("user_2", "Bob") def ids = 1;2;3 def output = "hello %(from_id["user_%ids"]) and bye"
We’re excited to learn about how you are using Rel — please let us know about any future features you’d like to see.
Understanding Our World
Rel is not a procedural language. It is a relational declarative language with roots in logic programming. Rel goes far beyond a simple type system by allowing you to define the rules your creations have to obey. Definitions are not methods that turn input into output, but rather rules that can be evaluated in both directions.
Is Database Administrator Still a Good Job?
The job of a database adminstrator is evolving, just as almost all careers in IT. DBAs are often the ones closest to the task of capturing the real world. This is arguably the base of the entire application stack. If you model is wrong, your data will be wrong, your predictions will be wrong, your decisions will be wrong. It all falls apart without the right model. It falls apart without those people who know what to capture and in what detail, what to connect and in what ways. That's the DBA.