From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleksandr Gavenko Newsgroups: gmane.emacs.help Subject: Question about Elisp language abilities (evaluating expr on time of func definition and ability to construct function). Date: Fri, 30 Sep 2011 00:33:17 +0300 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1317332033 29296 80.91.229.12 (29 Sep 2011 21:33:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 29 Sep 2011 21:33:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 29 23:33:49 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R9OEn-0007Oz-75 for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Sep 2011 23:33:49 +0200 Original-Received: from localhost ([::1]:41859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9OEm-0002bU-A8 for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Sep 2011 17:33:48 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:35056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9OEh-0002bJ-67 for help-gnu-emacs@gnu.org; Thu, 29 Sep 2011 17:33:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R9OEf-0005G5-R5 for help-gnu-emacs@gnu.org; Thu, 29 Sep 2011 17:33:43 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:40510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R9OEf-0005FW-Ib for help-gnu-emacs@gnu.org; Thu, 29 Sep 2011 17:33:41 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1R9OEe-0007LT-Bp for help-gnu-emacs@gnu.org; Thu, 29 Sep 2011 23:33:40 +0200 Original-Received: from 214-8-202-46.pool.ukrtel.net ([46.202.8.214]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 29 Sep 2011 23:33:40 +0200 Original-Received: from gavenkoa by 214-8-202-46.pool.ukrtel.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 29 Sep 2011 23:33:40 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 50 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 214-8-202-46.pool.ukrtel.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:82374 Archived-At: I learn Elisp lang capability. According to 13.2 Expansion of a Macro Call section of 'info elisp': Evaluation of the macro call begins like evaluation of a function call except for one crucial difference: the macro arguments are the actual expressions appearing in the macro call. They are not evaluated before they are given to the macro definition. So Elisp macro executed when func called, but with different algorithm of args passing. This allow make "new" language constructions but I know about more powerful abilities. Is there any Elisp special form which evaluate args when 'defun' parsed (like words which defined with IMMEDIATE marker in Forth prog lang)? In Forth in time of processing of word definition compiler can pass control to interpreter when encounter special word until they decide back to compilation process. So in similar construction exist in Elisp this hypothetical code: (defun f (x) (IMMEDIATE (message "hello!")) (1+ x) ) on 'f' compilation stage print "hello" and never do this on 'f' evaluation. Another question is there ability to construct function on the fly. For example: (GENFUNC get-parser (syntax-tree) (data) ... ) syntax-tree is a string, data is free argument. When you call (get-parser "a=a|ab; b=*") you get function with one argument (remember 'data'?) which constructed dynamically and can perform parsing very speedily (as 'get-parser' can be more fast then general purpose parser as it know 'syntax-tree' on construction stage).