[plt-scheme] Lispish system in Scheme

From: Jos Koot (jos.koot at telefonica.net)
Date: Thu Jun 22 08:22:13 EDT 2006

I think you should try defining your language by means of a module and use 
it in a module:

(module def-language mzscheme (provide ...) (define ...) ...)
(module use-language def-language expr ...)

In particular module def-language may redefine and provide syntax #%top, 
e.g:

(module def-language mzscheme
 (provide (rename my-top #%top) (all-from-except mzscheme #%top))
 (define-syntax my-top
  (syntax-rules ()
   ((my-top . id)
    (namespace-variable-value 'id #t (lambda () ()) (current-namespace))))))

(module use-language def-language
 (define a 1)
 (write (list a b)))

 (require use-language) ; writes (1 ( ))


((((lambda(x)((((((x x)x)x)x)x)x))
   (lambda(x)(lambda(y)(x(x y)))))
  (lambda(x)(write x)x))
 "greetings, Jos")
----- Original Message ----- 
From: "Ivanyi Peter" <pivanyi at freemail.hu>
To: "pltscheme" <plt-scheme at list.cs.brown.edu>
Sent: Thursday, June 22, 2006 1:56 PM
Subject: [plt-scheme] Lispish system in Scheme


Hi,

Is there any simple implementation of Lisp in Scheme? I have
tried
to do that but it does not seem to be too straightforward.
For example I would like to achieve that every variable has
a default
value, for example the empty list. I tried the following:

(define orig-eval (current-eval))
(define (lisp expr)
  (cond
    ((identifier? expr)
     (orig-eval (namespace-variable-value (syntax-e expr) #t
(lambda () '() )))
    )
    (else
      (orig-eval expr)
    )
  )
)
(current-eval lisp)

If I try this in DrScheme it works if I simply type a
symbol. However it
does not work in an expression like: (cons 1 anything)
I suspect the lisp evaluator is not called recursively.
Moreover I got it
work only as above, where expr is "maybe" a syntax object or
similar.
(Maybe I did not understand the documentation but something
else is
said there.) I also did not manage to "get into" this syntax
object, for
example to examine whether it is a list, if it is whether
the first element
in the list is a symbol and whether it is a function. (What
I would need
to write my own interpreter.)

I would appreciate any help, explanation, sample
implementation or
more detailed documentation.

(As I use DrScheme more and more and try to use new features
in it,
I have realised that I a really miss very simple demo programs.
I always have to search collects directory, and somtimes it
helps,
sometimes I found too complicated pieces of codes which I
cannot use,
etc. I know there is HtDP and a tons of other, but I mainly
work
offline and if I do not have them on the machine I cannot
access them.
I would prefer to have these in the PLTScheme docs.
Sorry for rambling, just a suggestion.)

Thanks for any help,

Peter Ivanyi




_______________________________________________________________________________
Focivébé helyett: csajos filmek egy kattintásra!
http://teka.t-online.hu/


_________________________________________________
  For list-related administrative tasks:
  http://list.cs.brown.edu/mailman/listinfo/plt-scheme 



Posted on the users mailing list.