From: Jean Louis <bugs@gnu.support>
To: Joost Kremers <joostkremers@fastmail.fm>
Cc: help-gnu-emacs@gnu.org
Subject: Re: common lisp vs elisp.
Date: Sun, 20 Jun 2021 10:16:32 +0300 [thread overview]
Message-ID: <YM7rUN9xB+0bohzH@protected.localdomain> (raw)
In-Reply-To: <87tult2fvq.fsf@fastmail.fm>
* Joost Kremers <joostkremers@fastmail.fm> [2021-06-20 09:46]:
> Second, IELM interacts with your Emacs session. If you set a variable or define
> a function in it, the variable or function is available throughout Emacs. SLIME
> interacts with a Common Lisp subprocess and whatever you do there has no effect
> on Emacs. So you can't define a function in SLIME and then call it from
> somewhere else in Emacs, nor can that function access Emacs' state.
Though it is possible to emulated or get some limited functionality by
calling external Lisp or other languages from Emacs Lisp:
(defun clisp-number-to-words (n &optional trim)
"Returns the cardinal English number representation, for example if N is 4, it would return \"four\""
(clisp (format "(format t \"~R\" %d)" n) trim))
Number of our ancestors in 50 generations (left to thinking):
(clisp-number-to-words (expt 2 50)) ⇒ "one quadrillion, one hundred and twenty-five trillion, eight hundred and ninety-nine billion, nine hundred and six million, eight hundred and forty-two thousand, six hundred and twenty-four
"
Or evaluating string with Perl programming language:
(defun perl (string)
(if (rcd-which "perl")
(if string
(rcd-command-output-from-input "perl" string)
"")
(rcd-warning-message "RCD ERROR: `perl' not found in $PATH")))
(perl "print 2 + 2") ⇒ "4"
(perl "print 2 + 2; print \"\n\"; print 10") ⇒ "4
10"
Or evaluating variable DATA as string, sending it to external Common
Lisp implementation CLISP and getting result from it:
(defun clisp (data &optional trim)
(if (rcd-which "clisp")
(let* ((value (if data
(rcd-command-output-from-input "clisp" data "-q" "-norc" "-")
""))
(value (if trim (string-trim value) value)))
value)
(rcd-warning-message "RCD ERROR: `clisp' not found in $PATH")))
(clisp "(princ (+ 2 2))") ⇒ "4
"
(clisp "(format t \"~R\" (expt 2 50))") ⇒ "one quadrillion, one
hundred and twenty-five trillion, eight hundred and ninety-nine
billion, nine hundred and six million, eight hundred and forty-two
thousand, six hundred and twenty-four
""
or with the macro that allows some easier Lisp writing and illusion of
direct evaluation:
(defmacro clisp-macro (&rest body)
(declare (indent 1) (debug t))
`(clisp (prin1-to-string (quote ,@body)) t))
(clisp-macro (format t "~R" (expt 2 50))) ⇒ "one quadrillion, one hundred and twenty-five trillion, eight hundred and ninety-nine billion, nine hundred and six million, eight hundred and forty-two thousand, six hundred and twenty-four"
Though I would like that this macro becomes able to evaluate any
number of forms. If somebody has a solutin, let me know.
(clisp-macro (princ "First form")) ⇒ "First form"
(clisp-macro (princ "First form") (princ "Second form")) -- not working
Of course this way it would work:
(clisp-macro (progn
(princ "First form") (princ " Second form"))) ⇒ "First form Second form"
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
next prev parent reply other threads:[~2021-06-20 7:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-20 2:22 common lisp vs elisp Hongyi Zhao
2021-06-20 3:13 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-20 3:26 ` Hongyi Zhao
2021-06-20 3:42 ` 2QdxY4RzWzUUiLuE
2021-06-20 4:04 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-06-20 4:44 ` Hongyi Zhao
2021-06-20 6:21 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-20 6:36 ` Joost Kremers
2021-06-20 6:57 ` Hongyi Zhao
2021-06-20 7:35 ` Jean Louis
2021-06-20 12:44 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-27 15:08 ` Andreas Eder
2021-06-27 15:36 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-28 6:46 ` Jean Louis
2021-07-06 1:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-07-06 12:28 ` Alexandre Garreau
2021-07-06 16:08 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-06-20 7:16 ` Jean Louis [this message]
2021-06-20 7:04 ` Jean Louis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YM7rUN9xB+0bohzH@protected.localdomain \
--to=bugs@gnu.support \
--cc=help-gnu-emacs@gnu.org \
--cc=joostkremers@fastmail.fm \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).