Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Ada is PL/I trying to be Smalltalk. -- Codoso diBlini


devel / comp.lang.lisp / What does (gensym) generate?

SubjectAuthor
* What does (gensym) generate?none
+* Re: What does (gensym) generate?Tom Russ
|`* Re: What does (gensym) generate?Spiros Bousbouras
| `- Re: What does (gensym) generate?Kaz Kylheku
+* Re: What does (gensym) generate?Kaz Kylheku
|`* Re: What does (gensym) generate?none
| `* Re: What does (gensym) generate?Spiros Bousbouras
|  `* Re: What does (gensym) generate?none
|   +- Re: What does (gensym) generate?Kaz Kylheku
|   `- Re: What does (gensym) generate?Tom Russ
`- Re: What does (gensym) generate?steve

1
What does (gensym) generate?

<nnd$40329216$4a966390@764d4750d92df32c>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17470&group=comp.lang.lisp#17470

  copy link   Newsgroups: comp.lang.lisp
Newsgroups: comp.lang.lisp
Subject: What does (gensym) generate?
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: albert@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$40329216$4a966390@764d4750d92df32c>
Organization: KPN B.V.
Date: Thu, 31 Aug 2023 11:11:14 +0200
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe005.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 46
Injection-Date: Thu, 31 Aug 2023 11:11:14 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 2347
 by: none - Thu, 31 Aug 2023 09:11 UTC

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 type of 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 -
--
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 -

Re: What does (gensym) generate?

<75e51292-e706-4e7e-8aa2-8c8327c71f4fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17472&group=comp.lang.lisp#17472

  copy link   Newsgroups: comp.lang.lisp
X-Received: by 2002:a05:622a:10f:b0:403:b6c8:4c28 with SMTP id u15-20020a05622a010f00b00403b6c84c28mr6310qtw.8.1693505938487;
Thu, 31 Aug 2023 11:18:58 -0700 (PDT)
X-Received: by 2002:a17:90a:fc8a:b0:26b:6df8:eb70 with SMTP id
ci10-20020a17090afc8a00b0026b6df8eb70mr27669pjb.1.1693505937612; Thu, 31 Aug
2023 11:18:57 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.lisp
Date: Thu, 31 Aug 2023 11:18:56 -0700 (PDT)
In-Reply-To: <nnd$40329216$4a966390@764d4750d92df32c>
Injection-Info: google-groups.googlegroups.com; posting-host=2603:8000:7603:1703:d842:acdc:969a:2571;
posting-account=05zmAwoAAAAJZM-3jv1hCWLHGZQceqwA
NNTP-Posting-Host: 2603:8000:7603:1703:d842:acdc:969a:2571
References: <nnd$40329216$4a966390@764d4750d92df32c>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <75e51292-e706-4e7e-8aa2-8c8327c71f4fn@googlegroups.com>
Subject: Re: What does (gensym) generate?
From: taruss@google.com (Tom Russ)
Injection-Date: Thu, 31 Aug 2023 18:18:58 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4607
 by: Tom Russ - Thu, 31 Aug 2023 18:18 UTC

On Thursday, August 31, 2023 at 2:11:21 AM UTC-7, 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.

The theoretical background is essentially this:
* For regular symbols, when the reader encounters a symbol, it creates a
symbol object and "interns" it. Interning means creating a mapping from
the symbol name to the symbol object.
* GENSYM will generate an "uninterned" symbol. It creates and returns a
symbol object, but does *not* create a mapping from the (generated)
name to the symbol object. That means that even if you type in the same
as gets internally chosen for this uninterned symbol, it will not be the
same object.

This is useful if you want a symbol for some purpose, in modern lisp usually
only for creating bindings inside macros, but don't want that symbol to have
any possibility of interfering with any other symbols, you can use one of these
generated symbols.

For some discussion of this, see https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node114.html#SECTION001530000000000000000

>
> (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 type of 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)))))))))

One of the general uses of GENSYM is in macros. By introducing a new, uninterned symbol one
does not have to worry that the new symbol can inadvertently capture (rebind) an external symbol
when the macro is expanded.

These are a bit silly, since there isn't
(defmacro bad-example (value &body body)
`(let ((x ,value))
(print x)
,@body))
(defmacro good-example (value &body body)
(let ((v (gensym)))
`(let ((,v ,value))
(print ,v)
,@body))))

Now consider these two cases:
(let ((x 5))
(bad-example 20 (print x)))
(let ((x 5))
(good-example 20 (print x)))
The bad example will print 20 20 and the good one will properly print 20 5.

That is because if you expand the macros you would end up with:
(let ((x 5))
(let ((x 20))
(print x)
(print x)))
vs
(let ((x 5))
(let ((#1=#:GENSYM100 20)) ; The actual printed value may differ and isn't important.
(print #1#)
(print x)))
This version uses the printer's alias ability to make sure that the same symbol is used
in the LET and the PRINT, since there is no mapping from name to symbol object when
the symbol is not interned.

Re: What does (gensym) generate?

<20230831104914.534@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17473&group=comp.lang.lisp#17473

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: What does (gensym) generate?
Date: Thu, 31 Aug 2023 18:21:24 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 83
Message-ID: <20230831104914.534@kylheku.com>
References: <nnd$40329216$4a966390@764d4750d92df32c>
Injection-Date: Thu, 31 Aug 2023 18:21:24 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="70d02f2c57901333f8c8fdfdb470c4f7";
logging-data="3578030"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18BMEzZHLJcF3A+JTj4ne54T7AvdXNlQYg="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:pRIlWxA3IFLqjp9gBVZK63l1i5g=
 by: Kaz Kylheku - Thu, 31 Aug 2023 18:21 UTC

On 2023-08-31, albert@cherry.(none) (albert) <albert@cherry> 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 .. )
>
> 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))?

gensym is an ordinary function which returns an object.
That object is a symbol.

If we replace it with (aaa (list 1 2 3)), then aaa is bound
to list of three elements.

The object returned by gensym is always a newly created symbol,
different from any other symbol in the system that has hitherto existed.

In Common Lisp, gensym returns an uninterned symbol: a symbol which
is not registered in a package. (There are some subtle details to it,
but let that suffice.) Common Lisp prints such symbols with a #:
(hash colon) prefix. E.g. (gensym "ABC-") -> #:ABC-0013 .
The Common Lisp gensym maintains an incrementing counter which it uses
to generate new names, but those names are just for human readability,
not the basis for the uniquenes..

Each time the reader encounters the #: syntax, it creates a new,
uninterned symbol so that (eq '#:abc '#:abc) will be false.
Those are two different symbols, which have the same name.

For interned symbols, that is impossible: only one symbol can
exist in a package under a given name: there can at most be one cl:list
or abc:foo or whatever.

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

It's a variable binding construct, so it only allows variable names,
which are symbols.

> I have the following lisp type of 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.

The obect aaa itself is a symbol. The token aaa appears in your code.
The Lisp reader scans that token, recognizes it as having the
shape of a symbol, and so it interns it: it produces either the
existing symbol that exists under that name, or else produces a new
one and registers it under that name. (If it didn't register it,
the symbol would be uninterned, like the ones from gensym.)

I'm guessing that since you've gone this far in MAL, you must
have that working.

> (let* (condvar (gensym))
> `(let* (~condvar ~(first xs))
> (if ~condvar ~condvar (or ~@(rest xs)))))))))

