Apply and mapcar break when a function is manually quoted

Apply and mapcar break when a function is manually quoted

I noticed some code breaking when transitioning from AutoCAD to BricsCAD lisp, and this tracked down to function applying functions, apply, mapcar.

In AutoCAD, I compile my lambdas beforehand in some cases, as this makes them a lot quicker in loops. function-quoting is not always an option, as a lambda might needed to be dynamically created, and also in cases, where the list-lambdas become too large to be carried around (where garbage collection kicks in hard).

In these cases, in AutoCAD it is needed to manually quote the compiled function, but this manual quoting causes an error in BricsCAD. In BCAD this quoting is actually not needed, which I would prefer to use, but for the code to be OK in both CADs, it would be necessary to have these functions working the same way in the manually quoted case.

vl-remove-if and vl-remove-if-not already work correctly in this case.

Just to highlight the differences:

(apply '(lambda (x) (+ x x)) '(1)) ;; ok
(apply (function (lambda (x) (+ x x))) '(1)) ;; ok
(apply (lambda (x) (+ x x)) '(1)) ;; breaks in AutoCAD, ok in BricsCAD
(apply (list 'quote (lambda (x) (+ x x))) '(1)) ;; ok in A-CAD, breaks in B-CAD

(mapcar '(lambda (x) (+ x x)) '(1 2 3)) ;; ok
(mapcar (lambda (x) (+ x x)) '(1 2 3)) ;; breaks in A-CAD, ok in B-CAD
(mapcar (list 'quote (lambda (x) (+ x x))) '(1 2 3)) ;; ok in A-CAD, breaks in B-CAD

(vl-remove-if '(lambda (x) (= x 1)) '(1 2 3)) ;; ok 
(vl-remove-if (lambda (x) (= x 1)) '(1 2 3)) ;; breaks in A-CAD, ok in B-CAD
(vl-remove-if (list 'quote (lambda (x) (= x 1))) '(1 2 3)) ;; ok in both

Comments

  • Hello maccs,

    thanks for reporting, interesting cases :-)
    You might also send this problem to our SupportRequest system, to have the issue tracked in our database, please ?

    I will check this anyway, and hopefully be able to get it fixed for V21 ...
    many greetings !

  • Will send!

  • Support for those (rather strange) Lisp code variants has been added, will be available with V21 then.

    many greetings !

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Click one of the buttons on the top bar to get involved!