• String literals

    From Chris Ahlstrom@3:633/10 to All on Sat Apr 11 07:24:30 2026
    I recently learned about raw string literals and, OMG!

    <https://en.cppreference.com/w/cpp/language/string_literal.html>

    and

    <https://en.cppreference.com/w/cpp/language/user_literal.html>

    --
    Smile! You're on Candid Camera.

    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Sun Apr 12 16:25:41 2026
    Am 11.04.2026 um 13:24 schrieb Chris Ahlstrom:

    I recently learned about raw string literals and, OMG!
    <https://en.cppreference.com/w/cpp/language/string_literal.html>
    and
    <https://en.cppreference.com/w/cpp/language/user_literal.html>

    These string literals make sense for regex-string with a lot of "\"s.


    --- PyGate Linux v1.5.13
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Paavo Helde@3:633/10 to All on Mon Apr 13 15:21:33 2026
    On 4/11/2026 2:24 PM, Chris Ahlstrom wrote:
    I recently learned about raw string literals and, OMG!

    <https://en.cppreference.com/w/cpp/language/string_literal.html>

    and

    <https://en.cppreference.com/w/cpp/language/user_literal.html>


    I am using raw literals all the time for embedding pieces of other
    languages inside C++ (HTML, Markdown, JSON, scripting languages, etc),
    works very nicely.

    I was told I should use external resource files for that, but honestly I
    do not see much point in that. Why should I make my life more
    complicated than needed? There are more than enough complications already.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris Ahlstrom@3:633/10 to All on Mon Apr 13 08:22:18 2026
    Bonita Montero wrote this screed in ALL-CAPS:

    Am 11.04.2026 um 13:24 schrieb Chris Ahlstrom:

    I recently learned about raw string literals and, OMG!
    <https://en.cppreference.com/w/cpp/language/string_literal.html>
    and
    <https://en.cppreference.com/w/cpp/language/user_literal.html>

    These string literals make sense for regex-string with a lot of "\"s.

    Indeed, in getting to know the <regex> APIs I first encountered
    raw string literals.

    This is my current implementation of converting a shell glob to
    regex. Anything wrong/incomplete about it? I haven't tried
    testing a lot of globs (lazy).

    std::string glob_to_regex (const std::string & globb)
    {
    std::string result { "^" };
    for (char c : globb)
    {
    switch (c)
    {
    case '*': result += ".*"; break;
    case '?': result += "."; break;
    case '.': result += "\\."; break;
    case '\\':
    case '[': case ']': /* is this ']' really necessary? */
    case '(': case ')':
    case '{': case '}':
    case '+': case '^':
    case '$': case '|':
    result += "\\";
    result += c;
    break;
    default:
    result += c;
    break;
    }
    }
    result += "$";
    return result;
    }

    ---------

    Clipping his ballsack?

    --
    Women, when they have made a sheep of a man, always tell him that he is a
    lion with a will of iron.
    -- Honore' de Balzac

    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Mon Apr 13 15:51:04 2026
    Am 13.04.2026 um 14:21 schrieb Paavo Helde:

    I am using raw literals all the time for embedding pieces of other
    languages inside C++ (HTML, Markdown, JSON, scripting languages, etc),
    works very nicely.

    Soon there will be compilers who support #embed; it's C++26.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From boltar@3:633/10 to All on Tue Apr 14 09:25:58 2026
    On Mon, 13 Apr 2026 15:21:33 +0300
    Paavo Helde <eesnimi@osa.pri.ee> gabbled:
    On 4/11/2026 2:24 PM, Chris Ahlstrom wrote:
    I recently learned about raw string literals and, OMG!

    <https://en.cppreference.com/w/cpp/language/string_literal.html>

    and

    <https://en.cppreference.com/w/cpp/language/user_literal.html>


    I am using raw literals all the time for embedding pieces of other
    languages inside C++ (HTML, Markdown, JSON, scripting languages, etc),
    works very nicely.

    I was told I should use external resource files for that, but honestly I
    do not see much point in that. Why should I make my life more
    complicated than needed? There are more than enough complications already.

    Because unless its a personal project someone will have to debug and
    modify the logical mess that literals give rise to.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Tue Apr 14 14:03:09 2026
    Am 14.04.2026 um 11:25 schrieb boltar@caprica.universe:

    Because unless its a personal project someone will have to debug and
    modify the logical mess that literals give rise to.

    If you use them at the right place they're a relief.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Paavo Helde@3:633/10 to All on Wed Apr 15 08:15:47 2026
    On 4/14/2026 12:25 PM, boltar@caprica.universe wrote:
    On Mon, 13 Apr 2026 15:21:33 +0300
    Paavo Helde <eesnimi@osa.pri.ee> gabbled:
    On 4/11/2026 2:24 PM, Chris Ahlstrom wrote:
    I recently learned about raw string literals and, OMG!

    ÿÿÿÿ <https://en.cppreference.com/w/cpp/language/string_literal.html>

    and

    ÿÿÿÿ <https://en.cppreference.com/w/cpp/language/user_literal.html>


    I am using raw literals all the time for embedding pieces of other
    languages inside C++ (HTML, Markdown, JSON, scripting languages, etc),
    works very nicely.

    I was told I should use external resource files for that, but honestly
    I do not see much point in that. Why should I make my life more
    complicated than needed? There are more than enough complications
    already.

    Because unless its a personal project someone will have to debug and
    modify the logical mess that literals give rise to.

    As always, any feature can be abused or overused. If raw string literals
    do not suit the task at hand or the team preferences, one is free to not
    use them.




    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From boltar@3:633/10 to All on Wed Apr 15 08:23:40 2026
    On Wed, 15 Apr 2026 08:15:47 +0300
    Paavo Helde <eesnimi@osa.pri.ee> gabbled:
    On 4/14/2026 12:25 PM, boltar@caprica.universe wrote:
    On Mon, 13 Apr 2026 15:21:33 +0300
    Paavo Helde <eesnimi@osa.pri.ee> gabbled:
    On 4/11/2026 2:24 PM, Chris Ahlstrom wrote:
    I recently learned about raw string literals and, OMG!

    ÿÿÿÿ <https://en.cppreference.com/w/cpp/language/string_literal.html>

    and

    ÿÿÿÿ <https://en.cppreference.com/w/cpp/language/user_literal.html>


    I am using raw literals all the time for embedding pieces of other
    languages inside C++ (HTML, Markdown, JSON, scripting languages, etc),
    works very nicely.

    I was told I should use external resource files for that, but honestly
    I do not see much point in that. Why should I make my life more
    complicated than needed? There are more than enough complications
    already.

    Because unless its a personal project someone will have to debug and
    modify the logical mess that literals give rise to.

    As always, any feature can be abused or overused. If raw string literals
    do not suit the task at hand or the team preferences, one is free to not
    use them.

    I prefer explicit code where possible. Having to track down what "_mypostfix" actually does is a waste of everyones time.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Paavo Helde@3:633/10 to All on Wed Apr 15 12:35:03 2026
    On 4/15/2026 11:23 AM, boltar@caprica.universe wrote:
    On Wed, 15 Apr 2026 08:15:47 +0300
    Paavo Helde <eesnimi@osa.pri.ee> gabbled:
    On 4/14/2026 12:25 PM, boltar@caprica.universe wrote:
    On Mon, 13 Apr 2026 15:21:33 +0300
    Paavo Helde <eesnimi@osa.pri.ee> gabbled:
    On 4/11/2026 2:24 PM, Chris Ahlstrom wrote:
    I recently learned about raw string literals and, OMG!

    ÿÿÿÿ <https://en.cppreference.com/w/cpp/language/string_literal.html> >>>>>
    and

    ÿÿÿÿ <https://en.cppreference.com/w/cpp/language/user_literal.html>


    I am using raw literals all the time for embedding pieces of other
    languages inside C++ (HTML, Markdown, JSON, scripting languages,
    etc), works very nicely.

    I was told I should use external resource files for that, but
    honestly I do not see much point in that. Why should I make my life
    more complicated than needed? There are more than enough
    complications already.

    Because unless its a personal project someone will have to debug and
    modify the logical mess that literals give rise to.

    As always, any feature can be abused or overused. If raw string
    literals do not suit the task at hand or the team preferences, one is
    free to not use them.

    I prefer explicit code where possible. Having to track down what "_mypostfix"
    actually does is a waste of everyones time.

    What _mypostfix? Ah, you are probably talking about user-defined
    literals. I have not used those yet. I was talking about plain raw
    string literals.

    A markdown example (from an openapi.json generator):

    void AddSchemaVar(stringview name, stringview type, stringview
    description, stringview example, JSONBuilder& builder);
    // ...

    AddSchemaVar("Level", "integer", R"__(
    Log level which the message was logged at (0-9):

    - 0: `INFO` (unconditional output)
    - 1: `ERROR` (critical error)
    - 2: `ERROR` (error)
    - 3: `WARN` (warning)
    - 4: `WARN` (abnormal situation, handled)
    - 5: `INFO` (major event)
    - 6: `INFO` (minor event)
    - 7: `DEBUG` (event details)
    - 8: `DEBUG` (verbose)
    - 9: `DEBUG` (max verbose)

    )__", "4", builder_);

    BTW, having a decent editor with syntax coloring helps a lot with such multiline string literals.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From boltar@3:633/10 to All on Wed Apr 15 09:40:55 2026
    On Wed, 15 Apr 2026 12:35:03 +0300
    Paavo Helde <eesnimi@osa.pri.ee> gabbled:
    On 4/15/2026 11:23 AM, boltar@caprica.universe wrote:
    On Wed, 15 Apr 2026 08:15:47 +0300
    Paavo Helde <eesnimi@osa.pri.ee> gabbled:
    On 4/14/2026 12:25 PM, boltar@caprica.universe wrote:
    On Mon, 13 Apr 2026 15:21:33 +0300
    Paavo Helde <eesnimi@osa.pri.ee> gabbled:
    On 4/11/2026 2:24 PM, Chris Ahlstrom wrote:
    I recently learned about raw string literals and, OMG!

    ÿÿÿÿ <https://en.cppreference.com/w/cpp/language/string_literal.html>


    and

    ÿÿÿÿ <https://en.cppreference.com/w/cpp/language/user_literal.html> >>>>>>

    I am using raw literals all the time for embedding pieces of other
    languages inside C++ (HTML, Markdown, JSON, scripting languages,
    etc), works very nicely.

    I was told I should use external resource files for that, but
    honestly I do not see much point in that. Why should I make my life >>>>> more complicated than needed? There are more than enough
    complications already.

    Because unless its a personal project someone will have to debug and
    modify the logical mess that literals give rise to.

    As always, any feature can be abused or overused. If raw string
    literals do not suit the task at hand or the team preferences, one is
    free to not use them.

    I prefer explicit code where possible. Having to track down what
    "_mypostfix"
    actually does is a waste of everyones time.

    What _mypostfix? Ah, you are probably talking about user-defined
    literals. I have not used those yet. I was talking about plain raw
    string literals.

    Ah, my mistake. I was confusing different posts.


    --- PyGate Linux v1.5.14
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)