From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: common lisp vs elisp. Date: Sun, 20 Jun 2021 10:16:32 +0300 Message-ID: References: <87bl81kz3b.fsf@zoho.eu> <87tult2fvq.fsf@fastmail.fm> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30628"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0.7+183 (3d24855) (2021-05-28) Cc: help-gnu-emacs@gnu.org To: Joost Kremers Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 20 09:22:11 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lurmU-0007j5-Uq for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 20 Jun 2021 09:22:10 +0200 Original-Received: from localhost ([::1]:33242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lurmT-0003G2-Bn for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 20 Jun 2021 03:22:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lurmA-0003Fo-Bf for help-gnu-emacs@gnu.org; Sun, 20 Jun 2021 03:21:50 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:43055) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lurm8-0001uS-HG for help-gnu-emacs@gnu.org; Sun, 20 Jun 2021 03:21:50 -0400 Original-Received: from localhost ([::ffff:197.157.0.61]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 00000000000D9939.0000000060CEEC89.00006CCB; Sun, 20 Jun 2021 00:21:45 -0700 Mail-Followup-To: Joost Kremers , help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <87tult2fvq.fsf@fastmail.fm> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: 29 X-Spam_score: 2.9 X-Spam_bar: ++ X-Spam_report: (2.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_SBL_CSS=3.335, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:131081 Archived-At: * Joost Kremers [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/