From: Julie A Vandyke
Subject: Trying to convert from Franz to Common lisp
Date:
Message-ID: <13416@sun.udel.edu>
I am needing a common lisp implementation of fexpr and lexpr.
Does anyone have or know of one before I work on the
problem myself? I'd love to save myself some effort.
Thanx in advance for any help-
Email please, as I do not usually read this newsgroup.
Thanx-
Julie Van Dyke
email: ·······@udel.edu
From: Jeff Dalton
Subject: Re: Trying to convert from Franz to Common lisp
Date:
Message-ID: <3222@skye.ed.ac.uk>
In article <·····@sun.udel.edu> ·······@sun.udel.edu (Julie A Vandyke) writes:
>I am needing a common lisp implementation of fexpr and lexpr.
>Does anyone have or know of one before I work on the
>problem myself? I'd love to save myself some effort.
>
>Thanx in advance for any help-
>
>Email please, as I do not usually read this newsgroup.
I also e-mailed this (plus some other Franz hacks) but thoght
this might be of general interest. I wrote this code long
ago so I can no longer remember for sure whether it all works.
------------------------------
;;;; def
;;;
;;; This is one way to let people define nlambdas (fexprs), lexprs, and
;;; vanilla (non-defmacro) Franz macros. 'Apply' will work with lexprs
;;; but not with fexprs or macros
;;;
(defmacro def (name (type formals &body body))
(case type
(lambda
`(defun ,name ,formals ,@body))
(nlambda
(if (/= (length formals) 1)
(error "Def: fexpr ~S must have exactly one formal parameter." name))
(let ((real-name
(intern (concatenate 'string "REAL-" (symbol-name name)))))
`(progn
(defun ,real-name ,formals ,@body)
(defmacro ,name (&rest .fexpr-args.)
`(funcall #' ,',real-name ', .fexpr-args.)))))
(lexpr
(if (/= (length formals) 1)
(error "Def: lexpr ~S must have exactly one formal parameter." name)
`(defun ,name (&rest .lexpr-args.)
(let* ((.lexpr-nargs. (length .lexpr-args.))
(,(first formals) .lexpr-nargs.))
,@body))))
(macro
(if (/= (length formals) 1)
(error "Def: macro ~S must have exactly one formal parameter." name)
`(defmacro ,name (&rest ,(first formals))
(setq ,(first formals) ;/\/ hack for Kyoto
(cons ',name ,(first formals)))
,@body)))
(t (error "Def: ~S is not a valid function type for function ~S."
type name))))
;;;; lexpr extras
;;;
;;; These are macros so they can reference '.lexpr-args.' despite
;;; lexical scoping (hee hee).
;;;
(defmacro arg (&optional (n nil n-p))
(if n-p
`(elt .lexpr-args. ,n) ;? might want to do our own length check?
`(progn .lexpr-nargs.))) ;not just a variable so can't be set
------------------------------
Jeff Dalton, JANET: ········@uk.ac.ed
AI Applications Institute, ARPA: ·················@nsfnet-relay.ac.uk
Edinburgh University. UUCP: ...!ukc!ed.ac.uk!J.Dalton
From: Ira Baxter
Subject: Re: Trying to convert from Franz to Common lisp
Date:
Message-ID: <26CC68EB.5205@ics.uci.edu>
In case you want to convert DRACO to CommonLisp, this might be handy:
In <····@skye.ed.ac.uk> ····@aiai.ed.ac.uk (Jeff Dalton) writes:
>In article <·····@sun.udel.edu> ·······@sun.udel.edu (Julie A Vandyke) writes:
>>I am needing a common lisp implementation of fexpr and lexpr.
>>Does anyone have or know of one before I work on the
>>problem myself? I'd love to save myself some effort.
>>
>>Thanx in advance for any help-
>>
>>Email please, as I do not usually read this newsgroup.
>I also e-mailed this (plus some other Franz hacks) but thoght
>this might be of general interest. I wrote this code long
>ago so I can no longer remember for sure whether it all works.
>------------------------------
>;;;; def
>;;;
>;;; This is one way to let people define nlambdas (fexprs), lexprs, and
>;;; vanilla (non-defmacro) Franz macros. 'Apply' will work with lexprs
>;;; but not with fexprs or macros
>;;;
>(defmacro def (name (type formals &body body))
> (case type
> (lambda
> `(defun ,name ,formals ,@body))
> (nlambda
> (if (/= (length formals) 1)
> (error "Def: fexpr ~S must have exactly one formal parameter." name))
> (let ((real-name
> (intern (concatenate 'string "REAL-" (symbol-name name)))))
> `(progn
> (defun ,real-name ,formals ,@body)
> (defmacro ,name (&rest .fexpr-args.)
> `(funcall #' ,',real-name ', .fexpr-args.)))))
> (lexpr
> (if (/= (length formals) 1)
> (error "Def: lexpr ~S must have exactly one formal parameter." name)
> `(defun ,name (&rest .lexpr-args.)
> (let* ((.lexpr-nargs. (length .lexpr-args.))
> (,(first formals) .lexpr-nargs.))
> ,@body))))
> (macro
> (if (/= (length formals) 1)
> (error "Def: macro ~S must have exactly one formal parameter." name)
> `(defmacro ,name (&rest ,(first formals))
> (setq ,(first formals) ;/\/ hack for Kyoto
> (cons ',name ,(first formals)))
> ,@body)))
> (t (error "Def: ~S is not a valid function type for function ~S."
> type name))))
>;;;; lexpr extras
>;;;
>;;; These are macros so they can reference '.lexpr-args.' despite
>;;; lexical scoping (hee hee).
>;;;
>(defmacro arg (&optional (n nil n-p))
> (if n-p
> `(elt .lexpr-args. ,n) ;? might want to do our own length check?
> `(progn .lexpr-nargs.))) ;not just a variable so can't be set
>------------------------------
>Jeff Dalton, JANET: ········@uk.ac.ed
>AI Applications Institute, ARPA: ·················@nsfnet-relay.ac.uk
>Edinburgh University. UUCP: ...!ukc!ed.ac.uk!J.Dalton
--
Ira Baxter
From: Ira Baxter
Subject: Re: Trying to convert from Franz to Common lisp, oops, netiquette error
Date:
Message-ID: <26CC6A13.5587@ics.uci.edu>
Please ignore the previous message... I use two mailers, one of which
uses "f" to mean "forward to another party" (which I intended), and NN,
in which "f" means "follow-up". My mistake, I fingered before I looked.
--
Ira Baxter