From: Alexander
Subject: passing parameter by reference
Date: 
Message-ID: <1134121053.146908.147130@g14g2000cwa.googlegroups.com>
A had written couple trivial macros to implement 'passing by reference'
function argument semantic.

For example let's write function swap :

(defun swap (a b)
  (rotatef (get-ref a) (get-ref b)))

(let ((x 10)
       (y 20))
   (swap (ref x) (ref y))
   (list x y))
=> (20 10)

Here implemention:

(defmacro ref (x)
   (multiple-value-bind (dummies vals new setter getter)
                        (get-setf-expansion x)
     `(let* ,(mapcar #'list dummies vals)
       (cons
	#'(lambda (arg) (let ((,(car new) arg)) ,setter))
	#'(lambda () ,getter)))))

(defmacro get-ref (y)
  `(funcall (cdr ,y)))

(defsetf get-ref (y) (what)
  `(funcall (car ,y) ,what))

From: Ivan Boldyrev
Subject: Re: passing parameter by reference
Date: 
Message-ID: <9op793-sat.ln1@ibhome.cgitftp.uiggm.nsc.ru>
On 9318 day of my life ········@gmail.com wrote:
> A had written couple trivial macros to implement 'passing by reference'
> function argument semantic.

There is also implementation of locatives (this is its lispy name) by
Lars Brinkhoff (google for "[Small-cl-src] Locatives Lars Brinkhoff".
Sorry, I have no exact URL, unfortunately I keep articles only, not
their URLs :)

Though your implementation is similar, Lars' one may use cons, struct
or class as locative storage type.

-- 
Ivan Boldyrev

              "Assembly of Japanese bicycle require great peace of mind."
From: Kenny Tilton
Subject: Re: passing parameter by reference
Date: 
Message-ID: <Rzgwf.30661$GW1.23109@news-wrt-01.rdc-nyc.rr.com>
Ivan Boldyrev wrote:
> On 9318 day of my life ········@gmail.com wrote:
> 
>>A had written couple trivial macros to implement 'passing by reference'
>>function argument semantic.
> 
> 
> There is also implementation of locatives (this is its lispy name) by
> Lars Brinkhoff (google for "[Small-cl-src] Locatives Lars Brinkhoff".
> Sorry, I have no exact URL, unfortunately I keep articles only, not
> their URLs :)
> 
> Though your implementation is similar, Lars' one may use cons, struct
> or class as locative storage type.
> 

Scary. two seconds ago I wrote:

(defmacro & (x) (cons x nil))
(defmacro * (x) (car x))

When we did a Java port, we had a dedicated wrapper class for each class 
of thing we wanted to pass by reference.

Ooops, time to stop beating that dead horse. Must retarget to Python... 
no, it's Ruby this week, right?

:)

Is anyone working on a Rails for Portable AllegroServe?

kt