Author Topic: Lisp in Basic  (Read 208328 times)

0 Members and 1 Guest are viewing this topic.

jack

  • Guest
Re: Lisp in Basic
« Reply #435 on: August 15, 2014, 08:55:41 AM »
thank you RobbeK :)

RobbeK

  • Guest
Re: Lisp in Basic
« Reply #436 on: August 15, 2014, 09:09:55 AM »
Mike ,   gazonk0.o  is  1308 bytes


best, Rob

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #437 on: August 15, 2014, 04:09:32 PM »
What does this new SBLisp structure do to our LISP in BASIC common effort ? Are you still sticking with the QB format?
We absolutely must find a way to formulate the remaining GoSub's as Subs even if it leads to duplicating some pieces of relevant GoTo code. Otherwise it will be impossible to use this code for either DynC or CBASIC that don't support labels which are accessible with both a call (=GoSub) and a jump (=GoTo) at the same time.

Quote
Code: [Select]
IF INSTR(" ()'", curchar) THEN GOTO CheckExistance
Shouldn't this be ...

Code: [Select]
IF INSTR(" ()'", curchar) <> undef THEN GOTO CheckExistance
Their SB logic in both cases evaluates to IF TRUE THEN GOTO (I tested and confirmed it) but if the second variant looks more natural to you, you can safely use it in your SBLisp code. I can read both notations equally fast and it doesn't distract or annoy me.

JRS

  • Guest
Re: Lisp in Basic
« Reply #438 on: August 15, 2014, 04:22:30 PM »
Quote
Their SB logic in both cases evaluates to IF TRUE THEN GOTO ...

I have had this bite me in the ass more times then I'm willing to say. We have already run into this in SBLisp where an undef result compare was needed. I have learned to keep an open eye for SB internal function undefs. The REF array swap you discovered was a great find!

Code: [Select]
GetNumber:
  total = VAL(curchar)
  BuildNumberLoop:
  IF decimalp THEN decimal += 1
  ipos += 1
  IF ipos > LEN(ibuf) THEN GOTO MakeNumber
  curchar = MID(ibuf, ipos, 1)
  IF curchar = "." THEN
    IF NOT decimalp THEN
      decimalp = TRUE
      GOTO BuildNumberLoop
    ELSE
      ipos = opos
      GetSymbol()
      RETURN
    END IF
  END IF
  IF curchar >= "0" AND curchar <= "9" THEN
    total = total * 10 + VAL(curchar)
    GOTO BuildNumberLoop
  END IF
  IF INSTR("()'", curchar) <> undef OR curchar <= " " THEN
  GOSUB MakeNumber
  RETURN
  END IF 
  ipos = opos
  GetSymbol()
  RETURN


Quote
We absolutely must find a way to formulate the remaining GoSub's as Subs even if it leads to duplicating some pieces of relevant GoTo code. Otherwise it will be impossible to use this code for either DynC or CBASIC that don't support labels which are accessible with both a call (=GoSub) and a jump (=GoTo) at the same time.

I agree but this was a good first step. Maybe making larger SUB/FUNCTION that encapsulates more common functionality.

Recommendations or code is always appreciated. I hope to get Arthur back on-board with this. We have exchanged a couple e-mails.
« Last Edit: August 15, 2014, 04:29:16 PM by John »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #439 on: August 15, 2014, 04:25:05 PM »
Mike ,   gazonk0.o  is  1308 bytes
Thanks Rob. With such a size, it looks like a program launcher only rather than the CL main code file.

OOps , Jack ...
seems I hit an iceberg
Yes Rob, your timing for the 10000th fibonumber also seems absolutely impossible to me. It takes 222 seconds for DynC to find the 52nd one and it would take years to find the 60th. 20 milliseconds are simply unrealistic.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #440 on: August 15, 2014, 04:37:19 PM »
We have already run into this in SBLisp where an undef result compare was needed.
Code: [Select]
IF INSTR("()'", curchar) <> undef OR curchar <= " " THEN
This is a trickier case with intermediate logical evaluation involved due to OR. Similar OR evaluations were also buggy in Charles' O2 until very recently when Ed's Toy interpreter started to function due to Charles having fixed up this very bug.

FBSL cracks all such logic very easily but I can maintain your style throughout the code for the sake of unification if you want me to. Absolutely NP with it here.

Quote
I agree but this was a good first step.
Sure and thanks for taking it. :)

Quote
I hope to get Arthur back on-board with this. We have exchanged a couple e-mails.
Was it Arthur who pointed you to ECL?

JRS

  • Guest
Re: Lisp in Basic
« Reply #441 on: August 15, 2014, 04:56:19 PM »
Quote
Was it Arthur who pointed you to ECL?

