• What does (gensym) generate?

    From none) (albert@21:1/5 to All on Thu Aug 31 10:57:35 2023
    The explanations about the usage of gensym are clear,
    how your are supposed to used them.
    The theoretical background however is far from it.

    (let* (aaa (gensym)) .. aaa .. )

    In the context `` .. aaa .. '' `aaa is obviously a symbol.
    The interesting question is what value is aaa coupled to due to
    the environment (aaa (gensym))?
    Apparently aaa must be evaluated before it is any use.
    However subsequently you see
    (let* (aaa (rest whatever)) ... )
    What is disturbing to me is that let* only allows symbols into the
    position of aaa and normally the coupling of aaa hides previous usage.
    I have the following lisp objects:
    symbols lists numbers strings arrays hashes normal-function
    special-functions booleans
    and more MAL oddballs:
    nil key atom

    Nothing seems an appropriate type for `aaa.

    Example studied:

    (defmacro! or
    (fn* (& xs)
    (if (empty? xs)
    nil
    (if (= 1 (count xs))
    (first xs)
    (let* (condvar (gensym))
    `(let* (~condvar ~(first xs))
    (if ~condvar ~condvar (or ~@(rest xs)))))))))

    Groetjes Albert
    --
    Don't praise the day before the evening. One swallow doesn't make spring.
    You must not say "hey" before you have crossed the bridge. Don't sell the
    hide of the bear until you shot it. Better one bird in the hand than ten in
    the air. First gain is a cat spinning. - the Wise from Antrim -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John@21:1/5 to All on Thu Aug 31 12:19:36 2023
    On Thu, 31 Aug 2023 10:57:35 +0200, none) (albert wrote:

    The explanations about the usage of gensym are clear,
    how your are supposed to used them.
    The theoretical background however is far from it.

    (let* (aaa (gensym)) .. aaa .. )

    Within a lisp macro gensym generates a randomly generated symbol to
    prevent name clashes

    John

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)