Nп/п : 64 из 93
 От   : none) (albert                       2:5075/128        04 сен 23 13:08:07
 К    : Spiros Bousbouras                                     04 сен 23 14:11:01
 Тема : Re: What does (gensym) generate?
----------------------------------------------------------------------------------
                                                                                 
@MSGID:
a9d45092
@REPLY: <8GRTwaqPt+TSAYagO@bongo-ra.co> 6bfd103b
@REPLYADDR none) (albert
@REPLYTO 2:5075/128 none) (albert
@CHRS: CP866 2
@RFC: 1 0
@RFC-References:
<20230831104914.534@kylheku.com>
<8GRTwaqPt+TSAYagO@bongo-ra.co>
@RFC-Message-ID:

@TZUTC: 0200
@TID: FIDOGATE-5.12-ge4e8b94
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)  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 -
--- trn 4.0-test77 (Sep 1, 2010)
 * Origin: KPN B.V. (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5058/104 5075/128
@PATH: 5075/128 5020/1042 4441



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх