Author Topic: Lisp in Basic  (Read 208106 times)

0 Members and 4 Guests are viewing this topic.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #150 on: August 04, 2014, 01:51:27 PM »
LOL is that a kind way to shut me up?! I'm *terribly* susceptible to such things! I would've been sleeping in a few more seconds hadn't I shut that page NOW!

;D

Aurel

  • Guest
Re: Lisp in Basic
« Reply #151 on: August 04, 2014, 01:52:56 PM »
Quote
No Aurel

No Mike
You are not JRS...you are not LIAR and you are very open in any discusion
BUT your friend J ...come on  ::)

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #152 on: August 04, 2014, 01:55:01 PM »
OK Charles,

I beg your pardon. Matter was I'd just come from Facebook and I couldn't switch over to a different manner of conversation. I'm sorry.

I'm shutting up. :)

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #153 on: August 04, 2014, 01:59:18 PM »
Quote
No Aurel
No Mike
You are not JRS...you are not LIAR

Come on Aurel, let's try to be constructive and positive for a change. And let bygones be bygones (look it up in Google Translator, please). We're not home in the kitchen. We are out in the public chez Charles.

We have personal messaging if we want to be rude, and we can even sometimes *delete our messages* when we realise we might've been just a little too tough on one another. :)

Charles Pegge

  • Guest
Re: Lisp in Basic
« Reply #154 on: August 04, 2014, 02:05:15 PM »



Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #155 on: August 04, 2014, 02:14:26 PM »
LOL exactly! :) Big up, as they say on FB! :)

JRS

  • Guest
Re: Lisp in Basic
« Reply #156 on: August 04, 2014, 03:13:41 PM »
I posted to Bitbucket a beta version of SBLisp.

Scheme Basics

@Rob - If you have time to do a little beta testing that would be great.

Code: [Select]
jrs@laptop:~/sb/sb22/sblisp$ scriba lisp.sb
Initializing Memory...
Initializing Lisp Environment...
LISP in BASIC v1.3 by Arthur Nunes-Harwitt
0](define factorial (lambda (n)
2](if (<= n 0)
3]1
3](* n (factorial (- n 1)))))))
FACTORIAL
0](factorial 8)
40320
0](quit)
Bye!
jrs@laptop:~/sb/sb22/sblisp$
« Last Edit: August 04, 2014, 05:04:14 PM by John »

JRS

  • Guest
Re: Lisp in Basic
« Reply #157 on: August 04, 2014, 04:22:39 PM »
Mike,

I thought that you were going to use the SB FIX() function for DoFlr (Floor)

Code: [Select]
DoFlr:
  ptype = qtype
  pvalue = qvalue
  bsd += 1
  GOSUB Car
  IF rtype = number THEN
    rvalue = INT(rvalue)
    bsd -= 1
    RETURN
  END IF
  PRINT "ERROR: In FLOOR\n"
  GOTO HandleError

Scheme vs. Common Lisp
Code: [Select]
What Common Lisp has got:         What Scheme has got:

Much better developed standard    SLIB + SRFI's + a hundred little
libraries                         libs that each do things differently
                                  and aren't very standardized.

   (Arguably Scheme is the place where new ideas fight for mindshare
    and prove themselves - but the fights and the multiplicity
    of contenders commits most code to one idea or another and
    limits the code's interoperability, longevity, and/or
    portability.)


A well-defined comprehensive      A well-defined minimal spec plus
spec and several implementations  dozens of variously comprehensive
which provide some extensions.    implementations. 

Escaping continuations only.      Fully reentrant continuations.
                                  Scheme just wins on this point.

   (I have heard the arguments about whether fully reentrant
    continuations are worth the cost of stack copying, or the
    cost of heap-allocating and garbage collecting invocation
    frames.  I don't care.  I'm just noting here that you can
    do a *LOT* of things with them that are hard to do without
    them.)

Lots of iterative constructs      Memory-safe tail recursion avoids
                                  the need for iteration syntax. 
                                  There's a looping construct, but
                                  it's more complicated than tail
                                  recursion so hardly anyone uses it.
                                  If you care for them, you can
                                  roll your own using continuations.

