• Re: Resources to learn common lisp?

    From Johann 'Myrkraverk' Oskarsson@johann@myrkraverk.invalid to comp.lang.lisp,comp.lang.misc,comp.lang.c on Mon Aug 24 19:38:57 2026
    From Newsgroup: comp.lang.misc

    On 24/08/2026 4:46 PM, tfb wrote:
    Paul Rubin <no.email@nospam.invalid> wrote:
    tfb <tfb@work.it.out> writes:
    No single language has 1% of constructs anyone might ever want.

    If I can code fluently in a language, that is, I can think entirely
    about the application-level problem I'm trying to solve and not putting
    much effort into choosing language constructs, then it's supplying 100%
    of what I want at least at that moment. That's great.


    Here's the thing: you are one person. There are, shockingly, other people
    in the world who might want to write programs. You may also have noted
    that more than one programming language exists. Although you are clearly happy with whatever language it is you use and never inclined to look at anything else, perhaps some if these other languages might exist because other people might want a different set of constructs, don't you think?


    Dear tfb,

    I have no idea what you're talking about. To me, Paul is absolutely
    correct. Being fluent in a programming language means I don't have to
    look things up constantly, such as figuring out what the various &
    symbols mean in Rust -- that's a recent adventure of mine, so I'm in-
    cluding comp.lang.misc until we have comp.lang.rust -- and it does get
    old fast.

    Working in an unfamiliar programming means I'm not fluent, and I cannot
    just write whatever I want -- I mean, the Rust compiler explicitly does
    not allow me to just /inline "Common Lisp"/ if I may speak in C++
    tokens; the equivalent Rust would probably be something like /inl Lisp {
    /* Common Lisp goes here */ }/, using AWK matching syntax for emphasis
    -- so I'm resorting to actually have to read the book, because constant-
    ly looking things up got old several days ago.

    This of course delays my chapter one project of /Writing a C Compiler/
    by Nora Sandler; so I'm including comp.lang.c in this discussion as
    well, for obvious reasons.


    So my question to you, dear tfb, when exactly do you not know a pro-
    gramming language, and when was the last time this happened to you?
    --
    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 tfb@tfb@work.it.out to comp.lang.lisp,comp.lang.misc,comp.lang.c on Mon Aug 24 12:22:13 2026
    From Newsgroup: comp.lang.misc

    Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote:


    I have no idea what you're talking about.

    You really don't, no.

    Hint: I am not talking about whether you know the language you are using
    well enough, but whether the language you are using provides the constructs
    you need to address the problem you are solving in it succinctly.
    --
    tfeb.org/computer/
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From tfb@tfb@work.it.out to comp.lang.lisp,comp.lang.misc,comp.lang.c on Mon Aug 24 13:18:29 2026
    From Newsgroup: comp.lang.misc



    I simply accuse you of having poor reading comprehension, and even worse writing comprehension.

    Do you really think that a thread about language extensibility and whether
    any given language could have enough co structs to satisfy all posdible
    users of that language had suddenly changed topic to how familiar an
    individual was with a given language? Really? Oh well.
    --
    tfeb.org/computer/
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Johann 'Myrkraverk' Oskarsson@johann@myrkraverk.invalid to comp.lang.lisp,comp.lang.misc,comp.lang.c on Mon Aug 24 22:16:15 2026
    From Newsgroup: comp.lang.misc

    On 24/08/2026 9:18 PM, tfb wrote:


    I simply accuse you of having poor reading comprehension, and even worse
    writing comprehension.

    Do you really think that a thread about language extensibility and whether any given language could have enough co structs to satisfy all posdible
    users of that language had suddenly changed topic to how familiar an individual was with a given language? Really? Oh well.


    Yes, because that's how human to human real world conversations work.
    Being strictly /on topic/ without any deviation is a social construct
    invented by psychopaths for psychopaths. It's because they can't deal
    with real human to human interactions, and have to /hide themselves/,
    and pretend.

    All. The. Time.

    You are being dangerously close to expose yourself as a psychopath, so I suggest you stop replying to me, and /touch grass/ or something.

    Side note, for people unfamiliar with the term psychopath in technology,
    please read this VICE article, and weep.


    https://www.vice.com/en/article/the-careers-that-attract-the-most-psychopaths-one-job-is-the-clear-winner/

    I have negative respect for psychopaths, for good reasons.


    Have a nice life outside of Usenet!
    --
    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 tfb@tfb@work.it.out to comp.lang.lisp,comp.lang.misc,comp.lang.c on Mon Aug 24 20:10:08 2026
    From Newsgroup: comp.lang.misc

    Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote:

    Yes, because that's how human to human real world conversations work.
    Being strictly /on topic/ without any deviation is a social construct invented by psychopaths for psychopaths. It's because they can't deal
    with real human to human interactions, and have to /hide themselves/,
    and pretend.

    All. The. Time.

    You are being dangerously close to expose yourself as a psychopath, so I suggest you stop replying to me, and /touch grass/ or something.


    I must admit to being pretty amused by how quickly some random internet buffoon, who very obviously is not a native English speaker, has moved from accusing me of poor English reading comprehension rCo and 'writing comprehension', which as a native English speaker I assume must mean 'comprehensible writing', but I dunno rCo to saying I'm about to expose
    myself as a psychopath because I 'can't deal with human to human
    interactions' (which is ... funny). (I half expect the same person is now wondering whether I'm using an LLM because of the spaced dashes. Hint:
    no.)

    And now, because I admit to laughing at you, it will no doubt confirm
    whatever pop-psychology rubbish you want to believe about people you've
    never met and never will. No: quite ordinary people laugh at fools, it
    turns put: there's a whole genre of comedy based on that.

    So be it.
    --
    tfeb.org/computer/
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul Rubin@no.email@nospam.invalid to comp.lang.lisp,comp.lang.misc,comp.lang.c on Mon Aug 24 17:10:51 2026
    From Newsgroup: comp.lang.misc

    tfb <tfb@work.it.out> writes:
    Do you really think that a thread about language extensibility and whether any given language could have enough co structs to satisfy all posdible
    users of that language had suddenly changed topic to how familiar an individual was with a given language?

    Fluency does matter.

    If fluency in a language lets me do most of my daily tasks with at most occasional inconvenience, I'd call the language satisfactory. Stuff
    like macros make inconvenient things convenient. They don't make the impossible possible. And if the language makes enough everyday things convenient, it's ok with me if some inconvenient ones are left over.

    So I haven't felt lack of macros to be a serious shortcoming of non-Lisp languages. There are usually alternate mechanisms offered, like
    function decorators in Python.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Johann 'Myrkraverk' Oskarsson@johann@myrkraverk.invalid to comp.lang.lisp,comp.lang.misc,comp.lang.c on Tue Aug 25 10:34:47 2026
    From Newsgroup: comp.lang.misc

    On 25/08/2026 4:10 AM, tfb wrote:
    Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote:

    Yes, because that's how human to human real world conversations work.
    Being strictly /on topic/ without any deviation is a social construct
    invented by psychopaths for psychopaths. It's because they can't deal
    with real human to human interactions, and have to /hide themselves/,
    and pretend.

    All. The. Time.

    You are being dangerously close to expose yourself as a psychopath, so I
    suggest you stop replying to me, and /touch grass/ or something.


    I must admit to being pretty amused by how quickly some random internet buffoon, who very obviously is not a native English speaker, has moved from accusing me of poor English reading comprehension rCo and 'writing comprehension', which as a native English speaker I assume must mean 'comprehensible writing', but I dunno rCo to saying I'm about to expose myself as a psychopath because I 'can't deal with human to human interactions' (which is ... funny). (I half expect the same person is now wondering whether I'm using an LLM because of the spaced dashes. Hint:
    no.)

    And I must admit being pretty amused by people whose only claim to
    language skills is to be /born in a country/. You may laugh, you may
    cry, I don't give a shit. The thing is, people with poor reading
    comprehension don't know it. They always, always, accuse the other
    person of being /poor at communicating/, and often cannot be corrected
    because they don't believe they can possibly be in the wrong.

    Thank you for proving my point about your poor reading comprehension.

    And just like Lewis Carrol when he wrote Alice in Wonderland, or Through
    the Looking Glass -- I don't care which book had this quote -- I use my
    words to mean what I mean, and not what you decide it means.

    And now, because I admit to laughing at you, it will no doubt confirm whatever pop-psychology rubbish you want to believe about people you've
    never met and never will. No: quite ordinary people laugh at fools, it
    turns put: there's a whole genre of comedy based on that.

    So be it.


    Fools laugh at people wiser than them, that's true. Thank you for prov-
    ing to me you're a fool.
    --
    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 'Myrkraverk' Oskarsson@johann@myrkraverk.invalid to comp.lang.lisp,comp.lang.misc,comp.lang.c on Tue Aug 25 10:41:57 2026
    From Newsgroup: comp.lang.misc

    On 25/08/2026 8:10 AM, Paul Rubin wrote:
    tfb <tfb@work.it.out> writes:
    Do you really think that a thread about language extensibility and whether >> any given language could have enough co structs to satisfy all posdible
    users of that language had suddenly changed topic to how familiar an
    individual was with a given language?

    Fluency does matter.

    If fluency in a language lets me do most of my daily tasks with at most occasional inconvenience, I'd call the language satisfactory. Stuff
    like macros make inconvenient things convenient. They don't make the impossible possible. And if the language makes enough everyday things convenient, it's ok with me if some inconvenient ones are left over.

    So I haven't felt lack of macros to be a serious shortcoming of non-Lisp languages. There are usually alternate mechanisms offered, like
    function decorators in Python.

    Thank you Paul. Now, if we're in the realm of impossible, there's very
    little that can be said to be truly /impossible/ in Common Lisp. This
    is because compilers like Steel Banks Common Lisp not only compile to
    pure binary code, they also offer Lisp syntax to just write the function
    in assembly. This is apparent to anyone who's delved into the inner
    guts of the compiler.

    Now, when we can just casually switch over to the assembly language, the /impossible/ is limited by the capabilities of the machine, and our
    patience to get whatever we want done.

    I mean, we can -- with enough patience and understanding, and reading of
    the code -- just overwrite the Common Lisp compiler, and the binaries it generates.

    I believe that's impossible in Python, so again I invite Lawrence D'Oli-
    veiro to correct me.

    And on the subject of macros, we can always template program like it's
    1976, and create our own textual code generator like Yacc. Though we
    don't have to create one in the context of parsing. This trick works
    equally in Python, and Common Lisp, but is for some reasons hardly ever
    used in practice today. Everyone seems to be hell bent on having the programmability of the programming language itself embedded in the de-
    fault compiler. Why is that?
    --
    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 tfb@tfb@work.it.out to comp.lang.lisp,comp.lang.misc,comp.lang.c on Tue Aug 25 09:22:44 2026
    From Newsgroup: comp.lang.misc

    oPaul Rubin <no.email@nospam.invalid> wrote:

    Fluency does matter.

    Absolutely so. Interestingly it's possible to not be fluent in languages
    (or language constructs) that you've designed: after Zyni and I wrote +atar
    (an iteration construct for CL), it took me months to become comfortable
    enough in it to use it to the exclusion of most of the standard ones. Some
    of this was worry about how large the support for it was (entirely silly on modern systems) and performance (we had benchmarks, but somehow these
    didn't help convince me), but part of it was just 'how do I get it to do
    that, erm ...'.


    If fluency in a language lets me do most of my daily tasks with at most occasional inconvenience, I'd call the language satisfactory. Stuff
    like macros make inconvenient things convenient. They don't make the impossible possible. And if the language makes enough everyday things convenient, it's ok with me if some inconvenient ones are left over.

    So I haven't felt lack of macros to be a serious shortcoming of non-Lisp languages. There are usually alternate mechanisms offered, like
    function decorators in Python.


    And that's fine. There are people for whom Fortran (I mean FORTRAN,
    probably, because modern Fortran is a large and flexible language only
    really related to anything older than Fortran 90 by some backward compatibility) is a language in which they are fluent and who feel no need
    for any other language. There is absolutely nothing wrong with that.

    But if I asserted that nobody should want a language other than FORTRAN,
    that would probably be something quite a lot of people would take issue
    with. And they would be right.

    If I asserted that *any single* programming language should be something
    every person is comfortable with then I think people would take issue with that, as well. There would probably be some extremists who would say,
    well, if only everyone saw and understood the blinding light of (Python|Ruby|Lisp) then they would achieve true happiness. But those
    people are pushing what is essentially a cult. And empirically those
    people are just wrong: if they were right, why are there so many
    programming languages? Why are there both Python cultists and Ruby
    cultists if there is more than one true language? Do we need some kind of purge of the nonbelievers?

    Well, perhaps there is some finite and fairly small set of languages that
    would meet everyone's requirements for comfort? If that were so, why do
    people endlessly invent new ones? If there is a finite set, we're clearly
    not close to reaching it yet.

    I suggest that the set of languages which would mean *everyone* was
    comfortable is not usefully finite. If hardware architecture was
    unchanging and there was a fixed set of problem domains it conceivably
    might be, but neither of those things is true. Modern Fortran has grown
    all sorts of new constructs designed to deal with what modern
    supercomputers look like, for instance.

    Language exploration and modification therefore matters. It may not matter
    for you, or for me: we may be fluent in and comfortable with our fixed languages (they might even be the same language). But *that means
    nothing*: it still matters.

    And (this is the contentious bit): I think that, since it matters, removing barriers to it also matters. It will never be easy, but it shouldn't
    require designing a whole new language to explore one idea. It should be possible to write functions in an existing language which map constructs expressing that new (or borrowed) idea into the existing language. Those functions have a name: macros. You may not want to use them: that is not
    an argument that they are not useful to other people, and to pretend it is would be as grotesquely arrogant as if I was to say that because *I* have
    no use for a church it should be demolished.
    --
    tfeb.org/computer/
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul Rubin@no.email@nospam.invalid to comp.lang.lisp,comp.lang.misc,comp.lang.c on Tue Aug 25 22:13:06 2026
    From Newsgroup: comp.lang.misc

    tfb <tfb@work.it.out> writes:
    There would probably be some extremists who would say, well, if only
    everyone saw and understood the blinding light of (Python|Ruby|Lisp)
    then they would achieve true happiness.

    The Blub fallacy. Yes it applies to CL just like to anything else.

    It should be possible to write functions in an existing language which
    map constructs expressing that new (or borrowed) idea into the
    existing language. Those functions have a name: macros.

    Meh, if the old language can express the new idea at all, then the new
    idea isn't that big of a change. Like try implementing Scheme
    continuations as macros in CL.

    There's a theoretical paper by Felleisen about what really adds
    expressive power to programming languages. Sadly, I don't understand
    it, but maybe someday.

    https://www2.ccs.neu.edu/racket/pubs/scp91-felleisen.pdf
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Anton Antimo@anton@safunu.org to comp.lang.lisp,comp.lang.misc,comp.lang.c on Wed Aug 26 15:43:38 2026
    From Newsgroup: comp.lang.misc

    Paul Rubin <no.email@nospam.invalid> writes:

    tfb <tfb@work.it.out> writes:
    There would probably be some extremists who would say, well, if only
    everyone saw and understood the blinding light of (Python|Ruby|Lisp)
    then they would achieve true happiness.

    The Blub fallacy. Yes it applies to CL just like to anything else.

    It should be possible to write functions in an existing language which
    map constructs expressing that new (or borrowed) idea into the
    existing language. Those functions have a name: macros.

    Meh, if the old language can express the new idea at all, then the new
    idea isn't that big of a change. Like try implementing Scheme
    continuations as macros in CL.

    Doug Hoyte does it in Let Over Lambda. But even if we have here a case
    where things don't work out so well, one case won't break the efficacy
    of all other cases.

    There's a theoretical paper by Felleisen about what really adds
    expressive power to programming languages. Sadly, I don't understand
    it, but maybe someday.

    https://www2.ccs.neu.edu/racket/pubs/scp91-felleisen.pdf

    Care to share what you don't understand about the paper? I suppose the
    subject is still interesting to the newsgroups addressed here, though it
    leans more towards comp.lang.misc and comp.theory and sci.logic.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul Rubin@no.email@nospam.invalid to comp.lang.lisp,comp.lang.misc,comp.lang.c on Wed Aug 26 18:23:24 2026
    From Newsgroup: comp.lang.misc

    Anton Antimo <anton@safunu.org> writes:
    Like try implementing Scheme continuations as macros in CL.
    Doug Hoyte does it in Let Over Lambda.

    I don't see how that is possible, other than by using the Turing
    completeness of CL macros to implement Scheme, more or less.
    Continuations automatically give you stackful coroutines and that
    requires runtime support that's not built into CL. I haven't read that
    book though.

    https://www2.ccs.neu.edu/racket/pubs/scp91-felleisen.pdf
    Care to share what you don't understand about the paper?

    It's written in the academic language of PL theory, which I haven't
    studied enough to make sense of what the paper is saying.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.lang.misc on Thu Aug 27 10:17:13 2026
    From Newsgroup: comp.lang.misc

    Anton Antimo <anton@safunu.org> wrote or quoted:
    Care to share what you don't understand about the paper? I suppose the >subject is still interesting to the newsgroups addressed here, though it >leans more towards comp.lang.misc and comp.theory and sci.logic.

    According to secondary sources, Felleisen deems two programming
    languages to be equally expressive if programs can be rewritten
    into the other language, maybe using local macros (because they
    are just "syntactic suger"). However, to me this is too vague,
    because between two Turing-complete languages, programs can al-
    ways be rewritten into the other language. But I have not read
    Felleisen; I just read articles /about/ Felleisen. So maybe Fell-
    eisen's text is less vague.

    To me it feels quite naturally to take the /amount/ of code
    into account. If I have to write 100 lines in language B for
    10 lines in language A, B seems to be less expressive to me.

    Bjarne Stroustrup wants to /express ideas directly in code/.
    Jack Reeves sees /code as design/.

    So the most expressive language would allow me to express my
    ideas directly in code, so my code would double as my design.
    The language would not distract with irrelevant details.

    Newsgroups: comp.lang.misc


    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.lang.misc on Thu Aug 27 10:47:56 2026
    From Newsgroup: comp.lang.misc

    ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
    According to secondary sources, Felleisen deems two programming
    languages to be equally expressive if programs can be rewritten
    into the other language, maybe using local macros (because they
    are just "syntactic suger").

    The following Clojure program is an example of what the
    chatbot deems to be expressive (untested):

    (fn [file-path]

    (slurp file-path) ; Read entire file into a string
    (re-seq #"\w+") ; Split text into a sequence of words
    (map clojure.string/lower-case) ; Convert all words to lowercase
    (filter #(>= (count %) 5)) ; Keep only words with 5+ characters
    (frequencies) ; Count occurrences
    (sort-by val >))) ; Sort the results by count, desc.

    This is intended to solve this problem:
    - read a text file,
    - filter out words shorter than 5 letters,
    - count the frequencies of the remaining words, and
    - sort them by their counts.

    If I understand Felleisen 1991 correctly from my secondary sources,
    a programming language where you can write that program in the same
    fashion (maybe using macros) has equal expressiveness. But when you
    have to change the structure from this linear list to something more
    complicated in your language, you have less expressiveness.

    Here's the Python version (untested):

    import re
    from collections import Counter
    from functools import reduce

    def pipe(data, *functions):
    """Passes data sequentially through a chain of functions."""
    return reduce(lambda val, func: func(val), functions, data)

    def count_words(file_path: str):
    return pipe(
    open(file_path, 'r').read(),
    lambda text: re.findall(r'\w+', text),
    lambda words: (w.lower() for w in words),
    lambda words: (w for w in words if len(w) >= 5),
    Counter,
    lambda counts: counts.most_common()
    )

    You could say that "pipe" is that macro that allows us to
    emulate Clojure, but to Felleisen it might be a "global"
    macro and, therefore, not be allowed in this context.

    C++ can do such a linear sequence, but it's much more verbose,
    distracting the programmer from the clean flow (untested):

    #include <iostream>
    #include <fstream>
    #include <string>
    #include <vector>
    #include <ranges>
    #include <algorithm>
    #include <map>

    auto count_words(const std::string& file_path) {
    std::ifstream file(file_path);
    std::map<std::string, int> word_counts;
    std::string word;

    // 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());
    };

    // 1. Stream data, sanitize, and filter by length dynamically
    auto word_stream = std::views::istream<std::string>(file)
    | std::views::transform(sanitize)
    | std::views::filter([](const std::string& w) { return w.length() >= 5; });

    for (const auto& w : word_stream) { word_counts[w]++; }

    // 2. Sort the map by value using C++23 range actions
    std::vector<std::pair<std::string, int>> sorted(word_counts.begin(), word_counts.end());
    std::ranges::sort(sorted, std::ranges::greater{}, &std::pair<std::string, int>::second);

    return sorted;
    }

    However, we need to take into account what benefits the
    verbosity brings. A lot of the verbosity of the C++ solution
    might be due to namespaces like "std::", but they might
    help to organize large programs.

    Common Lisp can implements Clojure's "->>" as a macro (untested).
    If Felleisen deems this to be a "global macro" it would not
    be allowed in this context.

    ;; 1. Define Clojure's threading macro in pure Common Lisp
    (defmacro ->> (initial-value &rest forms)
    "Threads the initial-value through the forms as the last argument of each."
    (reduce (lambda (acc form)
    (if (listp form)
    `(,(car form) ,@(cdr form) ,acc)
    `(,form ,acc)))
    forms
    :initial-value initial-value))

    ;; 2. The expressive word-count function
    (defun count-words (file-path)
    (->> (uiop:read-file-string file-path) ; Read file to string (UIOP is standard in modern CL)
    (cl-ppcre:split "[^a-zA-Z0-9]+") ; Split into words using regex
    (remove-if (lambda (w) (string= w ""))) ; Filter out empty strings from split
    (mapcar #'string-downcase) ; Normalize to lowercase
    (remove-if (lambda (w) (< (length w) 5))) ; Keep only words with 5+ characters
    (reduce (lambda (hash word) ; Count frequencies into a hash table
    (incf (gethash word hash 0))
    hash)
    _ :initial-value (make-hash-table :test 'equal))
    (alexandria:hash-table-alist) ; Convert to an association list (word . count)
    (sort _ #'> :key #'cdr))) ; Sort descending by the count




    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Anton Antimo@anton@safunu.org to comp.lang.lisp,comp.lang.misc,comp.lang.c on Fri Aug 28 17:29:26 2026
    From Newsgroup: comp.lang.misc

    Paul Rubin <no.email@nospam.invalid> writes:

    Anton Antimo <anton@safunu.org> writes:
    Like try implementing Scheme continuations as macros in CL.
    Doug Hoyte does it in Let Over Lambda.

    I don't see how that is possible, other than by using the Turing
    completeness of CL macros to implement Scheme, more or less.
    Continuations automatically give you stackful coroutines and that
    requires runtime support that's not built into CL. I haven't read that
    book though.

    I got that wrong. It turns out TFB posted in

    Message-ID: <116ndfj$st1q$1@dont-email.me>

    two days ago that Paul Graham does in ``On Lisp''.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Johann \@johann@myrkraverk.invalid to comp.lang.misc,comp.lang.c++ on Fri Sep 18 10:49:09 2026
    From Newsgroup: comp.lang.misc

    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.misc

    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.misc

    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.misc

    "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.misc

    "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.misc

    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.misc

    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.misc

    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 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.misc

    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 on Fri Sep 18 15:18:02 2026
    From Newsgroup: comp.lang.misc

    ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
    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".

    For one example, I wrote a program in 2020 to count the fre-
    quencies of Japanese "words", where I had my program figure
    out which characters go together by itself using something
    that vaguely resembles byte-pair encoding (BPE), but I came
    up with it myself before I ever heard of BPE.

    Japanese words are usually not separated by spaces. So, my
    program just observes which combinations of characters appear
    most frequently in my collection of Japanese texts, but also
    can deal with words that appear both separated from other words
    and also as parts of other words. For example, below both "pUepUe"
    and "pUe" are listed, and the 2*32232 occurences of "pUe" in "pUepUe"
    are not counted again to get the 22929 occurences of "pUe".

    These are "words" by the definition of my program - which might
    not agree with other definitions.

    So, now you know which "words" you should learn first because
    they are most common - from the output of my program (start):

    It says, "Hai" ("yes") is the most common Japanese word! Readers
    might be surprised by "pUepUe" - this appears often in the spoken
    language I was interested in, but rarely in formal texts.

    And we see that the few kanji I know ("E+o", "toU", and "E+e") are
    indeed very common! Again the 15591 hits of "E+o" in isolation
    are counted only when its not part of the "E+opUi", "E+opUo", and
    "E+opUa", which are listed and counted separately. And this also
    applies to longer sequences correspondingly.

    "pU>pUa" |u67739 rao2 rCo HA I
    "pUepUu" |u51279 rao2 rCo A SMALL-TU
    "pUapeo" |u38420 rao2 rCo U N
    "pUepUu" |u37268 rao2 rCo E SMALL-TU
    "pUapea" |u32336 rao2 rCo I YA
    "pUepUe" |u32232 rao2 rCo A A
    "pUopee" |u29729 rao2 rCo DE MO
    "peepUa" |u23096 rao2 rCo MO U
    "pUe" |u22929 rao1 rCo A
    "pUypeapUe" |u20123 rao3 rCo ZI SMALL-YA A
    "pUipecpUupU?" |u19575 rao4 rCo TI SMALL-YO SMALL-TU TO
    "pUepU<" |u18596 rao2 rCo A NO
    "pUe" |u16755 rao1 rCo E
    "peo" |u16391 rao1 rCo N
    "pUopei" |u16078 rao2 rCo KO RE
    "E+o" |u15591 rao1 rCo X-4F55
    "toU" |u14642 rao1 rCo X-79C1
    "pUapUipee" |u14125 rao3 rCo DA KA RA
    "pUepUa" |u13855 rao2 rCo O I
    "pU+pUe" |u13307 rao2 rCo MA A
    "E+e" |u12493 rao1 rCo X-4ECA
    "pUOpUapU+pUcpeo" |u11940 rao5 rCo SU I MA SE N
    "toUpU>" |u11247 rao2 rCo X-79C1 HA
    "pUepUe" |u11237 rao2 rCo E E
    "E+opUi" |u10606 rao2 rCo X-4F55 KA
    "pUeoei" |u10569 rao2 rCo O X-524D
    "pUYpeipU>" |u10475 rao3 rCo SO RE HA
    "pUepeepUipU?pUa" |u10469 rao5 rCo A RI GA TO U
    "pUYpUa" |u9965 rao2 rCo SO U
    "pU!pUe" |u9752 rao2 rCo NE E
    "pUepei" |u9180 rao2 rCo A RE
    "pU-pUapUR" |u8971 rao3 rCo DO U ZO
    "pU+pee" |u8948 rao2 rCo HO RA
    "E+opUo" |u8822 rao2 rCo X-4F55 DE
    "pUepeepUipU?pUapUopUupUapU+pUO" |u8571 rao10 rCo A RI GA TO U GO ZA I MA SU
    "pUepUU" |u8396 rao2 rCo A SMALL-A
    "pUeoiypUapUupU+pUO" |u7552 rao6 rCo O X-9858 I SI MA SU
    "E+|" |u7515 rao1 rCo X-4FFA
    "pU+pUf" |u7467 rao2 rCo MA TA
    "pUo" |u7283 rao1 rCo DE
    "peepUu" |u7214 rao2 rCo YO SI
    "pUopeipU>" |u7143 rao3 rCo KO RE HA
    "pUapUe" |u7052 rao2 rCo I E
    "pU>pUU" |u7008 rao2 rCo HA SMALL-A
    "pU-pUapUupUa" |u6943 rao4 rCo DO U SI TE
    "pU+pUa" |u6851 rao2 rCo MA DA
    "onoE+eon2" |u6838 rao3 rCo X-5927 X-4E08 X-592B
    "pUYpei" |u6710 rao2 rCo SO RE
    "E+|pU>" |u6630 rao2 rCo X-4FFA HA
    "pUupUa" |u6593 rao2 rCo SMALL-TU TE
    "E+CoEi" |u6477 rao2 rCo X-4E00 X-540C
    "pUapUupUa" |u6413 rao3 rCo DA SMALL-TU TE
    "pUopeUpeo" |u6407 rao3 rCo GO ME N
    "peapUupU#pee" |u6314 rao4 rCo YA SMALL-TU PA RI
    "pU+peopU-" |u6033 rao3 rCo MI N NA
    "oaetof" |u5932 rao2 rCo X-5148 X-751F
    "pUepaa" |u5932 rao2 rCo E SMALL-TU
    "pUupUipUu" |u5825 rao3 rCo SI KA SI
    "pUa" |u5813 rao1 rCo I
    "pUYpeipUo" |u5798 rao3 rCo SO RE DE
    "pUYpUupUa" |u5790 rao3 rCo SO SI TE
    "pUa" |u5629 rao1 rCo U
    "pU>pUe" |u5624 rao2 rCo HA A
    "pU-pUapee" |u5535 rao3 rCo DO U MO
    "pU>" |u5511 rao1 rCo HA
    "pUopU>" |u5275 rao2 rCo DE HA
    "pUepaa" |u5256 rao2 rCo A SMALL-TU
    "pUopUe" |u5123 rao2 rCo SA A
    "pUopeUpeopU-pUopUa" |u4997 rao6 rCo GO ME N NA SA I
    "E+euuNpU>" |u4907 rao3 rCo X-4ECA X-65E5 HA
    "pUYpeopU-" |u4819 rao3 rCo SO N NA
    "pU>pUu" |u4805 rao2 rCo HA SMALL-TU
    "pUYpeipUi" |u4802 rao3 rCo SO RE GA
    "pUOpU+pU+pUcpeo" |u4755 rao5 rCo SU MI MA SE N
    "pU+pUopUi" |u4616 rao3 rCo MA SA KA
    "on#tn+pUupU+pUO" |u4494 rao5 rCo X-5931 X-793C SI MA SU
    "pUYpUapUi" |u4428 rao3 rCo SO U KA
    "E+opUa" |u4237 rao2 rCo X-4F55 DA
    . . .

    Newsgroups: comp.lang.misc


    --- 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.misc

    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.misc

    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.misc

    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.misc

    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.misc

    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.misc

    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.misc

    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.misc

    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
  • From ram@ram@zedat.fu-berlin.de (Stefan Ram) to comp.lang.lisp,comp.lang.misc,comp.lang.c on Mon Nov 16 13:55:48 2026
    From Newsgroup: comp.lang.misc

    Anton Antimo <anton@safunu.org> wrote or quoted:
    Paul Rubin <no.email@nospam.invalid> writes:
    Meh, if the old language can express the new idea at all, then the new
    idea isn't that big of a change. Like try implementing Scheme >>continuations as macros in CL.
    Doug Hoyte does it in Let Over Lambda. But even if we have here a case
    where things don't work out so well, one case won't break the efficacy
    of all other cases.

    "Let Over Lambda" has now been made available for free in HTML
    and PDF by it's author if I understood a web page correctly.

    Newsgroups: comp.lang.lisp,comp.lang.misc,comp.lang.c
    Followup-To: comp.lang.lisp


    --- Synchronet 3.22a-Linux NewsLink 1.2