From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Fren Zeee Newsgroups: gmane.emacs.help Subject: Can elisp call C functions without recompilation of emacs? Date: Sun, 27 Jun 2010 22:34:46 -0700 (PDT) Organization: http://groups.google.com Message-ID: <94dbb562-a73d-4990-9a78-273056c9f829@e5g2000yqn.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1291840412 24209 80.91.229.12 (8 Dec 2010 20:33:32 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Dec 2010 20:33:32 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 08 21:33:28 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQQha-0005Zy-Sf for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 21:33:27 +0100 Original-Received: from localhost ([127.0.0.1]:36875 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQQha-0001JE-1E for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 15:33:26 -0500 Original-Path: usenet.stanford.edu!postnews.google.com!e5g2000yqn.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help, comp.lang.lisp, comp.lang.c, comp.emacs.xemacs, gnu.emacs.sources Original-Lines: 57 Original-NNTP-Posting-Host: 75.30.150.100 Original-X-Trace: posting.google.com 1277703286 24550 127.0.0.1 (28 Jun 2010 05:34:46 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Mon, 28 Jun 2010 05:34:46 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e5g2000yqn.googlegroups.com; posting-host=75.30.150.100; posting-account=Xy1x0QoAAAC1_8XWVbTILoO5VL5JMCDm User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6,gzip(gfe) Original-Xref: usenet.stanford.edu gnu.emacs.help:179291 comp.lang.lisp:289669 comp.lang.c:976880 comp.emacs.xemacs:82457 gnu.emacs.sources:13246 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:75987 Archived-At: In 1996, Stephen Eglin asked the following question which was never answered but is of interest to people in C , Lisp and users of Emacs : http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/a89c2d3ddd89768d/a2368ff6f5ea1b7b?q=%22Writing+Emacs+Primitives%22 Newsgroups: comp.emacs, gnu.emacs.help From: steph...@cogs.susx.ac.uk (Stephen Eglen) Date: 1996/04/10 Subject: Can elisp call C functions without recompilation of emacs? Reply to author | Forward | Print | Individual message | Show original | Report this message | Find messages by this author Can elisp call functions written in C without recompilation of emacs? I think what I am asking is not possible, but here goes anyway... Here at Sussex we have an environment called POP-11, which is a lisp style interactive AI programming environment. One of its main features is that you can call C functions from POP-11 after the shared object files containing the C functions have been loaded into POP-11. This can be done interactively, and does not require either POP-11 to be recompiled or for the C functions to be compiled with any special options. So for example, if I write a function called add(x,y) in C, and then compile it into a shared object, I can then call this C function from POP-11 once I have loaded in the object file storing the add function. Of course,one of the restrictions made on the POP:C interface is that I think the arguments to a c function must be ints, floats, doubles and chars, rather than abstract c data types. This is a very useful facility, especially when debugging c functions, since you can write the test functions in POP-11, which is an interactive language, and so only the C functions need compiling, and not the test functions. (I'm not sure exactly how the mechanism works in POP-11, but I think it uses some form of incremental compiler?) My question therefore is does emacs offer this facility of calling c functions from elisp? I notice in the elisp info files (Writing Emacs Primitives) that of course some emacs primitives are written in c, but am I right in thinking that once the c function has been written, the whole of emacs needs recompiling? If this is the case, then I guess the compile time of emacs would be a big overhead, and probably not worth it. Also, it looks like the c functions have to be written especially with elisp in mind (eg use of the DEFUN macros.) I only have access to emacs 19.27 at the moment, but if it works for other versions, I would be interested in hearing about them. Thanks in advance, Stephen Eglen. -- Stephen Eglen, DPhil Student, steph...@cogs.susx.ac.uk School of Cognitive and Computing Sciences, Fax: +44-(0)1273 671320 University of Sussex, Phone: +44- (0)1273-678524 Falmer, BRIGHTON, BN1 9QH, UK http://www.cogs.susx.ac.uk/users/stephene/