[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Can two variables share the same place?

paladin

2/22/2016 5:50:00 AM

Say you have variables X and Y, how can (SETF Y 'whatever) also accomplish a (SETF X 'whatever) automatically?
18 Answers

rpw3

2/22/2016 7:04:00 AM

0

paladin <quotient@gmail.com> wrote:
+---------------
| Say you have variables X and Y, how can (SETF Y 'whatever)
| also accomplish a (SETF X 'whatever) automatically?
+---------------

Symbol macros.

[Yeah, it's a cheat, but it might be enough,
depending on why you want such a thing...]


-Rob

-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <http://rpw...
San Mateo, CA 94403

Kenneth Tilton

2/22/2016 12:04:00 PM

0

On Monday, February 22, 2016 at 12:49:58 AM UTC-5, paladin wrote:
> Say you have variables X and Y, how can (SETF Y 'whatever) also accomplish a (SETF X 'whatever) automatically?

(a) No.
(b) What on Earth are you doing? I think you have boiled down what you really want to something simpler just to ask the question. There might be a "yes" available for the actual case.

-hk

Jim Newton

2/22/2016 12:17:00 PM

0

On Monday, February 22, 2016 at 6:49:58 AM UTC+1, paladin wrote:
> Say you have variables X and Y, how can (SETF Y 'whatever) also accomplish a (SETF X 'whatever) automatically?

Certainly two (or more) places can share the same space.

splenetico

2/22/2016 8:09:00 PM

0

paladin <quotient@gmail.com> wrote:

> Say you have variables X and Y, how can (SETF Y 'whatever) also accomplish
> a (SETF X 'whatever) automatically?

I think on Genera you can (could) get two symbols to share the same
value cell with

(si:link-symbol-value-cells 'x 'y)

which possibly may achieve what you ask for.

--
lo Splenetico
IN EVRO NVLLA SALVS

Kaz Kylheku

2/22/2016 8:25:00 PM

0

On 2016-02-22, Splenetico <splenetico@splenetico.net> wrote:
> paladin <quotient@gmail.com> wrote:
>
>> Say you have variables X and Y, how can (SETF Y 'whatever) also accomplish
>> a (SETF X 'whatever) automatically?
>
> I think on Genera you can (could) get two symbols to share the same
> value cell with
>
> (si:link-symbol-value-cells 'x 'y)

Runner up in the Miss Feature pageant of 1983!

Barry Margolin

2/22/2016 8:55:00 PM

0

In article <20160222122252.883@kylheku.com>,
Kaz Kylheku <330-706-9395@kylheku.com> wrote:

> On 2016-02-22, Splenetico <splenetico@splenetico.net> wrote:
> > paladin <quotient@gmail.com> wrote:
> >
> >> Say you have variables X and Y, how can (SETF Y 'whatever) also accomplish
> >> a (SETF X 'whatever) automatically?
> >
> > I think on Genera you can (could) get two symbols to share the same
> > value cell with
> >
> > (si:link-symbol-value-cells 'x 'y)
>
> Runner up in the Miss Feature pageant of 1983!

Lisp Machines had a general "forwarding pointer" mechanism -- the value
in any cell can be a pointer to another cell, and any access to the
first would automatically redirect to the target. I think its main use
was internal to the copying garbage collector -- when copying an object
to the new space, it replaced it with a forwarding pointer. This way, if
another process modified that object, it would be redirected to the new
location, rather than update the obsolete location.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Jeff Barnett

2/22/2016 9:07:00 PM

0

Barry Margolin wrote on 2/22/2016 1:55 PM:
> In article <20160222122252.883@kylheku.com>,
> Kaz Kylheku <330-706-9395@kylheku.com> wrote:
>
>> On 2016-02-22, Splenetico <splenetico@splenetico.net> wrote:
>>> paladin <quotient@gmail.com> wrote:
>>>
>>>> Say you have variables X and Y, how can (SETF Y 'whatever) also accomplish
>>>> a (SETF X 'whatever) automatically?
>>>
>>> I think on Genera you can (could) get two symbols to share the same
>>> value cell with
>>>
>>> (si:link-symbol-value-cells 'x 'y)
>>
>> Runner up in the Miss Feature pageant of 1983!
>
> Lisp Machines had a general "forwarding pointer" mechanism -- the value
> in any cell can be a pointer to another cell, and any access to the
> first would automatically redirect to the target. I think its main use
> was internal to the copying garbage collector -- when copying an object
> to the new space, it replaced it with a forwarding pointer. This way, if
> another process modified that object, it would be redirected to the new
> location, rather than update the obsolete location.

Another use was to aid the implementation of dynamic closures - remember
those things? And a third was to allow setf to the cdr of cdr-next
cells. In actual fact, the under-the-table forward was used for all
sorts of implementation hacking and made some royal pains relatively
straightforward.
--
Jeff Barnett

Kaz Kylheku

2/22/2016 9:25:00 PM

0

On 2016-02-22, Jeff Barnett <jbb@notatt.com> wrote:
> Barry Margolin wrote on 2/22/2016 1:55 PM:
>> In article <20160222122252.883@kylheku.com>,
>> Kaz Kylheku <330-706-9395@kylheku.com> wrote:
>>
>>> On 2016-02-22, Splenetico <splenetico@splenetico.net> wrote:
>>>> paladin <quotient@gmail.com> wrote:
>>>>
>>>>> Say you have variables X and Y, how can (SETF Y 'whatever) also accomplish
>>>>> a (SETF X 'whatever) automatically?
>>>>
>>>> I think on Genera you can (could) get two symbols to share the same
>>>> value cell with
>>>>
>>>> (si:link-symbol-value-cells 'x 'y)
>>>
>>> Runner up in the Miss Feature pageant of 1983!
>>
>> Lisp Machines had a general "forwarding pointer" mechanism -- the value
>> in any cell can be a pointer to another cell, and any access to the
>> first would automatically redirect to the target. I think its main use
>> was internal to the copying garbage collector -- when copying an object
>> to the new space, it replaced it with a forwarding pointer. This way, if
>> another process modified that object, it would be redirected to the new
>> location, rather than update the obsolete location.
>
> Another use was to aid the implementation of dynamic closures - remember
> those things? And a third was to allow setf to the cdr of cdr-next
> cells. In actual fact, the under-the-table forward was used for all
> sorts of implementation hacking and made some royal pains relatively
> straightforward.

Of course; that's just the fundamental theorem of software engineering:

https://en.wikipedia.org/wiki/Fundamental_theorem_of_software_e...

Kenneth Tilton

2/23/2016 9:56:00 AM

0

On Monday, February 22, 2016 at 7:16:48 AM UTC-5, Jim Newton wrote:
> On Monday, February 22, 2016 at 6:49:58 AM UTC+1, paladin wrote:
> > Say you have variables X and Y, how can (SETF Y 'whatever) also accomplish a (SETF X 'whatever) automatically?
>
> Certainly two (or more) places can share the same space.

I think you hit "send" before finishing this non-contradicting contradiction.

Antsan

2/23/2016 2:39:00 PM

0

Why is it a misfeature?

If bindings were first-class objects this wouldn't be a problem at all.
So, if you can make bindings fist class objects in Lisp you'd be able to share
a place across variables.
Didn't Doug Hoyte do this in Let Over Lambda via lambdas?

Yeah, this is the (incomplete and incorrect) code:
(defmacro! pointer-& (obj)
`(lambda (&optional (,g!set ',g!temp))
(if (eq ,g!set ',g!temp)
,obj
(setf ,obj ,g!set))))

(defun pointer-* (addr)
(funcall addr))

(defsetf pointer* (addr)
(val)
`(funcall ,addr ,val))

(defsetf pointer-& (addr)
(val)
`(setf (pointer-* ,addr)
,val))

Indirection indeed.