Author Topic: Lisp in Basic  (Read 192301 times)

0 Members and 1 Guest are viewing this topic.

Aurel

  • Guest
Lisp in Basic
« on: July 27, 2014, 08:31:36 AM »
F
« Last Edit: September 25, 2014, 01:57:37 AM by Aurel »

Charles Pegge

  • Guest
Re: Lisp in Basic
« Reply #1 on: July 27, 2014, 06:37:40 PM »
projectsA/LeanLisp/Lispish

quietly incubating :)

.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #2 on: July 27, 2014, 07:13:50 PM »
Time to open up Oxygen's own Lisp subforum and promote RobbeK to Chief Moderator. :)

Charles Pegge

  • Guest
Re: Lisp in Basic
« Reply #3 on: July 27, 2014, 07:47:25 PM »
Good!

I was going to say: there may be a problen with DEP (data execution prevention) under linux/wine. This applies to a few of the tests at the end of LispishTest2 involving o2 dynamic compiling.

Apart from those tests, this is fully interpreted code with optional tokenising of core functions, but no Data Execution.


LeanLisp is based on general LISP principles, as I understand them,  rather than any known LISP.
« Last Edit: July 27, 2014, 07:56:52 PM by Charles Pegge »

Charles Pegge

  • Guest
Re: Lisp in Basic
« Reply #4 on: July 27, 2014, 08:59:45 PM »
Maybe start with a system like one of those pre-pc home computers. Imagine one that has LISP as the resident language instead of BASIC.

Will need some core graphics functions to supplement console i/o.

RobbeK

  • Guest
Re: Lisp in Basic
« Reply #5 on: July 28, 2014, 01:06:18 AM »
Hi all,