Both Lexically and Dynamically    Lexical scope only, per the standard.
scoped special vars.  Common      Dynamically scoped vars are provided
Lisp just wins on this point.     by some implementations as an extension
                                  but code using them is not portable.

     (I have heard the arguments about whether Dynamic scoping
      is or is not a Bad Idea in the first place.  I don't care.
      I'm just noting that you can do things with it that you
      can't easily do without it.)


C numeric types plus bignums      Implementation-defined numeric types,
and complex nums, but no exact/   in some implementations failing to
inexact distinction.              include bignums or complex nums.  An
                                  exact/inexact distinction is required
                                  by the standard but properly implemented
                                  in only about 3/4 of scheme systems.
                                  In a good implementation, numerics
                                  (capabilities and correctness) are
                                  better than most CLs; on average,
                                  they are worse.

Optional type declarations        Optional type declarations provided
allow blazing fast numeric        by a few implementations as extensions.
code to skip typechecking.        Code using them is nonportable.  Some
Common Lisp just wins on numeric  implementations provide blazing speed
calculation speed.                but generally at the expense of numeric
                                  type richness and/or standard
                                  conformance.

Signals and conditions, catch     Roll your own using fully reentrant
and throw.                        continuations, or use any of several
                                  libraries.

CLOS                              Roll your own objects using closures
                                  and macros, or any of several OO
                                  libraries. TinyCLOS and Meroon are
                                  the most popular.

Well-defined standard module      At least three competing well-defined
system.  Common Lisp just wins    module systems which it's a pain in
on this point.                    the butt to move modules between.
                                  (or roll your own using scope, macros,
                                  and/or preprocessing code).

Readtables for low-level          Implementation-defined means of doing
macrology. Common Lisp wins       low-level macrology - none of it
here.                             portable.

gensym tricks to avoid implicit   hygienic macros with define-syntax and
variable captures in high-level   syntax-case.  You *can't* capture a
macros.                           variable in a macro except explicitly.

    (Different people claim this as a "win" for both languages.
     I don't care.  There is little difference in what I can do
     with it, nor in how hard it is to do it, so I'm not the guy
     to judge a winner here.)

One-argument eval assumes         environment specifier is second arg to
environment                       eval, allowing access to multiple
                                  environments.  Scheme just wins here.

Lambda syntax supports keyword    Available as add-on library developed
arguments & default vals for      using macros, but widely ignored.
optional arguments.

Symbols have properties,          Variables have values and also names.
including but not limited to      The names are lexically indistinguishable
function value and data value.    from symbols but the value of a variable
                                  is not a property of its name symbol. 
                                  Property lists are an extension
                                  provided by relatively few schemes.

Native hash tables.               Library hash tables.

Well-defined means of doing       A fragile hack that depends on common
binary I/O.  Common Lisp just     character encodings and/or assumption
wins here.                        that character ports act as byte ports.


Assertions.  Common Lisp just     In scheme you have to do this as two
wins here.                        macros; one for development, that signals
                                  an error if the condition isn't true, and
                                  one for production code which "expands"
                                  into nothing and gets out of the way.
                                  The compiler will not use your assertions
                                  to produce better code.


Large runtime environment         Small runtime environment, easily
                                  embeddable.  Scheme wins here.

Based on the above it seems that Scheme was the better choice to build on top of SB. Maybe the deficiencies in Scheme can be compensated for by SB in a seamless way.
« Last Edit: August 04, 2014, 04:59:04 PM by John »

JRS

  • Guest
Re: Lisp in Basic
« Reply #158 on: August 04, 2014, 05:33:32 PM »
In my search to find the gold standard of Scheme interpreters, I kept running into MIT/GNU Scheme. I downloaded the Unix 64 bit source and built it from scratch.

Code: [Select]
jrs@laptop:~$ 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 ]=> (define factorial (lambda (n)
(if (<= n 0)
1
(* n (factorial (- n 1)))))))

;Value: factorial

1 ]=> (factorial 8)

;Value: 40320

1 ]=> (quit)

[1]+  Stopped                 mit-scheme
jrs@laptop:~$



Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #159 on: August 04, 2014, 05:40:20 PM »
John,

1. Following a discussion with Rob much earlier in this thread (I think you were still having you rest then) and also based on some Lisp math specs he cited there, Lisp's concept of floor() and ceil() doesn't obey C, C++, C#, SB, FBSL, etc. rules of numeric rounding. So the L-i-B author was correct in choosing INT() for DoFlr which is the closest approximation that a BASIC can get. Lisp's floor() always rounds down to negative infinity - something which isn't available in SB or FBSL (or in C they are both written in, for that matter).

