Author Topic: Lisp in Basic  (Read 208231 times)

0 Members and 3 Guests are viewing this topic.

JRS

  • Guest
Re: Lisp in Basic
« Reply #330 on: August 10, 2014, 06:15:09 PM »
Mike,

I have been doing more testing of SBLisp and ran into another issue. Personally I would like to see F rather than () for false.

SBLisp
Code: [Select]
0](< 2 3)
()

mit-scheme
Code: [Select]
1 ]=> (< 2 3)

;Value: #t

Interesting that this does work.
Code: [Select]
0](<= 2 3)
T
« Last Edit: August 10, 2014, 06:50:55 PM by John »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #331 on: August 10, 2014, 06:57:01 PM »
Are you saying that FBSL is now you're baby? (single developer effort)

Never mind, John. It was meant to convey a shade of pique.

No, we are a team to the end of FBSL time. We are all human and it's just that everyone has their own rises and pitfalls from time to time. We shall overcome.

Mike,

Personally I would like to see F rather than () for false.

I might cure your pain, John, well, some day. Hence the definite article.

Hehe, and a coup de grace:

.

JRS

  • Guest
Re: Lisp in Basic
« Reply #332 on: August 10, 2014, 07:09:49 PM »
Outstanding!

Another member of the Lisp in BASIC family.  :)

P.S. Not to underscore Charles's LeanLisp efforts.

JRS

  • Guest
Re: Lisp in Basic
« Reply #333 on: August 10, 2014, 07:49:38 PM »
The greater than doesn't work either.  :-\

SBLisp
Code: [Select]
0](> 2 1)
()
0]

mit-scheme
Code: [Select]
1 ]=> (> 2 1)

;Value: #t

1 ]=>

JRS

  • Guest
Re: Lisp in Basic
« Reply #334 on: August 10, 2014, 08:10:24 PM »
I fixed it. The compares were reversed.

Code: [Select]
jrs@laptop:~/sb/sb22/sblisp$ scriba lisp.sb
SBLisp - Scheme BASIC Lisp

0](< 2 3)
T
0](> 2 1)
T
0](quit)
Bye!
jrs@laptop:~/sb/sb22/sblisp$

I also fixed the ATAN function. The ATN keyword is reserved but not implemented in SB. I replaced it with ATAN which is one of the new math functions Tom added for the SB 2.2 release.

Code: [Select]
0](atan 1)
0.785398
0]

Changes

3010  IF pvalue < qvalue THEN

3044  IF pvalue > qvalue THEN

3203    rvalue = ATAN(rvalue)

Fixed code pushed to Bitbucket.

I have gone through the complete Lisp in BASIC documentation trying the examples presented. Everything seems to work at this point from what I can tell.

« Last Edit: August 10, 2014, 11:11:54 PM by John »

JRS

  • Guest
Re: Lisp in Basic
« Reply #335 on: August 10, 2014, 10:03:24 PM »
I went ahead an did the conversion of the heaptype and heapvalue arrays. I have to say that the difference with Mike's benchmark is amazing and I have a heap of 400000 and stack of 200000 before garbage collection is being done. I'm happy! (12 minutes to 10 seconds)  8)

Code: [Select]
9998
9999
10000
10001
()
(quit)
Bye!

real 0m10.187s
user 0m9.641s
sys 0m0.468s
jrs@laptop:~/sb/sb22/sblisp$

Old Method
Code: [Select]
9997
9998
9999
10000
10001
()
(quit)
Bye!

real 11m58.927s
user 10m57.221s
sys 1m0.044s
jrs@laptop:~/sb/sb22/sblisp$

Attached is the FBSL version of this.


.
« Last Edit: August 10, 2014, 11:06:12 PM by John »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #336 on: August 11, 2014, 04:01:37 AM »
Hi John,

It is very strange to see the < and > bugs survive because they were fixed as early as on August 7. You can see it by the date of this message on the FBSL forum. Perhaps something went wrong that night when we were pushing the code up and down the repo prior to working out a common plan.

Thanks for the ATAN fix. It slipped me 'cause of SB not barking up the ATN tree.