No. Google.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #442 on: August 15, 2014, 05:19:03 PM »
Quote
Maybe making larger SUB/FUNCTION that encapsulates more common functionality.
Do you think you could do it for the project? The proc size and code duplication would be no problem at this stage. Then it will be easier to spot the duplicates and reduce them to yet finer common Subs until eliminated entirely. There's almost no difference in the overhead of a jump or call in a variant-based interpreter so it shouldn't affect its execution speed noticeably. At the same time, it will enable us to later turn the Sub calls from the existing IF tree into a call table (computed gotos) for DynC, C, and O2. It could improve the speed of their machine-coded interpretation.

JRS

  • Guest
Re: Lisp in Basic
« Reply #443 on: August 15, 2014, 06:36:05 PM »
Quote
Do you think you could do it for the project?

I could try. It took me three times of abandoning this current effort before getting to where it is now. I was on the edge of saying this is a waste of time.

It would be nice to have a GOSUB diagram of what calls what. Is that something you could generate quickly?

I would like to see a real Scheme script run in S|FBLisp that actually does something useful. This would at least tell us if the syntax of the language works.
« Last Edit: August 15, 2014, 07:47:00 PM by John »

JRS

  • Guest
Re: Lisp in Basic
« Reply #444 on: August 15, 2014, 09:38:08 PM »
I thought I would kill two birds using Dave's IDE/Debugger to solve this GOSUB to SUB/FUNCTION phase. I discover a problem with it creating an exception error. Sent an e-mail off to Dave. Here is a helpful feature of the IDE I like. (see attached) All you have to do is select the text and it shows the instance count. (highlighting all occurrences)



.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #445 on: August 15, 2014, 09:43:08 PM »
... what calls what. Is that something you could generate quickly?
Hehe it would be a trivial task for a machine code executable and almost any decent disassembler out there would provide you with one in a few seconds. But it's impossible to have for an indie interpreter written in yet another interpreter. It would require a separate program and thorouh knowledge of the structure of both languages. :)

Quote
I would like to see a real Scheme script run in S|FBLisp that actually does something useful. This would at least tell us if the syntax of the language works.
There are hardly many useful app tasks that would fit into the Procrustean bed of XFLisp's current vocabulary. But looking for one might really trigger its development. (I'm still not able to make OxyLISP's evaluator work with anything other than numbers... :-\ )

P.S. I was talking about graphical or at least tabulated cross-references - usual practice in disassemblers and asm activity in general.

JRS

  • Guest
Re: Lisp in Basic
« Reply #446 on: August 15, 2014, 10:04:56 PM »
Quote
But it's impossible to have for an indie interpreter written in yet another interpreter. It would require a separate program and thorouh knowledge of the structure of both languages.

Using the SB IDE/Debugger will give me what I'm after.

If you can concentrate on XBLisp scripts that show what this thing is capable of, that would VERY helpful. Here is a start.  ;)

Code: [Select]
0](eq? (list 'a 'b) (list 'a 'b))
()
0](equal? (list 'a 'b) (list 'a 'b))
T
0](+ 4 (* 5 6))
34
0](define x 6)
X
0](+ (* 5 x x) (* 4 x) 3)
207
0](/ 21 5)
4.200000

JRS

  • Guest
Re: Lisp in Basic
« Reply #447 on: August 15, 2014, 10:27:54 PM »
This is how I'm dealing with GOSUBs that don't call anything other than the HandleError: routine.

Code: [Select]
FUNCTION PushStack
  stacktype[stkcursor] = ptype
  stackvalue[stkcursor] = pvalue
  stkcursor += 1
  IF stkcursor > maxstacksize THEN
    PRINT "ERROR: Stack overflow.\n"
    PushStack = FALSE
    EXIT FUNCTION
  ELSE
    PushStack = TRUE
  END IF
  bsd -= 1
END FUNCTION

...

IF NOT PushStack() THEN GOTO HandleError
« Last Edit: August 16, 2014, 12:32:24 AM by John »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #448 on: August 15, 2014, 10:53:20 PM »
This is how I'm dealing with GOSUBs that don't call anything other than the HandleError: routine.
That's OK for FBLisp too.

We need also to restore the former HandleInternalError: but in relation to the actual errors that file read may encounter today. The QB45 errors were mostly concerned with floppies while a modern handler should work for other disk drives like e.g. HDD where XBLisp is most probably going to read its files from.

Quote
show what this thing is capable of
Hehe so you want me to be doing it? But John, I'm a GUI guy, I don't really see why you are all so happy with this ugly black hole in your monitors. ;D

Quote
Code: [Select]
0](eq? (list 'a 'b) (list 'a 'b))
()
BTW this one seems to be correct as per the PDF but I can't quite see the reason why. And the PDF doesn't describe this case clear enough to catch the idea behind "however, lists may look similar, but not be identical"... ??? Is it because the one on the left is the first term in this evaluation while the one on the right is the second one? Mystery...

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #449 on: August 15, 2014, 11:01:21 PM »
Hello Rob,

Can you teach us why exactly this expression


Code: [Select]
(eq? (list 'a 'b) (list 'a 'b))
evaluates to FALSE?

Thank you!