Code: Select all
(defconstant functions
'(1+
1-))
I want to define a macro that expands into
Code: Select all
(+
(1+ 1)
(1- 1))
Code: Select all
(defconstant functions
'(1+
1-))
Code: Select all
(+
(1+ 1)
(1- 1))
You don't need to worry about inlining simple standard functions. The functions 1+ and 1- are already inlined in most (all?) implementations.imba wrote:I want the functions to be called to be inlined.
Code: Select all
(defun my-function (...)
...)
(declaim (inline myfunction))
Code: Select all
(defconstant functions '(1+ 1-))
(defun foo ()
(loop for fun in functions
summing (funcall fun 4)))
Code: Select all
(defun fixnum-1+ (x)
(1+ (the fixnum x)))
(defun fixnum-1- (x)
(1- (the fixnum x)))
(defconstant +functions+ '(fixnum-1+ fixnum-1-))
(defun foo ()
(loop for fun in +functions+
summing (funcall fun 4)))
Well, because +functions+ is a constant? Is there no possibility to write a macro that translates this code togugamilare wrote:Only explicit calls to a function can be inlined. If you are holding functions in a variable, how can the compiler know which function that variable will be holding so that it can inline it?
Code: Select all
(+ (funcall 1+ 4)
(funcall 1- 4))