• Re: Resources to learn common lisp?

    From Johann \@johann@myrkraverk.invalid to comp.lang.misc,comp.lang.c++ on Fri Sep 18 10:49:09 2026
    From Newsgroup: comp.lang.c++

    On 8/27/2026 6:47 PM, Stefan Ram wrote:

    Dear Stefan,

    Please forgive me for this necromantic posting; I only got around to
    read this today.

    // Helper to sanitize a word to lowercase alphanumeric characters
    auto sanitize = [](std::string w) {
    auto clean = w | std::views::filter([](char c) { return std::isalnum(c); })
    | std::views::transform([](char c) { return std::tolower(c); });
    return std::string(clean.begin(), clean.end());
    };
    Here, it seems the variable /clean/ is completely superfluous [1].

    Wouldn't it be much better if std::string() -- the constructor -- could
    just use the filter directly? I mean, something like this, instead; un- tested.

    return std::string( w | filter | transform ) ;

    Obviously I skipped over a lot of previous syntax, but I believe the
    essence of the new lambda should be understood. This can even be used
    to get rid of the {} in the lambda, allowing syntax like

    auto sanitize = []( std::string w ) return std::string( w | filter |
    transform ) ;

    and therefore be even clearer than the original that we are dealing with
    a lambda, rather than a regular function.

    I have added comp.lang.c++ to this discussion.


    What do you think?


    [1] I'm obviously using the A.W.K. syntax for matching regular ex-
    pressions here.
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Johann \@johann@myrkraverk.invalid to comp.lang.misc,comp.lang.c++,comp.lang.perl on Fri Sep 18 11:05:46 2026
    From Newsgroup: comp.lang.c++

    On 8/27/2026 6:47 PM, Stefan Ram wrote:

    // Helper to sanitize a word to lowercase alphanumeric characters
    auto sanitize = [](std::string w) {
    auto clean = w | std::views::filter([](char c) { return std::isalnum(c); })
    | std::views::transform([](char c) { return std::tolower(c); });
    return std::string(clean.begin(), clean.end());
    };
    Dear Stefan,

    I also failed to notice at first glance that your word counting program,
    while quite brilliant -- I'll probably give it a try this weekend -- is
    failing to properly count "they're", "dog's" and such. I'm not sure
    modern C++ has a std::isenglishword() function, so my proposal would be something like

    return std::isalnum( c ) || c == '\'' ;

    but that fails if the input has Bri'ish quotes 'like this', or TeX
    quotes `like this' or even ``like this.''

    Has Bjarne thought to include PCRE2 in C++ already? Can we use a reg-
    ular expression to match ' only if it's inside a word? Do we want to
    account for Unicode single curly quotes too?

    I have added comp.lang.perl to this discussion, on the off chance this
    is already a solved problem with a regular expression.

    I have added comp.lang.c++ for the obvious reason.

    I am not aware of comp.lang.c++.boost being a real group, do you think
    it should be proposed in news.groups.proposals?


    Best wishes, and happy word counting in C++!
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From red floyd@no.spam.here@its.invalid to comp.lang.misc,comp.lang.c++,comp.lang.perl on Thu Sep 17 21:43:44 2026
    From Newsgroup: comp.lang.c++

    On 9/17/2026 8:05 PM, Johann "Myrkraverk" Oskarsson wrote:
    On 8/27/2026 6:47 PM, Stefan Ram wrote:

    Has Bjarne thought to include PCRE2 in C++ already?-a Can we use a reg-
    ular expression to match ' only if it's inside a word?-a Do we want to account for Unicode single curly quotes too?

    C++ has had a regex library since C++11.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.lang.misc,comp.lang.c++ on Fri Sep 18 10:25:32 2026
    From Newsgroup: comp.lang.c++

    "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> wrote or quoted: >> // Helper to sanitize a word to lowercase alphanumeric characters
    auto sanitize = [](std::string w) {
    auto clean = w | std::views::filter([](char c) { return std::isalnum(c); })
    | std::views::transform([](char c) { return std::tolower(c); });
    return std::string(clean.begin(), clean.end());
    };
    Here, it seems the variable /clean/ is completely superfluous [1].

    I'm not sure I know what code you have in mind that does not use
    that variable.

    Wouldn't it be much better if std::string() -- the constructor -- could
    just use the filter directly? I mean, something like this, instead; un- >tested.
    return std::string( w | filter | transform ) ;

    Well, one /can/ write

    auto sanitize = []( ::std::string w ) {
    return w | std::views::filter( []( char c ){ return ::std::isalnum( c ); })
    | std::views::transform( []( char c ){ return ::std::tolower( c ); })
    | std::ranges::to< ::std::string >();
    };

    .

    auto sanitize = []( ::std::string w ) return ::std::string( w | filter |
    transform ) ;

    So, I assume that you would still have to define that "filter"
    does "isalnum" and that "transform" does "tolower" somewhere?

    What you can do is to define,

    inline constexpr auto filter = std::views::filter( []( char c ){ return ::std::isalnum( c ); });
    inline constexpr auto transform = std::views::transform( []( char c ){ return ::std::tolower( c ); });

    , outside of a function (before "int main()") and then use,

    auto sanitize = []( ::std::string w ) {
    return w | filter | transform | ::std::ranges::to< ::std::string >();
    };

    .


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.lang.misc,comp.lang.c++ on Fri Sep 18 10:28:58 2026
    From Newsgroup: comp.lang.c++

    "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> wrote or quoted: >Has Bjarne thought to include PCRE2 in C++ already? Can we use a reg-
    ular expression to match ' only if it's inside a word? Do we want to
    account for Unicode single curly quotes too?

    "::std::regex" was introduced in C++11 (2011), but due to
    performance problems, it's scheduled to be deprecated.

    Newsgroups: comp.lang.misc,comp.lang.c++


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Johann 'Myrkraverk' Oskarsson@johann@myrkraverk.invalid to comp.lang.misc,comp.lang.c++ on Fri Sep 18 21:33:05 2026
    From Newsgroup: comp.lang.c++

    On 18/09/2026 6:28 PM, Stefan Ram wrote:
    "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> wrote or quoted:
    Has Bjarne thought to include PCRE2 in C++ already? Can we use a reg-
    ular expression to match ' only if it's inside a word? Do we want to
    account for Unicode single curly quotes too?

    "::std::regex" was introduced in C++11 (2011), but due to
    performance problems, it's scheduled to be deprecated.

    Newsgroups: comp.lang.misc,comp.lang.c++



    Dear Stefan,

    Well, in my defense, I haven't used much of C++ since C++98 -- by that I
    mean the standard -- since most C++ A.P.Is. are usable with roughly that knowledge. I have Meyers' /Effective Modern C++/ on my shelf, but it's
    still in my to-read-in-the-near-future pile; thanks to tsundoku.

    I also have Stroustrup's 4th edition, but I'm not sure it's worth read-
    ing to catch up on the latest? What do you think?

    Now, on the subject of regular expressions, we are now in a quandary, do
    we try to fix your word counting program with std::regex, and have it be uncompilable in the near future, or do we just use PCRE2 and have it be compilable forever?

    I use the word /try/ here because I'm not offhand sure a good word
    counting program can be done with strictly a regular expression, and
    I am in no hurry to adopt John Levin's [1] for this purpose, and use
    L.A.R.L. I'm leaving off comp.compilers because my Usenet provider
    seems to have trouble with posts to moderated Usenet groups, and I
    haven't emailed them about it yet; plus this is probably a bit too
    simple to bother the compiler experts about, now that I think about
    it for the second time.

    I am however willing to attempt to use PCRE2 in a C++ program over the
    weekend so let's see what happens, and if I have the time for such an
    adventure and so forth; no promises. I mean, compiling PCRE2 with MSVC
    can't be that hard, can it?


    Best wishes, and happy C++!

    [1] The one in the book /Flex & Bison/.
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.lang.misc,comp.lang.c++ on Fri Sep 18 13:51:13 2026
    From Newsgroup: comp.lang.c++

    Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote or quoted:
    I also have Stroustrup's 4th edition, but I'm not sure it's worth read-
    ing to catch up on the latest? What do you think?

    "The C++ Programming Language", fourth edition is excellent to catch
    up on C++11, but we are approaching C++26 now and a lot has changed.

    You could read the working draft N5046 as of 2026-05-12, but it's a
    bit technical. C++ is moving too fast currently for textbook authors
    to keep up, so maybe try websites like cppreference!

    The chatbot's comment:

    | The transition "but it's a bit technical" is a bit of an
    | understatement - the ISO working draft is famously dry and
    | notoriously difficult to read for general learning.

    .


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.lang.misc,comp.lang.c++ on Fri Sep 18 14:23:08 2026
    From Newsgroup: comp.lang.c++

    Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote or quoted:
    I use the word /try/ here because I'm not offhand sure a good word
    counting program can be done with strictly a regular expression,

    During this thread I did not think about it as a real
    application, but just as a example for programming. But if
    you ask me about it, the most important thing for a really
    good word-counting program is one's definition of "word".


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.lang.c++ on Fri Sep 18 14:41:00 2026
    From Newsgroup: comp.lang.c++

    ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
    You could read the working draft N5046 as of 2026-05-12, but it's a
    bit technical. C++ is moving too fast currently for textbook authors
    to keep up, so maybe try websites like cppreference!

    . . . and the C++ Core Guidelines.

    Newsgroups: comp.lang.c++


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From boltar@boltar@caprica.universe to comp.lang.misc,comp.lang.c++,comp.lang.perl on Fri Sep 18 15:11:15 2026
    From Newsgroup: comp.lang.c++

    On Fri, 18 Sep 2026 11:05:46 +0800
    "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> gabbled:
    Has Bjarne thought to include PCRE2 in C++ already? Can we use a reg-
    ular expression to match ' only if it's inside a word? Do we want to
    account for Unicode single curly quotes too?

    Instead of ever niche academic circle jerking wrt C++ expansion, it would be nice if some more basic stuff was added first that other languages have supported since their inception. Eg, how about a switch() construct that operated on more than just POD types?

    std::string mystr = "hello";
    :
    :
    switch(mystr)
    {
    case "hello": ...
    case "world": ...
    :
    }

    etc.

    So long as the object had operator==() defined I see no problem with overloading
    switch in this way.

    The amount of times I've had to write endless if-else's instead of this I've lost count of.

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.lang.misc,comp.lang.c++ on Fri Sep 18 15:25:17 2026
    From Newsgroup: comp.lang.c++

    boltar@caprica.universe writes: Eg, how about a switch() construct that >operated on more than just POD types?

    Expected in C++29:

    inspect (mystr) {
    "hello" => { /* ... */ },
    "world" => { /* ... */ },
    _ => { /* default */ }
    };

    Newsgroups: comp.lang.misc,comp.lang.c++


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Johann \@johann@myrkraverk.invalid to comp.lang.misc,comp.lang.c++,comp.lang.perl on Fri Sep 18 23:39:12 2026
    From Newsgroup: comp.lang.c++

    On 9/18/2026 11:11 PM, boltar@caprica.universe wrote:
    On Fri, 18 Sep 2026 11:05:46 +0800
    "Johann \"Myrkraverk\" Oskarsson" <johann@myrkraverk.invalid> gabbled:
    Has Bjarne thought to include PCRE2 in C++ already?-a Can we use a reg-
    ular expression to match ' only if it's inside a word?-a Do we want to
    account for Unicode single curly quotes too?

    Instead of ever niche academic circle jerking wrt C++ expansion, it
    would be
    nice if some more basic stuff was added first that other languages have supported since their inception. Eg, how about a switch() construct that operated on more than just POD types?

    std::string mystr = "hello";
    :
    :
    switch(mystr)
    {
    case "hello": ...
    case "world": ...
    :
    }

    etc.

    So long as the object had operator==() defined I see no problem with overloading
    switch in this way.

    The amount of times I've had to write endless if-else's instead of this
    I've
    lost count of.

    I honestly agree with you. Stroustrup has added almost everything to
    C++, so this lack of a generic switch () is astounding.

    Now, by merely adding PCRE2 to the compiler, we can even extend this
    syntax to A.W.K. like matching, for something akin to

    switch( str ) {
    case /re1/: ...
    case /re2/: ...
    }

    but that's better left as an exercise /after/ we get more generic switch
    () into standard C++.


    After all, everyone should be familiar with this kind of pattern match-
    ing syntax in Dtrace.
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From boltar@boltar@caprica.universe to comp.lang.misc,comp.lang.c++ on Fri Sep 18 15:49:23 2026
    From Newsgroup: comp.lang.c++

    On 18 Sep 2026 15:25:17 GMT
    ram@zedat.fu-berlin.de (Stefan Ram) gabbled:
    boltar@caprica.universe writes: Eg, how about a switch() construct that >>operated on more than just POD types?

    Expected in C++29:

    inspect (mystr) {
    "hello" => { /* ... */ },
    "world" => { /* ... */ },
    _ => { /* default */ }
    };

    Wtf?? Why an entirely new construct, just overload switch! Also I can guarantee than there's a ton of current code that will already be using the word "inspect" in some way.


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.lang.misc,comp.lang.c++ on Fri Sep 18 16:05:52 2026
    From Newsgroup: comp.lang.c++

    boltar@caprica.universe wrote or quoted:
    Why an entirely new construct, just overload switch!

    Switch already has fall-through semantic which is not desired
    for the new inspect statement. Also parsing both the old and
    the new "case" syntax can become difficult.

    Also I can guarantee than there's a ton of current code that
    will already be using the word "inspect" in some way.

    If the compiler sees "inspect (variable) { ... }", it parses
    it as a pattern-matching block.

    If it sees "int inspect = 5;" or "my_object.inspect()", it treats
    it as a completely valid standard identifier.

    Newsgroups: comp.lang.misc,comp.lang.c++
    Followup-to: comp.lang.c++


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From David Brown@david.brown@hesbynett.no to comp.lang.misc,comp.lang.c++ on Fri Sep 18 18:18:40 2026
    From Newsgroup: comp.lang.c++

    On 18/09/2026 17:49, boltar@caprica.universe wrote:
    On 18 Sep 2026 15:25:17 GMT
    ram@zedat.fu-berlin.de (Stefan Ram) gabbled:
    boltar@caprica.universe writes: Eg, how about a switch() construct that >>> operated on more than just POD types?

    Expected in C++29:

    inspect (mystr) {
    "hello" => { /* ... */ },
    "world" => { /* ... */ },
    _ => { /* default */ }
    };

    Wtf?? Why an entirely new construct, just overload switch! Also I can guarantee than there's a ton of current code that will already be using the word "inspect" in some way.


    "inspect" is /not/ expected in C++29 - Stefan is a bit out of date. It
    was one of several alternative proposals for a new pattern-matching
    feature. The current candidate is "match", with a syntax like :

    x match {
    0 => std::printf("zero");
    1 => std::printf("one");
    _ => std::printf("something else");
    }

    This works like a normal "switch", but there is no fall-through (so no
    "break" statements), and it is not weirdly unstructured.

    s match {
    "zero" => std::printf("zero");
    "one" => std::printf("one");
    _ => std::printf("something else");
    }

    It will work with any literal types. It can also be used to match
    variant types, polymorphic types, etc.

    And there are few situations where an existing identifier "match" could
    be in conflict with the new keyword. (You could cause trouble with a
    macro called "match", but that seems unlikely in real code.)


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Johann \@johann@myrkraverk.invalid to comp.lang.misc,comp.lang.c++ on Sat Sep 19 00:35:44 2026
    From Newsgroup: comp.lang.c++

    On 9/19/2026 12:18 AM, David Brown wrote:
    On 18/09/2026 17:49, boltar@caprica.universe wrote:
    On 18 Sep 2026 15:25:17 GMT
    ram@zedat.fu-berlin.de (Stefan Ram) gabbled:
    boltar@caprica.universe writes:-a-a Eg, how about a switch() construct
    that
    operated on more than just POD types?

    -a Expected in C++29:

    inspect (mystr) {
    -a-a-a "hello" => { /* ... */ },
    -a-a-a "world" => { /* ... */ },
    -a-a-a _-a-a-a-a-a-a => { /* default */ }
    };

    Wtf?? Why an entirely new construct, just overload switch! Also I can
    guarantee than there's a ton of current code that will already be
    using the
    word "inspect" in some way.


    "inspect" is /not/ expected in C++29 - Stefan is a bit out of date.-a It
    was one of several alternative proposals for a new pattern-matching feature.-a The current candidate is "match", with a syntax like :

    -a-a-a-ax match {
    -a-a-a-a-a-a-a 0 => std::printf("zero");
    -a-a-a-a-a-a-a 1 => std::printf("one");
    -a-a-a-a-a-a-a _ => std::printf("something else");
    -a-a-a-a}

    This works like a normal "switch", but there is no fall-through (so no "break" statements), and it is not weirdly unstructured.

    -a-a-a-as match {
    -a-a-a-a-a-a-a "zero" => std::printf("zero");
    -a-a-a-a-a-a-a "one" => std::printf("one");
    -a-a-a-a-a-a-a _ => std::printf("something else");
    -a-a-a-a}

    It will work with any literal types.-a It can also be used to match
    variant types, polymorphic types, etc.

    And there are few situations where an existing identifier "match" could
    be in conflict with the new keyword.-a (You could cause trouble with a
    macro called "match", but that seems unlikely in real code.)

    This is more akin to the original -- I believe -- the ML of Edinburgh.
    Which is also what people have come to expect from Rust. Though full disclosure, I haven't reached the pattern matching in my studies of Rust
    yet, and my ML is rusty.

    So I think this is going in the right direction, by giving people what
    they expect from other programming languages. The keyword conflict is unfortunate, though.
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From boltar@boltar@caprica.universe to comp.lang.misc,comp.lang.c++ on Sat Sep 19 08:29:36 2026
    From Newsgroup: comp.lang.c++

    On 18 Sep 2026 16:05:52 GMT
    ram@zedat.fu-berlin.de (Stefan Ram) gabbled:
    boltar@caprica.universe wrote or quoted:
    Why an entirely new construct, just overload switch!

    Switch already has fall-through semantic which is not desired
    for the new inspect statement. Also parsing both the old and

    Says who?

    the new "case" syntax can become difficult.

    Rubbish. Other languages manage.

    Also I can guarantee than there's a ton of current code that
    will already be using the word "inspect" in some way.

    If the compiler sees "inspect (variable) { ... }", it parses
    it as a pattern-matching block.

    If it sees "int inspect = 5;" or "my_object.inspect()", it treats
    it as a completely valid standard identifier.

    So we treat "inspect" differently to every other keyword in that it can be
    used as a variable/function/whatever name too? Well that won't be confusing
    at all!


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Johann \@johann@myrkraverk.invalid to comp.lang.misc,comp.lang.c++ on Sat Sep 19 16:50:14 2026
    From Newsgroup: comp.lang.c++

    On 9/19/2026 4:29 PM, boltar@caprica.universe wrote:
    On 18 Sep 2026 16:05:52 GMT
    ram@zedat.fu-berlin.de (Stefan Ram) gabbled:
    boltar@caprica.universe wrote or quoted:
    Why an entirely new construct, just overload switch!

    Switch already has fall-through semantic which is not desired
    for the new inspect statement. Also parsing both the old and

    Says who?

    the new "case" syntax can become difficult.

    Rubbish. Other languages manage.

    Also I can guarantee than there's a ton of current code that
    will already be using the word "inspect" in some way.

    If the compiler sees "inspect (variable) { ... }", it parses
    it as a pattern-matching block.

    If it sees "int inspect = 5;" or "my_object.inspect()", it treats
    it as a completely valid standard identifier.

    So we treat "inspect" differently to every other keyword in that it can be used as a variable/function/whatever name too? Well that won't be confusing at all!

    I don't think that's a problem. C++ has already maximized the confu-
    sion. What we now have is a saturation of confuddlement, so we can just
    change the syntax as we please.
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;
    --- Synchronet 3.22a-Linux NewsLink 1.2