So here condvar is a generated, unique symbol.

It is interpolated into the backquote template.

~convar says, insert the value of condvar here. The value is
a symbol, which is what we want there.

The macro is generating code in which there is a local variable boudd
using let*, and that variable's name is machine generated.

This the same as what you see in any compiler: machine generated
temporaries, jump labels and so on.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: What does (gensym) generate?

<hwL2ZQGx9qWcVmVLY@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17474&group=comp.lang.lisp#17474

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: What does (gensym) generate?
Date: Thu, 31 Aug 2023 18:57:40 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <hwL2ZQGx9qWcVmVLY@bongo-ra.co>
References: <nnd$40329216$4a966390@764d4750d92df32c> <75e51292-e706-4e7e-8aa2-8c8327c71f4fn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 31 Aug 2023 18:57:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="953f931c38f7411195d543c971be568c";
logging-data="3587822"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19brgMafyWkex8SPlvDzq19"
Cancel-Lock: sha1:EqCF//GEbbtVM79pjpK9X23FK20=
X-Organisation: Weyland-Yutani
In-Reply-To: <75e51292-e706-4e7e-8aa2-8c8327c71f4fn@googlegroups.com>
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Thu, 31 Aug 2023 18:57 UTC

On Thu, 31 Aug 2023 11:18:56 -0700 (PDT)
Tom Russ <taruss@google.com> wrote:
> On Thursday, August 31, 2023 at 2:11:21 AM UTC-7, 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.
>
> The theoretical background is essentially this:
> * For regular symbols, when the reader encounters a symbol, it creates a
> symbol object and "interns" it. Interning means creating a mapping from
> the symbol name to the symbol object.

No , interning means creating an association between a symbol and a package.
Different packages can have symbols with the same name. Other relevant facts
{for Common Lisp} :

A name is a string and each symbol has a name and it can even be the empty
string.

Each package can have at most 1 symbol with a given name.

You can have an unlimited number of uninterned symbols with a given name.

