Author Topic: BricsCAD: Problem with ((if booleVarP and not) T)?  (Read 1657 times)

0 Members and 1 Guest are viewing this topic.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
BricsCAD: Problem with ((if booleVarP and not) T)?
« on: October 04, 2013, 05:05:28 AM »
In BricsCAD I have a problem with this (see line 3 of the code):
Code - Auto/Visual Lisp: [Select]
  1. (setq booleVarP T)
  2. ((if booleVarP + -) 2 5) => 7 (OK).
  3. ((if booleVarP and not) T) => Error! See below.
  4.  
  5. (setq booleVarP nil)
  6. ((if booleVarP + -) 2 5) => -3 (OK).
  7. ((if booleVarP and not) T) => nil (OK).
Why is there this error?: no function definition <(IF BOOLEVARP AND NOT)> ; expected FUNCTION at [EVAL]

ronjonp

  • Needs a day job
  • Posts: 7531
Re: BricsCAD: Problem with ((if booleVarP and not) T)?
« Reply #1 on: October 04, 2013, 09:20:05 AM »
Not sure why it's throwing the error but in AutoCAD it generates this:
; error: cannot apply special form: AND

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: BricsCAD: Problem with ((if booleVarP and not) T)?
« Reply #2 on: October 04, 2013, 10:16:02 AM »
@ ronjonp:
Well at least it seems that BricsCAD is compatible. But like you I do not understand why there is an error.

hmspe

  • Bull Frog
  • Posts: 362
Re: BricsCAD: Problem with ((if booleVarP and not) T)?
« Reply #3 on: October 04, 2013, 01:02:30 PM »
Could it be that 'and' and 'not' are lisp functions?  Selecting an operator this way makes some sense, but I would not expect to be able to select a function this way.  I'm more surprised that line 7 appears to work than that line 3 does not.  That said, I'm not sure that line 7 is really evaluating what we think it is.
"Science is the belief in the ignorance of experts." - Richard Feynman

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: BricsCAD: Problem with ((if booleVarP and not) T)?
« Reply #4 on: October 05, 2013, 04:00:14 AM »
Code: [Select]
(setq booleVarP T)
((if booleVarP and not) T)   => Error!
((if booleVarP and not) nil) => Error!

(setq booleVarP nil)
((if booleVarP and not) T)   => nil
((if booleVarP and not) nil) => T
If there is no error the evaluation seems correct.
BTW: Using (or) instead of (and) does not solve this.

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: BricsCAD: Problem with ((if booleVarP and not) T)?
« Reply #5 on: October 05, 2013, 07:54:37 AM »
Given the error returned in AutoCAD, I presume that the problem is caused by the and function being a Special Form, and hence evaluating arguments in a different manner to not.

This is confirmed when using other Special Forms, such as foreach:
Code - Auto/Visual Lisp: [Select]
  1. _$ (setq x t)
  2. T
  3. _$ ((if x foreach) y '(1 2 3) (princ y))
  4. T
  5. ; error: cannot apply special form: FOREACH
Or or:
Code - Auto/Visual Lisp: [Select]
  1. _$ (setq x t)
  2. T
  3. _$ ((if x or not) t)
  4. ; error: cannot apply special form: OR

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: BricsCAD: Problem with ((if booleVarP and not) T)?
« Reply #6 on: October 05, 2013, 10:45:57 AM »
You just have to play nice with the interpreter:

(apply (if t 'and 'not) '(T)) => T

(apply (if nil 'and 'not) '(T)) => nil
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: BricsCAD: Problem with ((if booleVarP and not) T)?
« Reply #7 on: October 07, 2013, 03:44:34 AM »
Thanks guys.