[Ecls-list] example code error in new manual?

Raffael Cavallaro raffaelcavallaro at mac.com
Sun Mar 11 19:09:10 UTC 2007


While reading the new manual section on c-inline I noticed that one  
of the examples given at <http://ecls.sourceforge.net/new-manual/ 
re12.html> appears to have a significant typo:

(defun sample (x)
   (ffi:c-inline (n1 n2) (:int :int) (values :int :int) "{
     int n1 = #0, n2 = #1, out1 = 0, out2 = 1;
     while (n1 <= n2) {
       out1 += n1;
       out2 *= n1;
       n1++;
     }
     @(return 0)= out1;
     @(return 1)= out2;
     }"
    :side-effects nil))


I believe that the formal parameter x is never used, and the  
parameters n1 and n2 are undefined. This should probably read:

(defun sample (n1 n2)
   (ffi:c-inline (n1 n2) (:int :int) (values :int :int) "{
     int n1 = #0, n2 = #1, out1 = 0, out2 = 1;
     while (n1 <= n2) {
       out1 += n1;
       out2 *= n1;
       n1++;
     }
     @(return 0)= out1;
     @(return 1)= out2;
     }"
    :side-effects nil))


regards,

Ralph


Raffael Cavallaro, Ph.D.
raffaelcavallaro at mac.com





More information about the ecl-devel mailing list