Search found 17 matches

by lrodrig
Sun Jul 01, 2012 12:15 am
Forum: Common Lisp
Topic: Problem calling a macro
Replies: 3
Views: 7806

Re: Problem calling a macro

Hi, Thank you very much for your answer. I didn't realize that the problem was caused by this simple thing (shame on me!). As you show in your example and the argument passed to the function is not sent to the macro because it has been expanded at compiling time. As expected, replacing the wrapper f...
by lrodrig
Sat Jun 30, 2012 1:46 pm
Forum: Common Lisp
Topic: Problem calling a macro
Replies: 3
Views: 7806

Problem calling a macro

Hi, I have defined a macro that returns a closure. The basic idea is to provide a very simple OOP without using CLOS so that you can call the closure using some key parameters to get or set some attributes (free variables in the closure). The thing is that I have a function that provides a simple in...
by lrodrig
Tue Aug 16, 2011 1:39 am
Forum: Common Lisp
Topic: declaring macros returning type
Replies: 3
Views: 4411

Re: declaring macros returning type

Hi, Thank you very much for your answer. You are right when you say that macros return no type. Sorry for my poor explanation. I was referring to the type of the final expression evaluated within the macro. From your examples I'm assuming that including the type declaration inside the macro will do ...
by lrodrig
Tue Aug 16, 2011 12:43 am
Forum: Common Lisp
Topic: declaring macros returning type
Replies: 3
Views: 4411

declaring macros returning type

Hi,

I was wondering if there is something equivalent to ftype for macros. I need to produce a highly optimized piece of code and I'm using macros.

According to CLHS, ftype only works for functions. Is there any way to declare the type a macro will return?

Regards,
Luis.
by lrodrig
Sun Jun 12, 2011 12:19 am
Forum: Common Lisp
Topic: Comma operator and macros
Replies: 4
Views: 5688

Re: Comma operator and macros

Thanks a lot!
by lrodrig
Sat Jun 11, 2011 10:04 am
Forum: Common Lisp
Topic: Comma operator and macros
Replies: 4
Views: 5688

Comma operator and macros

Hi, I have a macro that creates a clausure like this: (defmacro object-mult (atr1 atr2) ` (let ((atr1 ,atr2) (atr2 ,atr2)) (lambda (x) (* atr1 atr2)))) The thing is that I'm trying to implement another macro that automatically produces the code shown in the example above . The macro skeleton would b...
by lrodrig
Sat Jun 04, 2011 12:42 pm
Forum: Common Lisp
Topic: multiple evaluation in macros
Replies: 4
Views: 5496

Re: multiple evaluation in macros

edgar-rft wrote:Try this:

Code: Select all

(defmacro macro-example (...)
  `(progn
     (defstruct ...)
     (defun  ....)))
Any other construct using an implicit PROGN will work, too.

- edgar
Thank you. I should have come up with this straightforward solution.

Regards,
Luiw
by lrodrig
Sat Jun 04, 2011 9:46 am
Forum: Common Lisp
Topic: multiple evaluation in macros
Replies: 4
Views: 5496

multiple evaluation in macros

Hi, I'm trying to implement a macro that creates both a struct and a function. The following code template: (defmacro macro-example (...) `(defstruct ...) `(defun ....)) doesn't work since only the last element is actually evaluated and, therefore, the function is defined but the structure is not cr...
by lrodrig
Fri Mar 25, 2011 3:47 am
Forum: Common Lisp
Topic: declaring types for atributes in CLOS
Replies: 3
Views: 3722

Re: declaring types for atributes in CLOS

Hi,

Thanks for your responses. I think that using structures will be a good solution here.

Luis.
by lrodrig
Thu Mar 24, 2011 12:04 pm
Forum: Common Lisp
Topic: declaring types for atributes in CLOS
Replies: 3
Views: 3722

declaring types for atributes in CLOS

Hi, I'm trying to optimize a piece of CL code (in SBCL) by adding some type declarations. The thing is that I have a class: (defclass foo () ... (data :accessor data :type 'single-float)) An I have a method: (defmethod do-something((object foo) a) (declare (optimize (speed 3)) (single-float a)) ( / ...