Author Topic: AutoLisp or/and not complying to CL's  (Read 9809 times)

0 Members and 1 Guest are viewing this topic.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: AutoLisp or/and not complying to CL's
« Reply #30 on: July 20, 2012, 04:05:34 AM »
Actually ... just found the original source code of XLisp 0.0 here: http://www.softwarepreservation.org/projects/LISP/xlisp/0_0/

Extract from xlmath.c
Code - C: [Select]
  1. /* lor - logical or */
  2. static struct node *lor(args)
  3.   struct node *args;
  4. {
  5.     struct node *oldstk,arg,*val;
  6.  
  7.     /* create a new stack frame */
  8.     oldstk = xlsave(&arg,NULL);
  9.  
  10.     /* initialize */
  11.     arg.n_ptr = args;
  12.     val = NULL;
  13.  
  14.     /* evaluate each argument */
  15.     while (arg.n_ptr != NULL)
  16.     if (cnvnum(xlevarg(&arg.n_ptr)) != 0) {
  17.         val = true;
  18.         break;
  19.     }
  20.  
  21.     /* restore the previous stack frame */
  22.     xlstack = oldstk;
  23.  
  24.     /* return the result value */
  25.     return (val);
  26. }
Clearly it returns the first value which evaluates to != 0.

Same for and:
Code - C: [Select]
  1. /* land - logical and */
  2. static struct node *land(args)
  3.   struct node *args;
  4. {
  5.     struct node *oldstk,arg,*val;
  6.  
  7.     /* create a new stack frame */
  8.     oldstk = xlsave(&arg,NULL);
  9.  
  10.     /* initialize */
  11.     arg.n_ptr = args;
  12.     val = true;
  13.  
  14.     /* evaluate each argument */
  15.     while (arg.n_ptr != NULL)
  16.  
  17.     /* get the next argument */
  18.     if (cnvnum(xlevarg(&arg.n_ptr)) == 0) {
  19.         val = NULL;
  20.         break;
  21.     }
  22.  
  23.     /* restore the previous stack frame */
  24.     xlstack = oldstk;
  25.  
  26.     /* return the result value */
  27.     return (val);
  28. }
Returns the value of the last item if all arguments evaluates to != 0.

So this is definitely an ADesk change! Which makes AL the only lisp to return T / nil ONLY from or/and.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.