1. Now I'll be dowloading your code from the repo; I want to see how you split the arrays. I'm glad it works but for the sake of maximum unification I suggest doing it my way because I did it for SB, FBSL and O2 already.

2. We have yet to see a case where garbage collection interferes with calc speed, functionality, or precision. So my suggestion is to subside to 20 000 for the heap, and 10 000, for the stack, in all the 3 languages. Under these conditions, the recursive stress test runs in 8 sec for SB, 9 sec for FBSL, and X millisec for O2 (still crashes, in fact). The memory footprints at these settings are also very similar between SB and FBSL.

Please give me an explicit answer if you (dis)agree with these two propositions.

I'll be working to fix OxyLISP to full usability today and see how it behaves under this stress test. Once through with it, we'll discuss where to go further.

JRS

  • Guest
Re: Lisp in Basic
« Reply #337 on: August 11, 2014, 06:52:02 AM »
I haven't seen your way of splitting the array yet so I hope you are good with the way I did it for SBLisp.

I'll change the max setting per your suggestion.

Have you run any test with what I posted?

Code: [Select]
1092
1093
1094
1095
1096
GC start A broken heart.

real 0m1.289s
user 0m1.132s
sys 0m0.036s
jrs@laptop:~/sb/sb22/sblisp$

Seems I broke something with GC in the array conversion. (using the new heap and stack max values)
« Last Edit: August 11, 2014, 07:17:25 AM by John »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #338 on: August 11, 2014, 07:25:57 AM »
I am good with anything that works. But what about the code consistency? It'd be easier for me to maintain three versions at once.

Alternatively, I can suggest my working with the SB code the way I please and uploading my developments here from time to time for you to decide what is good and/or fit for the repo version that you're maintaining.

