From: ···············@free.fr
Subject: How to implement setf ?
Date: 
Message-ID: <1147456889.481978.5260@y43g2000cwc.googlegroups.com>
 Hi !

I'm an asm, C, C++ programmer.
I try to understand LISP internal. So I tried to look at small LISP
interpreters sources.

I found a nice C sources here :
http://www.sonoma.edu/users/l/luvisi/sl3.c
In one chunk of code, written by Andru Luvisi.

My aim is to seize how it works in mind. I began :
- to split the file in small parts,
- to rewrite it in C++,
- to implement atom, eq and exit that lacked even to a tiny LISP.
  ( Are correct ? I hope... not sure. )

Here is my modified version :
http://fabrice.marchant.free.fr/sL/

It helps me to understand but I'm not able to add setf.

Please could you give me a hint in order to implement this assignment.

Thanks in advance.

Fabrice

From: Kaz Kylheku
Subject: Re: How to implement setf ?
Date: 
Message-ID: <1147459961.958969.116960@i40g2000cwc.googlegroups.com>
···············@free.fr wrote:
> Hi !
>
> I'm an asm, C, C++ programmer.
> I try to understand LISP internal. So I tried to look at small LISP
> interpreters sources.
>
> I found a nice C sources here :
> http://www.sonoma.edu/users/l/luvisi/sl3.c
> In one chunk of code, written by Andru Luvisi.
>
> My aim is to seize how it works in mind. I began :
> - to split the file in small parts,
> - to rewrite it in C++,
> - to implement atom, eq and exit that lacked even to a tiny LISP.
>   ( Are correct ? I hope... not sure. )
>
> Here is my modified version :
> http://fabrice.marchant.free.fr/sL/
>
> It helps me to understand but I'm not able to add setf.

Writing a SETF which conforms to the full ANSI CL spec for SETF isn't
entirely easy.

Writing a limited SETF which supports only a small "hard wired"
repertoire of places that can be assigned to should be easy.

> Please could you give me a hint in order to implement this assignment.

You didn't specify what failed approaches you actually tried, so nobody
has any idea why you are not able to add SETF.

Perhaps the missing hint that you need is that SETF is an operator, not
a function.

You could implement a limited SETF in the above interpreter as a
built-in special form.

Let's look at the interpreter's EVAL function. I'm looking at the
original sources, not your modified C++ version:

