help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about Elisp language abilities (evaluating expr on time of func


From: Oleksandr Gavenko
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
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1

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).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]