So I removed Floor() from the FBSL version too for the same reason.

2. Is the table your own investigation or someone else's?

3. Nice! Now you have a test bench to verify SBLisp against.


P.S. John, I'm getting off the air for tonight now if you don't mind. If you have any comments or questions, please post them here and I'll come back with my answers tomorrow morning (local time). See you tomorrow.

« Last Edit: August 04, 2014, 05:54:40 PM by Mike Lobanovsky »

JRS

  • Guest
Re: Lisp in Basic
« Reply #160 on: August 04, 2014, 05:52:50 PM »
Quote
. Is the table your own investigation or someone else's?

Please, I can hardly spell Lisp;D

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #161 on: August 04, 2014, 05:57:13 PM »
I can't either (too sleepy). :)


JRS

  • Guest
Re: Lisp in Basic
« Reply #162 on: August 04, 2014, 09:33:29 PM »
I don't think file loading is working.

(load "myfunc.scm")

One thing I found is the filename is being UCASE() which needs to be addressed but that doesn't account for rhe bad symbol error message. It never gets to the SB OPEN statement.

Attached is a screen shot of debugging this with the new SB IDE/Debugger.


.
« Last Edit: August 04, 2014, 11:56:21 PM by John »

RobbeK

  • Guest
Re: Lisp in Basic
« Reply #163 on: August 05, 2014, 01:15:54 AM »
@ John

I'll try to run some things from your app. 

As for the Japi --  no news, no answers , the complete NIHIL from the Java front ...

As for Scheme ,  next may be worth a look ,  I know it runs those Fu-script in the GIMP graph. editor (and does a good job).
http://tinyscheme.sourceforge.net/home.html
(no experience with it though)

@Mike,

Seems Belarussian solved the problem of the intonations on the "o" (compared with Russian)  ..  so guessing "milk" in belarus 2 "a"s and one "o" ??

best Rob

Addendum  -- to list or not to list ??
--------------------------------------------

attached :  Lisp working with a list and doing the same with 2 variables ( my idea : if you want Lisp give the speed of C , it looks (with other syntax and "nomenclature") likes C    :-\ )

(done in interpreted GNU CL  -- a fork from Kyoto Common Lisp )  -- when compiled both give 0 mSec ..
it then generates a gazonk - file ???    Mike , any one else what is a gazonk ???   )




.
« Last Edit: August 05, 2014, 03:05:22 AM by RobbeK »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #164 on: August 05, 2014, 06:05:03 AM »
Hi John,

Sure it doesn't. Please do the following:

-- goto line 101 in lisp.sb and change "QUOTES" to "QUOTE" (that's a typo after my autoreplacement of QUOTE for QUOTES because Quote() is an FBSL intrinsic function);
-- create a file "fact.lisp" with the following contents (it should also include the "function" call proper for it to be executed rather than typed in as in an interactive mode):
Code: [Select]
(define factorial (lambda (n)
(if (<= n 0)
1
(* n (factorial (- n 1)))))))

(factorial 8)
-- do not use (load "fact.lisp") - this isn't a proper syntax for Lisp. You should use (load (quote fact.lisp)) instead.

The file will load in both FBSL and SB:

-- FBSL prints the entire file, executes the "function" call, and prints out the result and a "T" symbol (=TRUE in Lisp) that signifies successful comletion of the task (see the appended screenshot 1).

-- SB would however print the first line only and then break on a file read error (see screenshot 2).

I don't know the exact cause of the error; perhaps your SB syntax for sequential line read from a text file isn't correct. Please try and fix it yourself. FBSL uses a word-for-word translation of both QB45 and SB syntax but with its own keywords, which means the algo as a whole is correct.

[EDIT] Goto line 693 in lisp.sb and change the If block that you'll find there, to the code below. It'll fix your read/execute problems:

Code: [Select]
IF NOT EOF(LispFileNum) THEN
LINE INPUT# LispFileNum, I
I = CHOMP(I)
PRINT I, "\n"
IPOS = 1
END IF

.
« Last Edit: August 05, 2014, 07:52:33 AM by Mike Lobanovsky »