obj *eval(obj *exp, obj *env) {
  obj *tmp;

  if(exp == nil) return nil;

  switch(exp->type) {
    case INT: return exp;
    case SYM:   tmp = assoc(exp, env);
                if(tmp == nil) error("Unbound symbol");
                return cdr(tmp);
    case CONS:  if(car(exp) == s_if) {
		  if(eval(car(cdr(exp)), env) != nil)
		    return eval(car(cdr(cdr(exp))), env);
		  else
		    return eval(car(cdr(cdr(cdr(exp)))), env);
		}
		if(car(exp) == s_lambda)
		  return mkproc(car(cdr(exp)), cdr(cdr(exp)), env);
		if(car(exp) == quote)
		  return car(cdr(exp));
		if(car(exp) == s_define)
		  return(extend_top(car(cdr(exp)),
		                    eval(car(cdr(cdr(exp))), env)));
		if(car(exp) == s_setb) {
		  obj *pair   = assoc(car(cdr(exp)), env);
		  obj *newval = eval(car(cdr(cdr(exp))), env);
		  setcdr(pair, newval);
		  return newval;
		}
		return apply(eval(car(exp), env), evlis(cdr(exp), env), env);
    case PRIMOP: return exp;
    case PROC:   return exp;
  }
  /* Not reached */
  return exp;

Look at the CONS case. This is the part of the evaluator which handles
compound expressions: expressions that are lists. The if/else  ladder
inside the case handles all of the interpreter's special operators: if,
lambda, quote, define and setb. One place to implement setf would be
here.

A basic minimal setf would be a lot like the setb, except more
complicated. The setb operator here doesn't do any error checking, and
supports assignment to a symbol only. It retrieves the first argument
of the setb, i.e. the  second element of the expression ---
car(cdr(exp)) --- and assumes that it's a symbol which can be looked up
in the environment using assoc(). It evaluates the second argument, and
performs the assignment.

A setf would have to do more work: it would have to look at the
/syntax/ of the first argument and analyze it to determine what kind of
place is being assigned to.

It might be better to write assignment functions for all the kinds of
places you want, implement macros, adn then write setf in the mini lisp
language itself as a macro!
From: Kalle Olavi Niemitalo
Subject: Re: How to implement setf ?
Date: 
Message-ID: <871wuwexqh.fsf@Astalo.kon.iki.fi>
"Kaz Kylheku" <········@gmail.com> writes:

> Writing a SETF which conforms to the full ANSI CL spec for SETF isn't
> entirely easy.

The SETF macro itself isn't very hard, but it needs
MULTIPLE-VALUE-BIND and GET-SETF-EXPANSION, which I think will
not be so easy to implement in a program not prepared for them.
(Function bindings hide outer setf expanders of the same name.)
Also, signalling PROGRAM-ERROR for odd numbers of arguments
requires a part of the condition system.
From: Pascal Bourguignon
Subject: Re: How to implement setf ?
Date: 
Message-ID: <87lkt75cwp.fsf@thalassa.informatimago.com>
···············@free.fr writes:
> I'm an asm, C, C++ programmer.
> I try to understand LISP internal. So I tried to look at small LISP
> interpreters sources.
>
> I found a nice C sources here :
> http://www.sonoma.edu/users/l/luvisi/sl3.c
> In one chunk of code, written by Andru Luvisi.
>
> My aim is to seize how it works in mind. I began :
> - to split the file in small parts,
> - to rewrite it in C++,
> - to implement atom, eq and exit that lacked even to a tiny LISP.
>   ( Are correct ? I hope... not sure. )
>
> Here is my modified version :
> http://fabrice.marchant.free.fr/sL/
>
> It helps me to understand but I'm not able to add setf.

Hahahahah!

> Please could you give me a hint in order to implement this assignment.

Yep. SETF can hardly be implemented in C++.  On the other hand, it can
be implemented easily in Lisp, as a lisp macro!


For example, in CLISP,  SETF is defined as follow.  To understand it,
you should read CLHS about  GET-SETF-EXPANSION.
http://ww.lispworks.com/documentation/HyperSpec/Body/f_get_se.htm
http://www.lispworks.com/documentation/HyperSpec/Body/05_aab.htm


(defmacro setf (&whole whole-form
                &rest args &environment env)
  (let ((argcount (length args)))
    (cond
      ((eql argcount 2)
       (let* ((place (first args))
              (value (second args)))
         (loop
            ;; 1. Schritt: nach globalen SETF-Definitionen suchen:
            (when (and (consp place) (symbolp (car place)))
              (when (global-in-fenv-p (car place) (svref env 1))
                ;; Operator nicht lokal definiert
                (if (and (eq (first place) 'values-list) (eql (length place) 2))
                    (return-from setf
                      `(values-list
                        (setf ,(second place) (multiple-value-list ,value))))
                    (let ((plist-info (get (first place) 
                                           'system::setf-expander)))
                      (when plist-info
                        (return-from setf
                          (cond 
                            ((symbolp plist-info) 
                             ;; Symbol kommt von kurzem DEFSETF
                             `(,plist-info ,@(cdr place) ,value))
                            ((and (eq (first place) 'the) (eql (length place) 3))
                             `(setf ,(third place) (the ,(second place) ,value)))
                            (t
                             (multiple-value-bind (temps subforms stores 
                                                   setterform getterform)
                                 (get-setf-expansion place env)
                               (declare (ignore getterform))
                               (let ((bindlist (mapcar #'list temps subforms)))
                                 (if (= (length stores) 1)
                                     ;; 1 store variable
                                     (wrap-let* 
                                        (nconc bindlist
                                               (list `(,(first stores) ,value)))
                                        setterform)
                                     ;; mehrere Store-Variable
                                     (if ;; Hat setterform die Gestalt
                                      ;; (VALUES (SETQ v1 store1) ...) ?
                                      (and (consp setterform)
                                           (eq (car setterform) 'values)
                                           (do ((str stores (cdr str))
                                                (sqr (cdr setterform) (cdr sqr)))
                                               ((or (null str) (null sqr))
                                                (and (null str) (null sqr)))
                                             (unless (simple-assignment-p
                                                          env (car sqr)
                                                          (list (car str)))
                                               (return nil))))
                                      (let ((vlist (mapcar #'second
                                                           (rest setterform))))
                                        `(let* ,bindlist
                                           (multiple-value-setq ,vlist ,value)
                                           (values ,@vlist)))
                                      (wrap-let* bindlist
                                                 `(multiple-value-bind ,stores
                                                             ,value
                                                    ,setterform))))))))))))))
            ;; 2. Schritt: macroexpandieren
            (when (eq place (setq place (macroexpand-1 place env)))
              (return)))
         ;; 3. Schritt: Default-SETF-Methoden
         (cond
           ((symbolp place)
            `(setq ,place ,value))
           ((and (consp place) (symbolp (car place)))
            (multiple-value-bind (temps subforms stores setterform getterform)
                (get-setf-expansion place env)
              (declare (ignore getterform))
              ;; setterform probably looks like
              ;;   `((SETF ,(first place)) ,@stores ,@temps).
              ;; stores are probably superfluous and get optimized away.
              (optimized-wrap-let* env
                                   (nconc (mapcar #'list temps subforms)
                                          (list (list (first stores) value)))
                                   setterform)))
           (t (error-of-type 'source-program-error
                             :form whole-form
                             :detail (first args)
                             (text "~S: Illegal place: ~S")
                             'setf (first args))))))
      ((oddp argcount)
       (error-of-type 'source-program-error
                      :form whole-form
                      :detail whole-form
                      (text "~S called with an odd number of arguments: ~S")
                      'setf whole-form))
      (t (do* ((arglist args (cddr arglist))
               (l nil))
              ((null arglist) `(let () (progn ,@(nreverse l))))
           (push `(setf ,(first arglist) ,(second arglist)) l))))))

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
From: Eli Gottlieb
Subject: Re: How to implement setf ?
Date: 
Message-ID: <FF69g.13324$Gg.930@twister.nyroc.rr.com>
···············@free.fr wrote:
>  Hi !
> 
> I'm an asm, C, C++ programmer.
> I try to understand LISP internal. So I tried to look at small LISP
> interpreters sources.
> 
> I found a nice C sources here :
> http://www.sonoma.edu/users/l/luvisi/sl3.c
> In one chunk of code, written by Andru Luvisi.
> 
> My aim is to seize how it works in mind. I began :
> - to split the file in small parts,
> - to rewrite it in C++,
> - to implement atom, eq and exit that lacked even to a tiny LISP.
>   ( Are correct ? I hope... not sure. )
> 
> Here is my modified version :
> http://fabrice.marchant.free.fr/sL/
> 
> It helps me to understand but I'm not able to add setf.
> 
> Please could you give me a hint in order to implement this assignment.
> 
> Thanks in advance.
> 
> Fabrice
> 
You sure you want a real Common Lisp setf?

-- 
The science of economics is the cleverest proof of free will yet 
constructed.
From: ···············@free.fr
Subject: Re: How to implement setf ?
Date: 
Message-ID: <1147518339.306324.321860@j33g2000cwa.googlegroups.com>
  Thank you for your swift answers, for the links and for the very
interesting explanations !

P.B.> SETF can hardly be implemented in C++
  Ah ! I didn't have weighed the complexity of the problem.

  You make me understand to be much more modest and forget ( put in
parenthesis ) setf for a time.
 Must begin to experiment with more basic kind of assignment !

> On the other hand, it can be implemented easily in Lisp, as a lisp macro!

Implementing setf in LISP why not ?

  But I want to base it on very tiny sl3.
  I've selected Andru Luvisi sl3 because it was very small and written
in a low level language I could easily understand, not in huge and
powerful Common LISP ! ( When a usable version of this tiny Lisp with a
minimal set of features will properly run, I want to be able to recode
it even in assembler. )

K.K.> You didn't specify what failed approaches you actually tried,
I read this
http://groups.google.fr/group/comp.lang.lisp/browse_thread/thread/2b141657ef1f7bc9/47
and took a look at the David Betz XLISP C sources.

There is a setf module : xlsetf.c
http://mvb.saic.com/freeware/vax85a/xlisp/
But I wasn't able to grasp the way it runs...

> Perhaps the missing hint that you need is that SETF is an operator, not a function.
> You could implement a limited SETF in the above interpreter as a built-in special function
That's an useful precision for me.

> Look at the CONS case. This is the part of the evaluator which handles
> compound expressions: expressions that are lists. The if/else  ladder
> inside the case handles all of the interpreter's special operators: if,
> lambda, quote, define and setb. One place to implement setf would be
> here.
I imagined to put it here.

> A basic minimal setf would be a lot like the setb, except more
> complicated. The setb operator here doesn't do any error checking, and
> supports assignment to a symbol only. It retrieves the first argument
> of the setb, i.e. the  second element of the expression ---
> car(cdr(exp)) --- and assumes that it's a symbol which can be looked up
> in the environment using assoc(). It evaluates the second argument, and
> performs the assignment.
> A setf would have to do more work: it would have to look at the
> /syntax/ of the first argument and analyze it to determine what kind of
> place is being assigned to.

OK : a mistake I'd in mind is to believe it was possible to get access
to a kind of "reference" ( in sense of C++ ) of the object to be
assigned to. ( So the access syntax to this object inside the first
argument would be completely indifferent ).

> It might be better to write assignment functions for all the kinds of
> places you want, implement macros, adn then write setf in the mini lisp
> language itself as a macro!

I agree and will follow this advice.
I read p41 of LISP 1.5 Programmer's Manual : 7.4 List Structure
Operators
An "elementary LISP" like sl3 "has no ability to modify list
structure."
( of a previously existing list, without creating some new copy ).
 Sl3 indeeds need such an "additional tools to increase its power."

Maybe a good start would be to implement rplaca/rplacd ?

In second step I will see how to handle this :
> Writing a limited SETF which supports only a small "hard wired"
> repertoire of places that can be assigned to should be easy.

Will keep this for the end :
(setf (any-accessor x) y)

For now, I will try to implement a rplaca (= set-car).

E.G.> You sure you want a real Common Lisp setf
Eli, what do you mean by this ? Are they some drawbacks in Common LISP
setf ?

Thanx again !

Fabrice
From: Kaz Kylheku
Subject: Re: How to implement setf ?
Date: 
Message-ID: <1147562276.651905.216570@g10g2000cwb.googlegroups.com>
···············@free.fr wrote:
> OK : a mistake I'd in mind is to believe it was possible to get access
> to a kind of "reference" ( in sense of C++ ) of the object to be
> assigned to. ( So the access syntax to this object inside the first
> argument would be completely indifferent ).

Even if you implement it this way, so that the operation of actually
storing the value is uniform among the different kinds of places
(simple indirection through an address), the code to compute the
effective address will still be different for each case.
From: ···············@free.fr
Subject: Re: How to implement setf ?
Date: 
Message-ID: <1147645371.350169.298340@u72g2000cwu.googlegroups.com>
P.B.> Well, it IS possible to write any program in C++ or in Assembler.
Türing machines...

> The question is why would you want to do that?
> There may be reason why to write some primitives for a Lisp in C++ or
> in assembler.  But what can be written more easily in Lisp why not
> write it in Lisp?

* As I explain below, I'm unable to write such a program in Lisp for
now.
* I want to build the small LISP from a minimal state and make it
evolve only when I understand the need of a new feature. That means : I
learn LISP in experimenting with the small interpreter.
* If the small LISP matures enough to be usable, I want to use it as an
embedded language for games ( for example like gnurobots that uses
libguile scheme to program a robot to explore a world) but I hope a
lighter size.  That forbids it to be interpreted by a big LISP.
Maybe can compile LISP... but what about the size ?
( About the games : a great thing would be to create a new Corewar were
LISP programs - instead of Redcode ones - could fight together. I dream
about this but cannot stand for a suitable arena. )

> Actually, in my opinion, there are very little reasons to write any
> primitive in C++, C or assembler.  I'd take Squeak as a canonical
> example:  The Smalltalk virtual machine in Squeak is written in a
> subset of Smalltalk, for which they implemented a Smalltalk to C
> translator, in Smalltalk.  So the whole Squeak environment is written
> in Smalltalk, even if some low-level parts of it is translated into C,
> from simple Smalltalk.

  I agree to write the maximum of things in the small LISP itself,
keeping it minimal in term of C or C++ core.

> Since you have at your disposition powerful tools, why not use them,
> even to write a simple and lighweight lisp?  Write it from Common Lisp!


I'm learning LISP : do not master the language at all.
Twenty years ago I thought to work with it and then forgot.
But I recently used GNU programs the GIMP and Dr Geo. Scheme is their
script language. All the job resides in the procedures side effects.
About elegance of LISP here : very few indeed but enough to recall the
desire to study it.

>> Are they some drawbacks in Common LISP setf ?
> None, but you may want to start with a simplier one.
> CL:SETF is "extensible": the user can define new places with DEFSETF
> or DEFINE-SETF-EXPANDER.
You make me discover this Common LISP feature.

> You may want to allow only a predetermined set of places.
K.K. >the code to compute the effective address will still be different
for
>each case.
>>> It might be better to write assignment functions for all the kinds of
>>> places you want...

Please what would be a basic set of places to the assignment fonctions
?
Today I implemented a rplaca that works fine for its desired side
effect.
I followed Kaz advices.
Translated in C, it would give something like this :

    case SYM:   tmp = assoc(exp, env);
                if(tmp == nil) error("Unbound symbol");
                return cdr(tmp);
    case CONS:  if(car(exp) == s_if) {
                  if(eval(car(cdr(exp)), env) != nil)
                    return eval(car(cdr(cdr(exp))), env);
                  else
                    return eval(car(cdr(cdr(cdr(exp)))), env);
                }
                if(car(exp) == s_lambda)
                  return mkproc(car(cdr(exp)), cdr(cdr(exp)), env);
                if(car(exp) == quote)
                  return car(cdr(exp));
                if(car(exp) == s_define)
                  return(extend_top(car(cdr(exp)),
                                    eval(car(cdr(cdr(exp))), env)));
                if(car(exp) == s_setb) {
                  obj *pair   = assoc(car(cdr(exp)), env);
                  obj *newval = eval(car(cdr(cdr(exp))), env);
                  setcdr(pair, newval);
                  return newval;
                }
//------------------------------------------
                if( car(exp) == s_rplaca ) {
                  setcar( eval(car(cdr(exp)), env),
                               eval(car(cdr(cdr(exp))), env)
                             );
                  return cadr()->eval( env ); // Not sure...
                }
//------------------------------------------
                return apply(eval(car(exp), env), evlis(cdr(exp), env),
env);

But what exactly about rplaca return value ?

Fabrice
From: Pascal Bourguignon
Subject: Re: How to implement setf ?
Date: 
Message-ID: <87iro83zma.fsf@thalassa.informatimago.com>
···············@free.fr writes:
>> [...] But what can be written more easily in Lisp why not
>> write it in Lisp?
> * As I explain below, I'm unable to write such a program in Lisp for now.
> [...]
>> Since you have at your disposition powerful tools, why not use them,
>> even to write a simple and lighweight lisp?  Write it from Common Lisp!
>
> I'm learning LISP : do not master the language at all.

So, since you don't know Lisp yet, you go on writting C code...
Like these people who search their lost keys under the lamppost because
that's where there's light.

C'est en forgeant qu'on devient forgeron!

Start writting lisp code, then you'll know how to write lisp code!


That said, I understand that you may have several simultaneous goals,
so it might be justified to just write a lisp implementation in C, but
I'm afraid you'll learn more on how to write a lisp implementation,
than to write lisp programs.

Since always, (from the beginning), lisp implementations were written
in lisp (even if the first one was then hand-compiled to 704
assembler).  If the inventor of lisp used lisp to write lisp, why
couldn't you do the same?

ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-008.pdf


I'd advise you to read SICP too: 
http://mitpress.mit.edu/sicp/full-text/book/book.html
or watch the videos:
http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

In a World without Walls and Fences, 
who needs Windows and Gates?
From: Rob Warnock
Subject: Re: How to implement setf ?
Date: 
Message-ID: <L9adnZh3MoJvQvrZnZ2dnUVZ_uWdnZ2d@speakeasy.net>
Pascal Bourguignon  <···@informatimago.com> wrote:
+---------------
| Since always, (from the beginning), lisp implementations were written
| in lisp (even if the first one was then hand-compiled to 704
| assembler).  If the inventor of lisp used lisp to write lisp, why
| couldn't you do the same?
| 
| ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-008.pdf
+---------------

A much more readable extended version (the 1960 CACM paper), which also
contains the "boxes & arrows" descriptions of internal data structures
and the low-level machine implementation of a few of the primitives
(both intentionally omitted from AIM-008), may be found here:

    http://www-formal.stanford.edu/jmc/recursive.html  [cover page]
    http://www-formal.stanford.edu/jmc/recursive.pdf

+---------------
| I'd advise you to read SICP too: 
|   http://mitpress.mit.edu/sicp/full-text/book/book.html
| or watch the videos:
|   http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/
+---------------

And any serious would-be implementor should also read Christian
Queinnec's marvelous "LiSP", which covers numerous design
alternatives in the implementation of Lisp-like languages:

    "Lisp in Small Pieces" [originally "Les langages Lisp"]
    http://www-spi.lip6.fr/~queinnec/WWW/LiSP.html
    http://www-spi.lip6.fr/~queinnec/common/LiSPeng.png

I personally found "Chapter 6: Fast interpretation" to be
particularly useful as an introduction to the preprocessing
needed for fast lexical variables, including various alternatives
for the runtime representations of lexical environments [including
one particularly-tricky "gotcha" in the interaction between the
representation of closures and Scheme-style continuations].


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Eli Gottlieb
Subject: Re: How to implement setf ?
Date: 
Message-ID: <GFR9g.17041$TT.2509@twister.nyroc.rr.com>
Rob Warnock wrote:
> Pascal Bourguignon  <···@informatimago.com> wrote:
> +---------------
> | Since always, (from the beginning), lisp implementations were written
> | in lisp (even if the first one was then hand-compiled to 704
> | assembler).  If the inventor of lisp used lisp to write lisp, why
> | couldn't you do the same?
> | 
> | ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-008.pdf
> +---------------
> 
> A much more readable extended version (the 1960 CACM paper), which also
> contains the "boxes & arrows" descriptions of internal data structures
> and the low-level machine implementation of a few of the primitives
> (both intentionally omitted from AIM-008), may be found here:
> 
>     http://www-formal.stanford.edu/jmc/recursive.html  [cover page]
>     http://www-formal.stanford.edu/jmc/recursive.pdf
> 
> +---------------
> | I'd advise you to read SICP too: 
> |   http://mitpress.mit.edu/sicp/full-text/book/book.html
> | or watch the videos:
> |   http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/
> +---------------
> 
> And any serious would-be implementor should also read Christian
> Queinnec's marvelous "LiSP", which covers numerous design
> alternatives in the implementation of Lisp-like languages:
> 
>     "Lisp in Small Pieces" [originally "Les langages Lisp"]
>     http://www-spi.lip6.fr/~queinnec/WWW/LiSP.html
>     http://www-spi.lip6.fr/~queinnec/common/LiSPeng.png
> 
> I personally found "Chapter 6: Fast interpretation" to be
> particularly useful as an introduction to the preprocessing
> needed for fast lexical variables, including various alternatives
> for the runtime representations of lexical environments [including
> one particularly-tricky "gotcha" in the interaction between the
> representation of closures and Scheme-style continuations].
> 
> 
> -Rob
> 
> -----
> Rob Warnock			<····@rpw3.org>
> 627 26th Avenue			<URL:http://rpw3.org/>
> San Mateo, CA 94403		(650)572-2607
> 
Hey, nifty!

-- 
The science of economics is the cleverest proof of free will yet 
constructed.
From: ···············@free.fr
Subject: Re: How to implement setf ?
Date: 
Message-ID: <1148171988.966620.323680@y43g2000cwc.googlegroups.com>
ftp://publications.ai.mit.edu/ai-publications/pdf/AIM-008.pdf
and
http://www-formal.stanford.edu/jmc/recursive.html

Interesting papers, indeed !

They speak about "Linear Lisp".

Do you know additional information about "linear" or "binary" LISP.
They were maybe implemented ?

P.B.> C'est en forgeant qu'on devient forgeron!
C'est en l'aidant que l'on devient laideron.
C'est en sciant que Léonard devint scie.
OK, you are right : I need to begin to write some LISP.

And about rplaca return value ?
From: Rob Warnock
Subject: Re: How to implement setf ?
Date: 
Message-ID: <6omdnZb-R__7QPLZnZ2dnUVZ_sOdnZ2d@speakeasy.net>
<···············@free.fr> wrote:
+---------------
| They speak about "Linear Lisp".
| Do you know additional information about "linear" or "binary" LISP.
+---------------

Had you Google'd for "linear lisp", the very first hit would have
been a winner:

    http://home.pipeline.com/~hbaker1/LinearLisp.html
    Lively Linear Lisp -- 'Look Ma, No Garbage!'

You will also find quite a large number of other references to
linear logic at Baker's site:

    http://home.pipeline.com/~hbaker1/home.html


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: ···············@free.fr
Subject: Re: How to implement setf ?
Date: 
Message-ID: <1148244272.620980.179510@i40g2000cwc.googlegroups.com>
Thank you Rob !

I study Henry G. Baker pages. Very curious to understand what is this
special LISP.

Regards

Fabrice
From: Pascal Bourguignon
Subject: Re: How to implement setf ?
Date: 
Message-ID: <87d5eh632k.fsf@thalassa.informatimago.com>
···············@free.fr writes:

>   Thank you for your swift answers, for the links and for the very
> interesting explanations !
>
> P.B.> SETF can hardly be implemented in C++
>   Ah ! I didn't have weighed the complexity of the problem.
>
>   You make me understand to be much more modest and forget ( put in
> parenthesis ) setf for a time.
>  Must begin to experiment with more basic kind of assignment !
>
>> On the other hand, it can be implemented easily in Lisp, as a lisp macro!
>
> Implementing setf in LISP why not ?
>
>   But I want to base it on very tiny sl3.
>   I've selected Andru Luvisi sl3 because it was very small and written
> in a low level language I could easily understand, not in huge and
> powerful Common LISP ! ( When a usable version of this tiny Lisp with a
> minimal set of features will properly run, I want to be able to recode
> it even in assembler. )

Well, it IS possible to write any program in C++ or in Assembler. 
The question is why would you want to do that?

There may be reason why to write some primitives for a Lisp in C++ or
in assembler.  But what can be written more easily in Lisp why not
write it in Lisp?


Actually, in my opinion, there are very little reasons to write any
primitive in C++, C or assembler.  I'd take Squeak as a canonical
example:  The Smalltalk virtual machine in Squeak is written in a
subset of Smalltalk, for which they implemented a Smalltalk to C
translator, in Smalltalk.  So the whole Squeak environment is written
in Smalltalk, even if some low-level parts of it is translated into C,
from simple Smalltalk.  

Since you have at your disposition powerful tools, why not use them,
even to write a simple and lighweight lisp?  Write it from Common Lisp!

> [...]
> E.G.> You sure you want a real Common Lisp setf
> Eli, what do you mean by this ? Are they some drawbacks in Common LISP
> setf ?

None, but you may want to start with a simplier one.
CL:SETF is "extensible": the user can define new places with DEFSETF
or DEFINE-SETF-EXPANDER.  
You may want to allow only a predetermined set of places.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we. -- Georges W. Bush