There's a simple way to combine NewLisp and Basic (tB , GFA , FB , ....  ).
This has the advantage of using a full strength Basic and Lisp at the same time, and in this case (attached) also using Petr's excellent module (and if needed combine it with Oxygen !!!  ).
The program is just a start for something IMO interesting.  I used partly Lisp because i used 2 conditional mappings , as by the variadic nature of Lisp it has some function to test if the object is a symbol, a number , a list , a  ....   etc  , furthermore , mapping is an easy mechanism (as can be seen in the code , it will need some more code in an imperative, iterative way ...

(code is just the start of something,,   ...   )

best Rob

(source, bundle, dll in attachment)  -- use the arrow keys / Pg U/Dn for some animation
 addendum : l3D b.exe for the complete bundle (incl newlisp.dll)


.
« Last Edit: July 28, 2014, 01:41:56 AM by RobbeK »

RobbeK

  • Guest
Re: Lisp in Basic
« Reply #6 on: July 28, 2014, 02:02:57 AM »
Hi John,

Nothing standard in CL  (common Lisp)  ..  infact imho everything outside the ansi standard common lisp is somewhat of a disaster.  (it already starts with the FFI  (foreign function interface)  there's ffi , cffi , uffi ....  after a while one starts collecting dependencies an nothing (if working) is compatible any more ...   (I use Japi most of the time -- but some days ago I found serious problems to combine it with OpenGL , glu(t) .. though I could set up the callback functions for keyboard, mouse, joystick , idletime etc ...   
(I think the CLisp came with Texas Instrument graphics from the mid 1980's   ::)


best Rob

RobbeK

  • Guest
Re: Lisp in Basic ( 4 fun --- the truth about Lisp)
« Reply #7 on: July 28, 2014, 03:01:14 AM »
In which the truth about lisp is revealed :

Learning lisp will alter your life.

Your brain will grow bigger than you ever thought possible.

You will rewrite all of your applications in just a handful of lines

Society will shun you. You will shun society.

You will become disatisfied with everything and everyone around you.

Lisp is so simple to learn that you can learn lisp in just a few minutes. I just learnt it while I was waiting for a bus.

Lisp is so simple that you can implement it in any language in just a few pages of code. This might never happen though, because once you've learnt lisp you'd never want to write anything in any language other than lisp, so you wouldn't bother implementing lisp in any language other than lisp.

Lisp can be fully implemented in lisp in just a handful of lines. I just implemented lisp in lisp, fully, while i was hopping onto a bus and paying for my bus ticket all at the same time.

When you become a lisper, you will laugh at jokes that no one else thinks are funny. You will know things that cannot be expressed in ordinary imperative language.

You will think people are idiots when they state things like "Hi, how are you?" because a lisper simply doesn't need to use such verbose constructs. Lisp abstracts away those patterns of interaction and makes them completely irrelevant. The proper way to greet a fellow lisper is just a tiny nod of the chin, and about a tenth of a wink from your left eye, then point at your tin foil hat. They will know what you mean. if they don't know what you mean then they are not a true lisp programmer and they don't matter anyway.

Lisp was invented a long time ago, before java, before C, before fortran, before computers, before people, before the earth was built. the universe itself is a lisp program so trivial that no true lisper would even both implementing it.

Lisp is so elegant that the very fact that you know even the first thing about it will qualify you for a season as principal dancer of the royal ballet. You will go out on stage in your little tutu and just scribble a few round brackets in the air with your toe. People will gasp in wonder. Unless they don't know any lisp. If they don't know any lisp then they are idiots and they don't matter.

 8)

Charles Pegge

  • Guest
Re: Lisp in Basic
« Reply #8 on: July 28, 2014, 05:23:13 AM »
Hi Rob,

The first chapter is wonderfully inspiring, but it gets much more complex, and hard to follow  in later chapters.

http://www.gigamonkeys.com/book/

Lisp lacks the constructs needed for direct OS interfacing, but I agree with you that it has great potential when anchored to Basic.



RobbeK

  • Guest
Re: Lisp in Basic
« Reply #9 on: July 28, 2014, 07:18:38 AM »
Hi Charles,

@ the job, I had a book from Springer Verlag, that was (while this one is praised all over) more methodic and building things in smaller educational steps ..   afraid I lost it , but not sure (didn't use it in more than 12 yrs).

in the mean time , worked a little on previous sample

- added two mappings to center the image (lisp)
- moved the building of the matrix outside the main GL rendering  loop (it's calculated once now , and put in a GL List )     (TBGL)

it starts to look a little bit as something ...  6 iterations deep to start now --  U / D in the code stands fro up and down ...

best Rob

.

RobbeK

  • Guest
Re: Lisp in Basic
« Reply #10 on: July 28, 2014, 12:16:06 PM »
Hi John,

Always (when possible) with an editor using the/a REPL  -- on top the code , lower half an interactive area to test the definitions -- it's a kind of scratch area , you can test (or prototype definitions ) before saving the source.  It's very handy ..  LispWorks CL made name and fame when it was on board NASA's Deep Space One and was remotely reprogrammed.  It was not a stunt, but a necessity because the code onboard was buggy --  it was all done with the REPL (on the homebase) ,  taking definitions apart testing and debugging and re-injecting them.
After this (all in interpreted mode) Lisp has the possibility to compile definitions piece by piece.  When the interpreter encounters interpreted and compiled code, it will execute the compiled code ---  so you can mix both interpreted and compiled code, but in a way the compiling command can be inside the interpreter source. (though it can be done on the (lower) command window too for testing).  Compiling the complete source can be done both from inside the source or from the command window.   
Making stand-alone exec.'s is another difficulty in Lisp --  it just save the complete image (with heap , stack configurations and all) into a new Lisp image with a hook to the entry function of your code.   -- often for languages as Steel Bank CL upto 40 Mb.  (CLisp only needs around 5 Mb).
What I mentioned about the disastrous situation of certain packages is not correct for commercial products like LispWorks , Franz Lisp etc...   but paying £ 3000 as a hobbyist is something too expensive for me.  (their personal versions do work , they do compile .. but do not make executables , which infact is no problem if your correspondent has same installed -- however to be fair, I don't do such things ).

One that *is* free an has it all (and more), is Racket Scheme http://racket-lang.org/  -- I should use it more (it has a number theory module onboard , complex numbers , opengl , GNU plot , lazy and strict evaluation switch , runs perfect under Linux and Windows etc ...   the language goes that far, that inside the REPL drawing just can be copied and pasted (even on documents set up on DrRacket )  ...  but with its 1000s and 1000s definitions, I'm a little afraid of it ...

best Rob


JRS

  • Guest
Re: Lisp in Basic
« Reply #11 on: July 29, 2014, 08:12:18 PM »
FYI - The Script BASIC Lisp effort has been moved to the Script BASIC forum.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #12 on: July 30, 2014, 11:28:06 AM »
Hello Rob,

Can I have your expert opinion on the functionality of Charles' implementation of Lisp as compared to tradition? (I'm leaving arbitrary precision and similar extremes out of the scope of this question)

What else does it need structurally to become fully usable/competitive?

JRS

  • Guest
Re: Lisp in Basic
« Reply #13 on: July 30, 2014, 03:25:00 PM »
I would say that an interactive Lisp interpreter is must. There are a lot of Lisp interpreters and compilers out their and if one is to take competing in that realm seriously, it could be a project all on its own.

I was more interested in what it takes to convert a Quick BASIC program to Script BASIC and getting a Lisp interpreter out of the deal was icing.
« Last Edit: July 30, 2014, 05:54:21 PM by John »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #14 on: July 30, 2014, 11:50:51 PM »
Actually it won't take very long if one is aware that:

1. QB45 arrays are 1-based, not 0-based.

2.
Code: [Select]
FOR x = 0 TO maxheapsize
  heaptype[x] = 0
  heaptype[x,0] = 0
  heaptype[x,1] = 0
  heapvalue[x] = 0
  heapvalue[x,0] = 0
  heapvalue[x,1] = 0
NEXT x

is not the same as

Code: [Select]
FOR mem = 0 TO MAXHEAPSIZE
HEAPtype[mem,0]=0
HEAPtype[mem,1]=0
HEAPvalue[mem,0]=0
HEAPvalue[mem,1]=0
NEXT mem

3. ERR is a QB45 system error keyword and its value is specific to QB45 rather than SB; so ON ERROR GOTO HandleInternalError and the entire HandleInternalError: have no meaning in SB.

4.
Code: [Select]
DATA{"CONS"}=1
DATA{"CAR"}=2
DATA{"CDR"}=3

and

Code: [Select]
FOR p=0 TO UBOUND(DATA) STEP 2
  i$ = DATA[p]
  primnum = DATA[p+1]

which start at index 0 are not the same as

Code: [Select]
' [0,0]/[0,1] are dummy pair
Primitives[0,0]=""
Primitives[0,1]=0
Primitives[1,0]="CONS"
Primitives[1,1]=1
Primitives[2,0]="CAR"
Primitives[2,1]=2
Primitives[3,0]="CDR"
Primitives[3,1]=3

and

Code: [Select]
FOR prm=1 TO MAXPRIM
I=Primitives[prm,0]
PRIMNUM=Primitives[prm,1]

which start at index 1.

5. QB45's variables that appear only in GoSub/Return blocks have local scope unlike those in SB, therefore the "p" variables cannot appear in different GoSub/Return blocks or they will interfere with one another.

6. QB45's

Code: [Select]
ClearStackLoop:
    IF BSD% <> 0 THEN BSD% = BSD% - 1: RETURN ClearStackLoop
    GOTO LispReadEvalPrintLoop

does not mean

Code: [Select]
ClearStackLoop:
IF bsd<>0 THEN
   bsd=bsd-1
   REM RETURN ClearStackLoop
   RETURN
END IF
GOTO LispReadEvalPrintLoop

but rather

Code: [Select]
ClearStackLoop:
IF BSD<>0 THEN
BSD=BSD-1
GOTO ClearStackLoop
END IF
GOTO LispReadEvalPrintLoop

7.
Code: [Select]
  IF pvalue=38 THEN GOTO DoCos
  IF pvalue=38 THEN GOTO DoAtan
  IF pvalue=39 THEN GOTO DoGC
  IF pvalue=40 THEN GOTO DoEvl

will never allow one to do atan, or garbage collect, or evaluate anything, etc.



I don't promise all those evident fixups will reanimate SB Lisp at once and in full but they will surely allow one to at least enter, garbage collect, and exit gracefully. Yet I don't fully see how SB may benefit from such medieval sources.