From bear at typewritten.org Wed Oct 12 18:42:29 2016 From: bear at typewritten.org (r.stricklin) Date: Wed, 12 Oct 2016 18:42:29 -0700 Subject: [LispM] odd Explorer behavior - interpreted vs. compiled Message-ID: <4F593985-CCDF-4ECF-BDDC-00C15C79C2CA@typewritten.org> Howdy, folks. I have an odd issue I'm at a loss to explain and lack insight re: where to start troubleshooting. I have a function which is meant to take a number and a list of numbers as arguments, and return T if the number is evenly divisible by any number in the list. Nil, if the number is not evenly divisible by any of the numbers in the list. (defun divp (n list) (block nil (mapcar #'(lambda (p) (cond ((zerop (mod n p)) (return T)))) list) (return nil))) This works exactly as I expect, whether compiled or interpreted, on Allegro CL and in Genera 8. On the microExplorer (Release 6.1 if it matters), it works exactly as I expect... until I compile it. Once it's compiled, it always returns nil. For example, the expected behavior, and what is observed from Allegro CL, Genera: > (divp 5 '(2 3)) NIL > (divp 6 '(2 3)) T What happens on microExplorer, but only when compiled: > (divp 5 '(2 3)) NIL > (divp 6 '(2 3)) NIL Anybody have any ideas? Am I overlooking something really obvious? What might I do to figure out how/why it's going wrong? ok bear. -- until further notice From brad at heeltoe.com Wed Oct 12 19:30:45 2016 From: brad at heeltoe.com (Brad Parker) Date: Wed, 12 Oct 2016 22:30:45 -0400 Subject: [LispM] odd Explorer behavior - interpreted vs. compiled In-Reply-To: <4F593985-CCDF-4ECF-BDDC-00C15C79C2CA@typewritten.org> References: <4F593985-CCDF-4ECF-BDDC-00C15C79C2CA@typewritten.org> Message-ID: On 10/12/16 9:42 PM, r.stricklin wrote: > Howdy, folks. > > I have an odd issue I'm at a loss to explain and lack insight re: where to start troubleshooting. > > I have a function which is meant to take a number and a list of numbers as arguments, and return T if the number is evenly divisible by any number in the list. Nil, if the number is not evenly divisible by any of the numbers in the list. > > (defun divp (n list) > (block nil (mapcar #'(lambda (p) > (cond ((zerop (mod n p)) (return T)))) list) > (return nil))) > > > This works exactly as I expect, whether compiled or interpreted, on Allegro CL and in Genera 8. On the microExplorer (Release 6.1 if it matters), it works exactly as I expect... until I compile it. Once it's compiled, it always returns nil. > If it were me, I'd disassemble the compiled function on genera 8 and the explorer. And, just for grins I'd disassemble it on the CADR as well. I would think the CADR compiler and the explorer compiler are pretty similar (I'd like to think they had common ancestry but I don't know how much LMI did before TI got to it) I guess it sounds like a bug to me. I would think the macro code would show it. The return inside the lambda might be an issue. I might fool around with the lambda to return a count or value instead of returning and see if that works when compiled. it does seem odd. -brad From bear at typewritten.org Wed Oct 12 19:52:36 2016 From: bear at typewritten.org (r.stricklin) Date: Wed, 12 Oct 2016 19:52:36 -0700 Subject: [LispM] odd Explorer behavior - interpreted vs. compiled In-Reply-To: References: <4F593985-CCDF-4ECF-BDDC-00C15C79C2CA@typewritten.org> Message-ID: On Oct 12, 2016, at 7:30 PM, Brad Parker wrote: > If it were me, I'd disassemble the compiled function on genera 8 and the explorer. And, just for grins I'd disassemble it on the CADR as well. I would think the CADR compiler and the explorer compiler are pretty similar (I'd like to think they had common ancestry but I don't know how much LMI did before TI got to it) It occurred to me to try the same on the Explorer. Now I have a half an answer. > (disassemble 'divp) 6 PUSH-LOC LOCAL|0 7 PUSH ARG|1 ; LIST 8 POP LOCAL|2 9 POP LOCAL|1 10 BR 28 ; here is the bug. 11 PUSH LOCAL|1 12 PUSH-CAR LOCAL|2 13 POP LOCAL|3 ; P 14 PUSH ARG|0 ; N 15 PUSH LOCAL|3 ; P 16 (MISC) PUSH FLOOR-2 [...] 26 (MISC) TEST RPLACD 27 SETE-CDR LOCAL|2 28 TEST LOCAL|2 29 BR-NOT-NULL 11 30 (AUX) RETURN-NIL DIVP > The weird thing is I can (uncompile 'divp) and it starts working again. I thought I saw something in the doc about providing optimization parameters to the compiler, but I can't find it now. ok bear. -- until further notice From bear at typewritten.org Wed Oct 12 20:00:27 2016 From: bear at typewritten.org (r.stricklin) Date: Wed, 12 Oct 2016 20:00:27 -0700 Subject: [LispM] odd Explorer behavior - interpreted vs. compiled In-Reply-To: References: <4F593985-CCDF-4ECF-BDDC-00C15C79C2CA@typewritten.org> Message-ID: <381EA3C7-13EB-4AC0-9D53-F17E462CC36F@typewritten.org> On Oct 12, 2016, at 7:52 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. ok bear. -- until further notice From bear at typewritten.org Wed Oct 12 22:09:16 2016 From: bear at typewritten.org (r.stricklin) Date: Wed, 12 Oct 2016 22:09:16 -0700 Subject: [LispM] odd Explorer behavior - interpreted vs. compiled In-Reply-To: <381EA3C7-13EB-4AC0-9D53-F17E462CC36F@typewritten.org> References: <4F593985-CCDF-4ECF-BDDC-00C15C79C2CA@typewritten.org> <381EA3C7-13EB-4AC0-9D53-F17E462CC36F@typewritten.org> Message-ID: <3791575A-6B0E-4FF9-8931-1BA2CF21B976@typewritten.org> 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 From ams at gnu.org Thu Oct 13 01:23:05 2016 From: ams at gnu.org (Alfred M. Szmidt) Date: Thu, 13 Oct 2016 04:23:05 -0400 Subject: [LispM] odd Explorer behavior - interpreted vs. compiled In-Reply-To: <3791575A-6B0E-4FF9-8931-1BA2CF21B976@typewritten.org> (bear@typewritten.org) References: <4F593985-CCDF-4ECF-BDDC-00C15C79C2CA@typewritten.org> <381EA3C7-13EB-4AC0-9D53-F17E462CC36F@typewritten.org> <3791575A-6B0E-4FF9-8931-1BA2CF21B976@typewritten.org> Message-ID: What happens with when block tag is NIL instead of DIVP? (DEFUN DIVP (N LIST) (BLOCK NIL (MAPCAR #'(LAMBDA (P) (COND ((ZEROP (MOD N P)) (RETURN-FROM NIL T)))) LIST) (RETURN-FROM NIL NIL))) > (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)))) You should be able to nuke the NIL block if you are doing RETURN-FROM to DIVP. From rwiker at gmail.com Thu Oct 13 01:33:36 2016 From: rwiker at gmail.com (Raymond Wiker) Date: Thu, 13 Oct 2016 10:33:36 +0200 Subject: [LispM] odd Explorer behavior - interpreted vs. compiled In-Reply-To: <3791575A-6B0E-4FF9-8931-1BA2CF21B976@typewritten.org> References: <4F593985-CCDF-4ECF-BDDC-00C15C79C2CA@typewritten.org> <381EA3C7-13EB-4AC0-9D53-F17E462CC36F@typewritten.org> <3791575A-6B0E-4FF9-8931-1BA2CF21B976@typewritten.org> Message-ID: Could it be that the compiler inserts a block named nil when it compiles the expression? On Thu, Oct 13, 2016 at 7:09 AM, r.stricklin wrote: > > 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 > > _______________________________________________ > LispM mailing list > LispM at tunes.org > http://lists.tunes.org/mailman/listinfo/lispm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fabrice.leal.ch at gmail.com Mon Oct 31 11:22:28 2016 From: fabrice.leal.ch at gmail.com (Fabrice Leal) Date: Mon, 31 Oct 2016 18:22:28 +0000 Subject: [LispM] LispM assembly reference? Message-ID: Was skimming this Lisp Machine manual ( http://bitsavers.trailing-edge.com/pdf/mit/cadr/chinual_3rdEd_Mar81.pdf) and fantasizing about making up some lisp-processor-like emulator. Does anybody have resources on the assembly language used by Lisp Machines (check chapter 27, page 432 of pdf) or the Ivory processors? I cant find a full reference online. --- Fabrice Leal -------------- next part -------------- An HTML attachment was scrubbed... URL: From steven.nunez at illation.com.hk Mon Oct 31 19:59:20 2016 From: steven.nunez at illation.com.hk (Steven Nunez) Date: Tue, 1 Nov 2016 10:59:20 +0800 Subject: [LispM] LispM assembly reference? In-Reply-To: References: Message-ID: <004a01d233eb$f2a0eed0$d7e2cc70$@illation.com.hk> You should look up the story of how Brad Parker built his emulator for the Ivory. From: LispM [mailto:lispm-bounces at tunes.org] On Behalf Of Fabrice Leal Sent: 1 November, 2016 02:22 To: lispm at tunes.org Subject: [LispM] LispM assembly reference? Was skimming this Lisp Machine manual (http://bitsavers.trailing-edge.com/pdf/mit/cadr/chinual_3rdEd_Mar81.pdf) and fantasizing about making up some lisp-processor-like emulator. Does anybody have resources on the assembly language used by Lisp Machines (check chapter 27, page 432 of pdf) or the Ivory processors? I cant find a full reference online. --- Fabrice Leal -------------- next part -------------- An HTML attachment was scrubbed... URL: