Search found 20 matches

by abvgdeika
Thu Nov 29, 2012 2:15 am
Forum: Common Lisp
Topic: macro expansion within macro
Replies: 5
Views: 15188

Re: macro expansion within macro

Your code did not work in my implementation. But here is my solution of what you probably wanted: (defmacro cond-clause (expr res) `(,expr (push ,res res) ) ) (defmacro test (cond-expr) `(cond ,(macroexpand-1 cond-expr) ) ) Then the command (macroexpand-1 '(test (cond-clause (equalp c 8) 1) ) ) resu...
by abvgdeika
Wed Nov 21, 2012 10:01 am
Forum: Common Lisp
Topic: Classes of functions?
Replies: 2
Views: 5361

Classes of functions?

When dealing with functions in LISP it is sometimes desirable to handle them differently depending on the number of formal variables. My question: is there any possibility to define classes of functions like "functions_of_one_variable", "functions_of_two_variables" etc? If this w...
by abvgdeika
Sat Nov 17, 2012 2:11 pm
Forum: Common Lisp
Topic: on &rest and keyword args...
Replies: 11
Views: 24997

Re: on &rest and keyword args...

by abvgdeika
Fri Nov 16, 2012 10:15 pm
Forum: Common Lisp
Topic: Replacing a function in an expression
Replies: 20
Views: 39065

Re: Replacing a function in an expression

When formulating your problem, you should also think about lexical closures. Assume your piece of LISP code contains the following fragment: (flet ((list (&rest argument) ......... definition ..........)) (LIST a b) (LIST c d e) .... et cetera ...... ) Are you sure you want to replace function o...
by abvgdeika
Fri Nov 16, 2012 10:01 am
Forum: Common Lisp
Topic: Behaviour of EVAL inside LET
Replies: 14
Views: 25496

Re: Behaviour of EVAL inside LET

I am not so advanced LISP user to understand the difference between a runtime evaluation and a macroexpansion out (:-)))) But macro TRUE-EVAL has indeed a strange behaviour. It cannot be applied to formal variables inside function definitions, an attempt to compile (defun t-eval (x) (true-eval x) ) ...
by abvgdeika
Fri Nov 16, 2012 8:25 am
Forum: Common Lisp
Topic: Behaviour of EVAL inside LET
Replies: 14
Views: 25496

Re: Behaviour of EVAL inside LET

The discussion in this topic is aimed at better understanding how the principle "there is no difference between code and data in LISP" works in practice. My intention was to "execute" comand-variables containing LISP code as their values (like variable "command") so tha...
by abvgdeika
Thu Nov 15, 2012 3:31 pm
Forum: Common Lisp
Topic: Behaviour of EVAL inside LET
Replies: 14
Views: 25496

Re: Behaviour of EVAL inside LET

After some experiments I found a right replacement of EVAL operator which works as expected inside lexical closures. This is the following macro: (defmacro true-eval (command-expression) `(macrolet ((evaluate () ,command-expression)) (evaluate) )) Here is a testing code: (setf command '(+ c j) ) (se...
by abvgdeika
Sun Nov 11, 2012 11:25 pm
Forum: Common Lisp
Topic: Problem with "initialize-instance"
Replies: 5
Views: 8949

Re: Problem with "initialize-instance"

Thank you for the explanation! I would say this is not so economic behaviour of LISP processor,
to run first all available methods and then to choose appropriate result. It seems much more natural to choose first
appropriate method and then to run it.
by abvgdeika
Sun Nov 11, 2012 2:40 pm
Forum: Common Lisp
Topic: Problem with "initialize-instance"
Replies: 5
Views: 8949

Re: Problem with "initialize-instance"

Situation is not so easy. The code (defmethod initialize-instance :after ( (item Big) &key ) (setf (my-value item) 666 ) ) (setf x (make-instance 'Small ) ) results in creating an instance "x" having my-value 13, as expected since the method of initialization for the class "Small&...
by abvgdeika
Sun Nov 11, 2012 9:03 am
Forum: Common Lisp
Topic: Problem with "initialize-instance"
Replies: 5
Views: 8949

Problem with "initialize-instance"

I try to experiment with classes in LISP and I stuck at the following problem already at a very beginning level. I define two classes "BIg" and "Small" so that "Small" is a subclass of "Big": (defclass Big () ( (my-value :accessor my-value) )) (defclass Small ...