No, I haven't yet touched the SB code today except for fixing the bugs you mentioned above, in my local copy. I'm all into galvanizing OxyLISP. This strict data typification is driving me mad. I can't get floating-point math to work yet. Matter is rvalue, pvalue, etc. are reusable in QB, SB, and FBSL for all sorts of calc but it can't be mimiced easily in O2 where typification either rounds everything to integers or unrolls it to doubles... >:(

Here's my latest lisp.sb. But be careful -- it may be non-conformant with your formating specs.

.

JRS

  • Guest
Re: Lisp in Basic
« Reply #339 on: August 11, 2014, 08:09:36 AM »
Mike,

Your version of SBLisp works and gives better numbers to boot. I'm good with your version for SBLisp. I will do a little testing and push it to Bitbucket.

Code: [Select]
9997
9998
9999
10000
10001
()
(quit)
Bye!

real 0m9.455s
user 0m9.133s
sys 0m0.252s
jrs@laptop:~/sb/sb22/sblisp$

JRS

  • Guest
Re: Lisp in Basic
« Reply #340 on: August 11, 2014, 08:50:44 AM »
Mike,

I have pushed your slightly cleaned up version of SBLisp to Bitbucket.  I'm calling this the MASTER at this point.


Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #341 on: August 11, 2014, 09:19:18 AM »
Thanks, John.

Faster boot is due to heap/stack sizes set to 20000/10000. SPLITA() takes its toll on large arrays too though it works really much faster than FOR/NEXT. I wasn't able to find an alternative way to do anything with the arrays.

Also, it looks like the internal representation of an array element in SB is rather memory consuming. Setting the max heap size to 4M would produce a 250MB array in SB against some 80MB in FBSL. It would also render the boot time intolerably long. So I confined the max sizes to 20000/10000 in all languages and let CG do its work whenever necessary, which made them boot almost equally fast subjectively.

I suggest we postpone further recursion depth investigations till we come across a case when it really matters to the viability of an actual LISP application.
« Last Edit: August 11, 2014, 09:39:16 AM by Mike Lobanovsky »

JRS

  • Guest
Re: Lisp in Basic
« Reply #342 on: August 11, 2014, 09:39:08 AM »
Great job by the way. You're definitely a PRO!!!

I will try to find some Scheme based Lisp examples to try and see if I can break SBLisp.


JRS

  • Guest
Re: Lisp in Basic
« Reply #343 on: August 11, 2014, 10:20:00 AM »
@Mike - Can you have a quick peek at this an let me know what might be causing the read error?

Quote
The purpose of the following function is to help balance a checkbook. The function prompts the user for an initial balance. Then it enters the loop in which it requests a number from the user, subtracts it from the current balance, and keeps track of the new balance. Deposits are entered by inputting a negative number. Entering zero (0) causes the procedure to terminate and print the final balance.

Code: [Select]
(define checkbook (lambda ()

; This check book balancing program was written to illustrate
; i/o in Scheme. It uses the purely functional part of Scheme.

        ; These definitions are local to checkbook
        (letrec

            ; These strings are used as prompts

           ((IB "Enter initial balance: ")
            (AT "Enter transaction (- for withdrawal): ")
            (FB "Your final balance is: ")

            ; This function displays a prompt then returns
            ; a value read.

            (prompt-read (lambda (Prompt)

                  (display Prompt)
                  (read)))

            ; This function recursively computes the new
            ; balance given an initial balance init and
            ; a new value t.  Termination occurs when the
            ; new value is 0.

            (newbal (lambda (Init t)
                  (if (= t 0)
                      (list FB Init)
                      (transaction (+ Init t)))))

            ; This function prompts for and reads the next
            ; transaction and passes the information to newbal

            (transaction (lambda (Init)
                      (newbal Init (prompt-read AT)))))

; This is the body of checkbook;  it prompts for the
; starting balance

  (transaction (prompt-read IB)))))

Output
Code: [Select]
jrs@laptop:~/sb/sb22/sblisp$ scriba lisp.sb
SBLisp - Scheme BASIC Lisp

0](load 'ckbook.scm)
(define checkbook (lambda ()
        (letrec
           ((IB "Enter initial balance: ")
            (AT "Enter transaction (- for withdrawal): ")
            (FB "Your final balance is: ")
            (prompt-read (lambda (Prompt)
                  (display Prompt)
                  (read)))
            (newbal (lambda (Init t)
                  (if (= t 0)
                      (list FB Init)
                      (transaction (+ Init t)))))
            (transaction (lambda (Init)
                      (newbal Init (prompt-read AT)))))
  (transaction (prompt-read IB)))))
CHECKBOOK
 
ERROR: Read.
ERROR: Problem in file ckbook.scm
0]
 

My guess. transaction isn't a SBLisp symbol. :-(

mit-scheme
Code: [Select]
jrs@laptop:~/sb/sb22/sblisp$ mit-scheme
MIT/GNU Scheme running under GNU/Linux
Type `^C' (control-C) followed by `H' to obtain information about interrupts.

Copyright (C) 2014 Massachusetts Institute of Technology
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Image saved on Saturday May 17, 2014 at 2:39:25 AM
  Release 9.2 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118 || Edwin 3.116

1 ]=> (load 'ckbook.scm)

;The object ckbook.scm, passed as an argument to merge-pathnames, is not a pathname.
;To continue, call RESTART with an option number:
; (RESTART 1) => Return to read-eval-print level 1.

2 error> (load "ckbook.scm")

;Loading "ckbook.scm"... done
;Value: checkbook

2 error>


« Last Edit: August 11, 2014, 10:50:38 AM by John »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #344 on: August 11, 2014, 10:53:45 AM »
There ain't no such command as (letrec) in SBLisp. According to the PDF, there are only (let) and (let!) in its vocabulary. This code needs rework based on what (letrec) actually does in the dialect this app was originally written in.

It also uses other non-existent commands, e.g. (display) which is actually (print) in SBLisp and its siblings.

SBLisp is currently rather limited in its functionality. I think the only problems it can theoretically solve would be the simpler tasks published at the Rosetta Code site I pointed you to earlier in this thread. And even those would require rework to fix up (define ... (lambda ...)) declarations and (print) statements. There's no explicit functionality either for interactive input similar to (read) in your alien LISP code.
« Last Edit: August 11, 2014, 11:06:47 AM by Mike Lobanovsky »