> * GENSYM will generate an "uninterned" symbol. It creates and returns a
> symbol object, but does *not* create a mapping from the (generated)
> name to the symbol object. That means that even if you type in the same
> as gets internally chosen for this uninterned symbol, it will not be the
> same object.

Re: What does (gensym) generate?

<20230831120530.843@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17476&group=comp.lang.lisp#17476

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: What does (gensym) generate?
Date: Thu, 31 Aug 2023 19:07:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 16
Message-ID: <20230831120530.843@kylheku.com>
References: <nnd$40329216$4a966390@764d4750d92df32c>
<75e51292-e706-4e7e-8aa2-8c8327c71f4fn@googlegroups.com>
<hwL2ZQGx9qWcVmVLY@bongo-ra.co>
Injection-Date: Thu, 31 Aug 2023 19:07:06 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="70d02f2c57901333f8c8fdfdb470c4f7";
logging-data="3590096"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX197fIjF1yFtaiqaQ4s9HV2Dd4UaQQHvb5I="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:v8d1IIShHTMT3Ks+rweH4b8EtEE=
 by: Kaz Kylheku - Thu, 31 Aug 2023 19:07 UTC

On 2023-08-31, Spiros Bousbouras <spibou@gmail.com> wrote:
> No , interning means creating an association between a symbol and a package.
> Different packages can have symbols with the same name. Other relevant facts
> {for Common Lisp} :

Plus, in a simple Lisp with no package system, interning just means
recording the symbol in some pervasive dictionary of symbols (that is
essentially the one and only package).

The CL-like package systems refines the concept by dividing the
previously global dictionary into named namespaces.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: What does (gensym) generate?

<nnd$616b9609$1776a5b1@5e4c41ff528acb91>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17477&group=comp.lang.lisp#17477

  copy link   Newsgroups: comp.lang.lisp
Newsgroups: comp.lang.lisp
References: <nnd$40329216$4a966390@764d4750d92df32c> <20230831104914.534@kylheku.com>
Subject: Re: What does (gensym) generate?
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: albert@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$616b9609$1776a5b1@5e4c41ff528acb91>
Organization: KPN B.V.
Date: Fri, 01 Sep 2023 14:23:21 +0200
Path: i2pn2.org!i2pn.org!nntp.comgw.net!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe005.abavia.com!abp001.abavia.com!news.kpn.nl!not-for-mail
Lines: 143
Injection-Date: Fri, 01 Sep 2023 14:23:21 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 6311
 by: none - Fri, 1 Sep 2023 12:23 UTC

