[LispM] odd Explorer behavior - interpreted vs. compiled

r.stricklin bear at typewritten.org
Wed Oct 12 22:09:16 PDT 2016


On Oct 12, 2016, at 8:00 PM, r.stricklin wrote:

>> 10 BR         28            ; here is the bug.
> 
> boy, I wish I could haul this one back. talk about jumping to conclusions! yikes.

Okay, it's something to do with the semantics of the defun macro and interaction with return.

This works, using "return-from divp" instead of just "return":

> (defun divp (n list) (block nil (mapcar #'(lambda (p) (cond ((zerop (mod n p)) (return-from divp t)))) list) (return-from divp nil)))
DIVP
> (divp 6 '(2 3))
T
> (divp 5 '(2 3))
NIL
> (compile 'divp)
DIVP
0
> (divp 6 '(2 3))
T
> (divp 5 '(2 3))
NIL
> (uncompile 'divp)
T
> (fdefinition 'divp)
(NAMED-LAMBDA DIVP (N LIST) (BLOCK DIVP (BLOCK NIL (MAPCAR (FUNCTION (LAMBDA (P) (COND ((ZEROP (MOD N P)) (RETURN-FROM DIVP T))))) LIST) (RETURN-FROM DIVP NIL))))

I can't say I really understand _why_ it ought to have mattered. I should have a closer look under the covers of one of the other systems.


ok
bear.

-- 
until further notice



More information about the LispM mailing list