In article <20230831104914.534@kylheku.com>,
Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>On 2023-08-31, albert@cherry.(none) (albert) <albert@cherry> 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 .. )
>>
>> 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))?
>
>gensym is an ordinary function which returns an object.
>That object is a symbol.
>
>If we replace it with (aaa (list 1 2 3)), then aaa is bound
>to list of three elements.
>
>The object returned by gensym is always a newly created symbol,
>different from any other symbol in the system that has hitherto existed.
>
>In Common Lisp, gensym returns an uninterned symbol: a symbol which
>is not registered in a package. (There are some subtle details to it,
>but let that suffice.) Common Lisp prints such symbols with a #:
>(hash colon) prefix. E.g. (gensym "ABC-") -> #:ABC-0013 .
>The Common Lisp gensym maintains an incrementing counter which it uses
>to generate new names, but those names are just for human readability,
>not the basis for the uniquenes..
>
>Each time the reader encounters the #: syntax, it creates a new,
>uninterned symbol so that (eq '#:abc '#:abc) will be false.
>Those are two different symbols, which have the same name.
>
>For interned symbols, that is impossible: only one symbol can
>exist in a package under a given name: there can at most be one cl:list
>or abc:foo or whatever.

That is all trivial to implement.

>
>> 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.
>
>It's a variable binding construct, so it only allows variable names,
>which are symbols.
Huh?

>
>> I have the following lisp type of 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.
>
>The obect aaa itself is a symbol. The token aaa appears in your code.
>The Lisp reader scans that token, recognizes it as having the
>shape of a symbol, and so it interns it: it produces either the
>existing symbol that exists under that name, or else produces a new
>one and registers it under that name. (If it didn't register it,
>the symbol would be uninterned, like the ones from gensym.)
>
>I'm guessing that since you've gone this far in MAL, you must
>have that working.

Right you are

>
>> (let* (condvar (gensym))
>> `(let* (~condvar ~(first xs))
>> (if ~condvar ~condvar (or ~@(rest xs)))))))))
>
>So here condvar is a generated, unique symbol.
>
>It is interpolated into the backquote template.
>
>~convar says, insert the value of condvar here. The value is
>a symbol, which is what we want there.

Can we conclude that the only time to worry is inside
quasiquote? That helps a lot. There is a moment in time
where we expand, and the

>
>The macro is generating code in which there is a local variable boudd
>using let*, and that variable's name is machine generated.
>
>This the same as what you see in any compiler: machine generated
>temporaries, jump labels and so on.

The big question how to parse
(let (aaa <object> ) ...
In the abstract structure tree `let and `aaa are symbols
that are manipulated during evaluation.
The spec's of let is that aaa is a symbol that is bound to object.
This cannot be the whole story. For instance there is no notice
to evaluate aaa , the previous binding is lost.
That are the spec's of `let , or so I thought.
Comes gensym . If I previously encountered `` (aaa (gensym)) ''
everything changes. But how can I even know that the previous
binding was this weird contraption?

I have 256 Gbyte RAM and MAL is a toy implementation, so bear with me:
each object has 7 64 bit fields.
All objects are uniform and have a tag giving its type:
pointer to code, pointer to data, a flag field (containing tags),
a link field, a name field, a source field (not used) and
one spare.

It is related to the following implementation choice I made.
All objects have a place to set a name.
All object have some data and possibly no name (e.g. numbers, lists
functions, strings)
Symbols have a name and all other fields are free.
Binding a symbol : fill the name of the symbol in the object
and possibly link it into an environment (linkfield is the hook for that).
Sometime we have to clone the whole object, if it previously had a name
and were linked to some environment.
For example an anonymous lambda looks like this:
code pointer : forth interpreter
data pointer : forth code to be interpreted
flag : contains either #func or #special or-ed with possibly Forty flags.
link , name : empty.

The contradiction caused by (gensym) is that you have symbols with
two names, where the only property of a symbol is that it has
a name that identifies itself. Or so I thought.

>
>--
>TXR Programming Language: http://nongnu.org/txr

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 -

Re: What does (gensym) generate?

<8GRTwaqPt+TSAYagO@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17480&group=comp.lang.lisp#17480

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!paganini.bofh.team!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: What does (gensym) generate?
Date: Fri, 1 Sep 2023 14:27:19 -0000 (UTC)
Organization: To protect and to server
Message-ID: <8GRTwaqPt+TSAYagO@bongo-ra.co>
References: <nnd$40329216$4a966390@764d4750d92df32c> <20230831104914.534@kylheku.com> <nnd$616b9609$1776a5b1@5e4c41ff528acb91>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 1 Sep 2023 14:27:19 -0000 (UTC)
Injection-Info: paganini.bofh.team; logging-data="9020"; posting-host="9H7U5kayiTdk7VIdYU44Rw.user.paganini.bofh.team"; mail-complaints-to="usenet@bofh.team"; posting-account="9dIQLXBM7WM9KzA+yjdR4A";
Cancel-Lock: sha256:QQsvOwzbw2bAJN1bkJBjFuzyT8ZzDkIycZylJR0m4L4=
X-Notice: Filtered by postfilter v. 0.9.3
X-Server-Commands: nowebcancel
X-Organisation: Weyland-Yutani
 by: Spiros Bousbouras - Fri, 1 Sep 2023 14:27 UTC

On Fri, 01 Sep 2023 14:23:21 +0200
albert@cherry.(none) (albert) wrote:
> In article <20230831104914.534@kylheku.com>,
> Kaz Kylheku <864-117-4973@kylheku.com> wrote:
> >On 2023-08-31, albert@cherry.(none) (albert) <albert@cherry> wrote:

[...]

> >> 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.
> >
> >It's a variable binding construct, so it only allows variable names,
> >which are symbols.
> Huh?

let binds variables ; so in something like

(let ((<something> value) ...))

the <something> has to be a variable name which means a Lisp object of
type symbol.

[...]

> >> (let* (condvar (gensym))
> >> `(let* (~condvar ~(first xs))
> >> (if ~condvar ~condvar (or ~@(rest xs)))))))))
> >
> >So here condvar is a generated, unique symbol.
> >
> >It is interpolated into the backquote template.
> >
> >~convar says, insert the value of condvar here. The value is
> >a symbol, which is what we want there.
>
> Can we conclude that the only time to worry is inside
> quasiquote? That helps a lot. There is a moment in time
> where we expand, and the

There is no special worry involved but more on this below.

> >The macro is generating code in which there is a local variable boudd
> >using let*, and that variable's name is machine generated.
> >
> >This the same as what you see in any compiler: machine generated
> >temporaries, jump labels and so on.
>
> The big question how to parse
> (let (aaa <object> ) ...
> In the abstract structure tree `let and `aaa are symbols
> that are manipulated during evaluation.
> The spec's of let is that aaa is a symbol that is bound to object.
> This cannot be the whole story. For instance there is no notice
> to evaluate aaa , the previous binding is lost.
> That are the spec's of `let , or so I thought.
> Comes gensym . If I previously encountered `` (aaa (gensym)) ''
> everything changes. But how can I even know that the previous
> binding was this weird contraption?

(let ((aaa (foo)))) binds aaa to whatever (foo) returns. As
far as this goes there is nothing special with something like
(let ((aaa (gensym)))) . aaa gets bound to whatever (gensym)
returned much like (let ((aaa (+ 1 1)))) binds aaa to whatever
(+ 1 1) returns which is 2.

(gensym) returns a symbol with the special property that it is
uninterned. So the only reference to the symbol returned is through
aaa .There is nothing you can type on the REPL to get the same
symbol {although you can get a symbol with the same name} and every
other call to gensym will also return a different symbol.

> I have 256 Gbyte RAM and MAL is a toy implementation, so bear with me:
> each object has 7 64 bit fields.
> All objects are uniform and have a tag giving its type:
> pointer to code, pointer to data, a flag field (containing tags),
> a link field, a name field, a source field (not used) and
> one spare.

I don't think such low level details are helpful but anyway.

> It is related to the following implementation choice I made.
> All objects have a place to set a name.

The first problem here is that you are using what is standard Lisp
terminology , or at least Common Lisp terminology , for something
which seems to be different. In Common Lisp a symbol has a name
which is a string. So the name of the symbol aaa is the string
"aaa" .But a symbol is a different thing than its name ; it's a
different datatype and a different object.

> All object have some data and possibly no name (e.g. numbers, lists
> functions, strings)
> Symbols have a name and all other fields are free.
> Binding a symbol : fill the name of the symbol in the object
> and possibly link it into an environment (linkfield is the hook for that).
> Sometime we have to clone the whole object, if it previously had a name
> and were linked to some environment.
> For example an anonymous lambda looks like this:
> code pointer : forth interpreter
> data pointer : forth code to be interpreted
> flag : contains either #func or #special or-ed with possibly Forty flags.
> link , name : empty.

So if you have something like (let ((aaa 19))) what value are the
various things you mention going to have ?

> The contradiction caused by (gensym) is that you have symbols with
> two names, where the only property of a symbol is that it has
> a name that identifies itself. Or so I thought.

What identifies a symbol is its location in memory. You don't have
direct access to that location {i.e. you can't get the address} but
in that location there will be stored {in an appropriate layout known
to the Lisp implementation} the various properties of the symbol
which include the following :

A symbol has a name {meaning a string , as I explained above} and
whether it is bound to a value and whether it is interned or not. For
simplicity lets assume that "interned" is a binary property although
in Common Lisp it isn't , if a symbol is interned then it is interned
in some package. With something like

(let ((aaa (gensym))))

the symbol aaa has the following properties :

- it has the name "aaa" which is a string.

- it is interned because you typed it into the REPL or read it from source
code in some file.

- it is bound to the value returned by (gensym) .By the definition of
gensym this value will have the following properties :

- it will be a symbol therefore it will also have a name which will also
be a string. In Common Lisp you can even control what that string will be
and you can even make it to be "aaa" .But even if you make the name
to be "aaa" , the symbol returned by (gensym) will be distinct
from aaa which you typed on the REPL ; "distinct" meaning it will be
stored at a different place in memory and its various properties
can be different than the properties of aaa and that includes whether
it is bound to a value and which value.

- it will be uninterned.

These facts are unrelated to quasiquoting although often are used in combination
with quasiquoting. But note that your code

(let* (condvar (gensym))
`(let* (~condvar ~(first xs))
(if ~condvar ~condvar (or ~@(rest xs)))))))))

could be written as

(defun or-function (list-of-clauses)
(if list-of-clauses
(let* ((condvar (gensym)))
(list 'let* (list (list condvar (first list-of-clauses)))
(list 'if condvar condvar
(or-function (rest list-of-clauses)))))
nil))

..Obviously this is a lot less readable but I hope it illustrates the
point that gensym is not based on quasiquoting nor the other way
around.

--
vlaho.ninja/prog

Re: What does (gensym) generate?

<nnd$548571c9$5c8aed95@a9ee2931c2de023e>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17484&group=comp.lang.lisp#17484

  copy link   Newsgroups: comp.lang.lisp
Newsgroups: comp.lang.lisp
References: <nnd$40329216$4a966390@764d4750d92df32c> <20230831104914.534@kylheku.com> <nnd$616b9609$1776a5b1@5e4c41ff528acb91> <8GRTwaqPt+TSAYagO@bongo-ra.co>
Subject: Re: What does (gensym) generate?
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
From: albert@cherry (none)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$548571c9$5c8aed95@a9ee2931c2de023e>
Organization: KPN B.V.
Date: Mon, 04 Sep 2023 13:08:07 +0200
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feed.abavia.com!abe005.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 156
Injection-Date: Mon, 04 Sep 2023 13:08:07 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
X-Received-Bytes: 7609
 by: none - Mon, 4 Sep 2023 11:08 UTC

In article <8GRTwaqPt+TSAYagO@bongo-ra.co>,
Spiros Bousbouras <spibou@gmail.com> wrote:
>On Fri, 01 Sep 2023 14:23:21 +0200
>albert@cherry.(none) (albert) wrote:
>> In article <20230831104914.534@kylheku.com>,
>> Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>> >On 2023-08-31, albert@cherry.(none) (albert) <albert@cherry> wrote:
>
>[...]
>
>
>(let ((aaa (foo)))) binds aaa to whatever (foo) returns. As
>far as this goes there is nothing special with something like
>(let ((aaa (gensym)))) . aaa gets bound to whatever (gensym)
>returned much like (let ((aaa (+ 1 1)))) binds aaa to whatever
>(+ 1 1) returns which is 2.
>
>(gensym) returns a symbol with the special property that it is
>uninterned. So the only reference to the symbol returned is through
>aaa .There is nothing you can type on the REPL to get the same
>symbol {although you can get a symbol with the same name} and every
>other call to gensym will also return a different symbol.

Remember that my big question was,what is the type of the value
`aaa is bound to. So apparently that is a symbol that has
uninterned.
Can you please elaborate what uninterned means?

>
>> I have 256 Gbyte RAM and MAL is a toy implementation, so bear with me:
>> each object has 7 64 bit fields.
>> All objects are uniform and have a tag giving its type:
>> pointer to code, pointer to data, a flag field (containing tags),
>> a link field, a name field, a source field (not used) and
>> one spare.
>
>I don't think such low level details are helpful but anyway.
>
>> It is related to the following implementation choice I made.
>> All objects have a place to set a name.
>
>The first problem here is that you are using what is standard Lisp
>terminology , or at least Common Lisp terminology , for something
>which seems to be different. In Common Lisp a symbol has a name
>which is a string. So the name of the symbol aaa is the string
>"aaa" .But a symbol is a different thing than its name ; it's a
>different datatype and a different object.

I should have said, a field that associated it with a symbol.

It is clear that you can have a symbol that is floating around
and has not been placed in abstract structure tree or a
hash table. Is that uninterned?

>
>> All object have some data and possibly no name (e.g. numbers, lists
>> functions, strings)
>> Symbols have a name and all other fields are free.
>> Binding a symbol : fill the name of the symbol in the object
>> and possibly link it into an environment (linkfield is the hook for that).
>> Sometime we have to clone the whole object, if it previously had a name
>> and were linked to some environment.
>> For example an anonymous lambda looks like this:
>> code pointer : forth interpreter
>> data pointer : forth code to be interpreted
>> flag : contains either #func or #special or-ed with possibly Forty flags.
>> link , name : empty.
>
>So if you have something like (let ((aaa 19))) what value are the
>various things you mention going to have ?
let : symbol
aaa : symbol
19 : number
(let...) list (( aaa 19)) a list with one object that is again a list.

Let us discuss what I understand `let does.
In MAL the function coupled to let is a special function and it looks
like (let* (aaa 19) ...
In my book, the arguments are not evaluated (that what special means, not?)
and `let is allowed to evaluate it, on its own terms.
In my interpretation:
`let inspects the first argument, requires this to be a list,
an requires that all odd elements be symbols, lest it is allowed
to call "fire!".

>
>> The contradiction caused by (gensym) is that you have symbols with
>> two names, where the only property of a symbol is that it has
>> a name that identifies itself. Or so I thought.
>
>What identifies a symbol is its location in memory. You don't have
>direct access to that location {i.e. you can't get the address} but
>in that location there will be stored {in an appropriate layout known
>to the Lisp implementation} the various properties of the symbol
>which include the following :
Okay that is what I do.
(let (aaa 19)
The symbol aaa is a location in memory. I borrow its name and
fetch 19 and put it in a hash list.
>
>A symbol has a name {meaning a string , as I explained above} and
>whether it is bound to a value and whether it is interned or not. For
>simplicity lets assume that "interned" is a binary property although
>in Common Lisp it isn't , if a symbol is interned then it is interned
>in some package. With something like
>
> (let ((aaa (gensym))))
>
>the symbol aaa has the following properties :
>
>- it has the name "aaa" which is a string.
>
>- it is interned because you typed it into the REPL or read it from source
> code in some file.
>
>- it is bound to the value returned by (gensym) .By the definition of
> gensym this value will have the following properties :
>
> - it will be a symbol therefore it will also have a name which will also
> be a string. In Common Lisp you can even control what that string will be
> and you can even make it to be "aaa" .But even if you make the name
> to be "aaa" , the symbol returned by (gensym) will be distinct
> from aaa which you typed on the REPL ; "distinct" meaning it will be
> stored at a different place in memory and its various properties
x can be different than the properties of aaa and that includes whether
> it is bound to a value and which value.
>x
> - it will be uninterned.

Be it is it may, `aaa has only one meaning. It is the thingy that has
been found in the current environment.
Suppose I use a name for a symbol that is already present in the environment.
I hope that that the new and old symbol are distinct despite having the
same name. Otherwise I seriously misunderstand lisp.

An implementation comes up.
I can introduced a flag "uninterned".
Prior to using a symbol I look whether it is bound in the current
context. If it is bound to a non-symbol, I do nothing.
If it is bound to an uninterned symbol, (only example generated
by (gensym) ), I replace it by the uninterned symbol.
These action should be taken, irrespective if the symbol is in
a context where it should be evaluated or not.
It can be done at the lexing/parsing stage, where the abstract structure
tree is build (is that a general term, or is that MAL jargon?),
and it not terrible involved.
>--
>ninja

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 -

Re: What does (gensym) generate?

<20230904084412.969@kylheku.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17485&group=comp.lang.lisp#17485

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-4973@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: What does (gensym) generate?
Date: Mon, 4 Sep 2023 15:56:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <20230904084412.969@kylheku.com>
References: <nnd$40329216$4a966390@764d4750d92df32c>
<20230831104914.534@kylheku.com> <nnd$616b9609$1776a5b1@5e4c41ff528acb91>
<8GRTwaqPt+TSAYagO@bongo-ra.co> <nnd$548571c9$5c8aed95@a9ee2931c2de023e>
Injection-Date: Mon, 4 Sep 2023 15:56:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b0451dec79ee4655b8a53117d1292826";
logging-data="1625518"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/aZ7XGn9G9cTkCUgC5EZXNEoYkQKBywJM="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:kvBESM9VLxLjgxHLcgf6khWGyJg=
 by: Kaz Kylheku - Mon, 4 Sep 2023 15:56 UTC

On 2023-09-04, albert@cherry.(none) (albert) <albert@cherry> wrote:
> In article <8GRTwaqPt+TSAYagO@bongo-ra.co>,
> Spiros Bousbouras <spibou@gmail.com> wrote:
>>On Fri, 01 Sep 2023 14:23:21 +0200
>>albert@cherry.(none) (albert) wrote:
>>> In article <20230831104914.534@kylheku.com>,
>>> Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>>> >On 2023-08-31, albert@cherry.(none) (albert) <albert@cherry> wrote:
>>
>>[...]
>>
>>
>>(let ((aaa (foo)))) binds aaa to whatever (foo) returns. As
>>far as this goes there is nothing special with something like
>>(let ((aaa (gensym)))) . aaa gets bound to whatever (gensym)
>>returned much like (let ((aaa (+ 1 1)))) binds aaa to whatever
>>(+ 1 1) returns which is 2.
>>
>>(gensym) returns a symbol with the special property that it is
>>uninterned. So the only reference to the symbol returned is through
>>aaa .There is nothing you can type on the REPL to get the same
>>symbol {although you can get a symbol with the same name} and every
>>other call to gensym will also return a different symbol.
>
> Remember that my big question was,what is the type of the value
> `aaa is bound to. So apparently that is a symbol that has
> uninterned.
> Can you please elaborate what uninterned means?

Uninterned means "not remembered by name for the purposes of
turning the same syntactic tokeen into the same symbol object".

Interning refers to turning multiple occurrences of an identifier
in the printed notation into references to the same symbol,
rather than distinct symbols. When (x x x) is read, there
are three references to the same symbol x, because of interning.

An uninterned symol is created without entering it into the dictionary
of interned symbols. Because it's newly created, it's a distinct object
from any other object, and because it's not interned, it cannot be found
by name. You cannot possibly read any object from text that would
contain that uninterned symbol.

> It is clear that you can have a symbol that is floating around
> and has not been placed in abstract structure tree or a
> hash table. Is that uninterned?

Yes, if by that hash table you refer to the structure that is used
to identify (x x x) has having the same symbol three times,
rather than three symbols.

(In ANSI Common Lisp, which has a package system, that table is the
package. Packages themselves are named: there is more than one package.)

Re: What does (gensym) generate?

<df69e26a-63a6-4e13-add0-f6d6544d7f48n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17487&group=comp.lang.lisp#17487

  copy link   Newsgroups: comp.lang.lisp
X-Received: by 2002:a05:620a:8c14:b0:76d:473:2e74 with SMTP id qz20-20020a05620a8c1400b0076d04732e74mr453220qkn.6.1693934838186;
Tue, 05 Sep 2023 10:27:18 -0700 (PDT)
X-Received: by 2002:a17:903:2303:b0:1bc:2547:b17c with SMTP id
d3-20020a170903230300b001bc2547b17cmr4715344plh.1.1693934837691; Tue, 05 Sep
2023 10:27:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.lisp
Date: Tue, 5 Sep 2023 10:27:17 -0700 (PDT)
In-Reply-To: <nnd$548571c9$5c8aed95@a9ee2931c2de023e>
Injection-Info: google-groups.googlegroups.com; posting-host=2620:0:102f:1005:55ea:3210:e66e:acf;
posting-account=05zmAwoAAAAJZM-3jv1hCWLHGZQceqwA
NNTP-Posting-Host: 2620:0:102f:1005:55ea:3210:e66e:acf
References: <nnd$40329216$4a966390@764d4750d92df32c> <20230831104914.534@kylheku.com>
<nnd$616b9609$1776a5b1@5e4c41ff528acb91> <8GRTwaqPt+TSAYagO@bongo-ra.co> <nnd$548571c9$5c8aed95@a9ee2931c2de023e>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <df69e26a-63a6-4e13-add0-f6d6544d7f48n@googlegroups.com>
Subject: Re: What does (gensym) generate?
From: taruss@google.com (Tom Russ)
Injection-Date: Tue, 05 Sep 2023 17:27:18 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2718
 by: Tom Russ - Tue, 5 Sep 2023 17:27 UTC

On Monday, September 4, 2023 at 4:08:19 AM UTC-7, none albert wrote:

> Suppose I use a name for a symbol that is already present in the environment.
> I hope that that the new and old symbol are distinct despite having the
> same name. Otherwise I seriously misunderstand lisp.

What happens depends on whether the symbol in question is interned or not.

Interned symbols:
If the reader encounters a symbol with a (package-qualified) name that is the same
as an already encountered symbol name, then the same symbol is returned. That is
why the CommonLisp expression (eq 'x 'x) returns T. Remember that EQ is object equality.
So with normal interned symbols, seeing the same name means you have the same symbol.
Now the same symbol can be bound to different values in different environments, but
the symbol object is always the same. So in the following (ignore the ".")
(let ((x 1))
...(print x)
...(let ((x 2))
.....(print x))
...(print x))
The printed values will be 1, 2, 1 because of the lexical bindings of the LET form, even
though the symbol X is the same symbol object in all the forms.

Uninterned symbols:
If the reader encounters a symbol with the special syntax indicating that it is an uninterned
symbol, then a new symbol is created. So that is why the CommonLisp expression
(eq '#:x '#:x) returns NIL.

Re: What does (gensym) generate?

<87a5u0gevh.fsf@gmail.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17489&group=comp.lang.lisp#17489

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 06 Sep 2023 03:27:52 +0000
From: sgonedes1977@gmail.com (steve)
Newsgroups: comp.lang.lisp
Subject: Re: What does (gensym) generate?
References: <nnd$40329216$4a966390@764d4750d92df32c>
Date: Tue, 05 Sep 2023 23:27:46 -0400
Message-ID: <87a5u0gevh.fsf@gmail.com>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:gmIybeZiKR/W2KfWhxBarOjCJHg=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 81
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-6FCnx1DmAyAYueW+Hj4gK33bTovKGI4faxf37XM42X6tWSS5mdTSrcGKotlpPbWTEz/dW1CDiHvITiC!L0DwrvyC8e+kt6aF2vfvQsJdBjOgHCLic5hxBOdURiFR8Q==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: steve - Wed, 6 Sep 2023 03:27 UTC

albert@cherry.(none) (albert) writes:

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

gensym is used in macros. like mkstemp in C.

> (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 type of 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))
;; try (let* (,~condvar ~(first xs))
> (if ~condvar ~condvar (or ~@(rest xs)))))))))

instead of using macro names with thisvar_ as you would use in C use
gensym. here is a small example.

(defmacro dostring ((var str &optional (return-value nil)) &body forms)
(declare (string str))
`(loop for ,var of-type character across (the string ,str)
do (locally ,@forms) finally (return ,return-value)))

(defmacro do-string-codes ((var string &optional return-value) &body forms)
(let ((ch-var (gensym "CHARACTER")))
`(dostring (,ch-var ,string ,return-value)
(let ((,var (char-code ,ch-var)))
,@forms))))

=> (dostring (chr "hello world")
(print chr))

#\h
#\e
#\l
#\l
#\o
#\
#\w
#\o
#\r
#\l
#\d
NIL

macroexpand

(LOOP FOR CHR OF-TYPE CHARACTER ACROSS (THE STRING "hello world")
DO (LOCALLY (PRINT CHR))
FINALLY (RETURN NIL))

sorry for the convoluted code - this is what I have..

usually make-symbol is used; gensym is never eq.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor