Author Topic: Lisp in Basic  (Read 208320 times)

0 Members and 4 Guests are viewing this topic.

JRS

  • Guest
Re: Lisp in Basic
« Reply #645 on: August 21, 2014, 10:31:51 PM »
Quote
Can you give me a practical example of storing both integers and doubles in a common O2 array, and integers, doubles and strings in a variable called pvalue, without the need to maintain an auxilliary array that would concurrently store the values' data types, please?

Very good point Mike and something I don't appreciate enough in SB. I need to ask Peter Verhas how much QB influence his design standards.

To answer your question about SB able to deal with C strings (null terminated strings) the answer is yes. Be aware as Charles and I discovered you can't directly assign a SB string pointer. Peter's MyAlloc is in play by default and using the SB API is the best way to pass strings within the SB C ext. module.
« Last Edit: August 21, 2014, 10:44:22 PM by John »

Charles Pegge

  • Guest
Re: Lisp in Basic
« Reply #646 on: August 21, 2014, 10:39:59 PM »
In LeanLisp, I store all the variables and other entities as strings. Types are inferred during parsing, and value are transferred to the appropriate (strong) temp variables for processing.

I will try to conjure an example after my dawn siesta :)

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #647 on: August 21, 2014, 10:50:35 PM »
I will try to conjure an example after my dawn siesta :)

Please take your time, Charles, we aren't really in a hurry. :)

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #648 on: August 21, 2014, 10:57:29 PM »
Be aware as Charles and I discovered you can't directly assign a SB string pointer.

1. Can you get a pointer to anything in SB without Charles' extension module? I'm aware of ADDRESSOF and associated FUNCALL -- what about pointers to SB variables in general?

2. Is Charles' extension module a prerequisite for SB to be able to communicate with any other precompiled extension module e.g. graphics?
« Last Edit: August 21, 2014, 11:04:54 PM by Mike Lobanovsky »

JRS

  • Guest
Re: Lisp in Basic
« Reply #649 on: August 21, 2014, 11:30:11 PM »
Be aware as Charles and I discovered you can't directly assign a SB string pointer.

1. Can you get a pointer to anything in SB without Charles' extension module? I'm aware of ADDRESSOF and associated FUNCALL -- what about pointers to SB variables in general?

If all you need is a simple FFI use the DYC ext. module from SB. Charles's DLLC was to add IUP, multi-threading and COM to the mix.

Quote
2. Is Charles' extension module a prerequisite for SB to be able to communicate with any other precompiled extension module e.g. graphics?

SB already has ready to use ext. modules. SDL GFX done in C BASIC is a rather recent addition. 

A few examples

« Last Edit: August 21, 2014, 11:42:38 PM by John »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #650 on: August 21, 2014, 11:37:20 PM »
I haven't seen the FBSL version of the SBLisp project since the beginning. What is the current format? Does it look more like the original QB version or the SB version?

The FBSL version with GOSUB's de-interleaved is yet non-existent. An earlier version with <, >, /, - and ; fixed is available on the FBSL forum in this thread.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #651 on: August 21, 2014, 11:51:37 PM »
If all you need is a simple FFI use the DYC ext. module from SB.

Thank you. Does SB use the concept of pointers at all except in its ref variables and indirect function calls with FUNCALL? In other words, can you get a pointer to anything in SB with an operator and then do something useful with such a pointer further on in your code?

JRS

  • Guest
Re: Lisp in Basic
« Reply #652 on: August 22, 2014, 12:00:44 AM »
Okay. I pushed your source and Windows executable to the FBSL folder on Bitbucket. You have R/W access there so if you can maintain your FBSL version that would be great.

BTW: We can't use the .fbs attribute for FBSL source files. Bitbucket thinks that attribute is an image file. I changed it to .fbsl to get it to work.
« Last Edit: August 22, 2014, 12:38:41 AM by John »

JRS

  • Guest
Re: Lisp in Basic
« Reply #653 on: August 22, 2014, 12:07:03 AM »
Quote
Thank you. Does SB use the concept of pointers at all except in its ref variables and indirect function calls with FUNCALL? In other words, can you get a pointer to anything in SB with an operator and then do something useful with such a pointer further on in your code?

ADDRESS returns an internal SB serial number for the function which then can be used with other SB BASIC functions and passed as an argument for indirect calls from within the function. Argument count may vary and is available with besARGNR at the SB API level. The SB extension & embedding API is the only way to deal with the SB internals.

« Last Edit: August 22, 2014, 12:16:02 AM by John »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #654 on: August 22, 2014, 12:40:28 AM »
ADDRESS returns an internal SB serial number for the function which then can be used with other SB BASIC functions and passed as an argument for indirect calls from within the function. Argument count may vary and tested at the SB API level. The SB extension & embedding API is the only way to deal with the SB internals.

Thank you.

Okay. I pushed your source and Windows executable to the FBSL folder on Bitbucket.

This isn't "okay" with me. The FBSL version will stay where it belongs on the FBSL site. I have never expressed my volition or intention to become the maintainer of a ScriptBASIC repository or project or fork and especially under the banner of GNU GPL and/or its compatibles. I have my beliefs and attitudes that I will hardly change, and I will stay with MIT and BSD in the foreseeable future. The FBSL branch shall remain open source as it is now and this product shall never be included in the official FBSL distribution. It shall be freely downloadable under the original Creative Commons' from the FBSL site for as long as the latter exists on the net.

This is about all that I have to say on this subject. Now please undo.

Aurel

  • Guest
Re: Lisp in Basic
« Reply #655 on: August 22, 2014, 12:55:40 AM »
Mike
I would like to say that i prefer to believe in new languages like is PWCT than
in this hybrid basic-lisp.

JRS

  • Guest
Re: Lisp in Basic
« Reply #656 on: August 22, 2014, 01:03:34 AM »
Quote
Now please undo.

Removed.

Good-night.

RobbeK

  • Guest
Re: Lisp in Basic
« Reply #657 on: August 22, 2014, 01:54:12 AM »
Hi all,           recursion / iteration

First the definition of (nth i L)

(define nth
    (lambda (i L)
      ( if (= i 0) (car L)
           (nth (1- i) (cdr L)))))

which is perfectly symptomatic for this Lisp.
Historically imo Scheme was set up as a minimalistic Lisp , also proving that every situation can be solved with recursion - even today there are people promoting/advocating this (I'm not one of them).

the nth in natural language works like  (we're going to count 3rd slice .. of a bread
Mr Basic : 1 2 3
Mr Lisp : I take the first slice (car) and then I have the rest of my bread (cdr)
              I then take the first slice of the rest of my bread &
              then once again - now I have the 3rd slice ....

why this infantility , are they out of their mind doing this ???

infact not, because Lisp is variadic and typeless
Mr Basic can perfectly find the 4th house in a street very easily , the houses have the same size , he nows the start position and calculates the distance (offset) and he's there.

For Mr Lisp , things can be houses , streets , villages , cars ... there even may be an Aurel between them , he can not calculate the offset , he goes to the first and then there is a pointer to next -- to reach the fourth he has to travel through these 4 pointers. 
(reaching the last will take some time but a clever Mr Lisp  does   (car (reverse environment))    )

However, there is *no* need to follow such a mechanism when numbers are involved -- from there CL has arrays/vectors and they are easily assigned -- the elements are of a same type.

the solutions tried in Scheme are many, while (range i) still generates a list that is mapped (this happens in parallel , yet another problem ) , it also has (in-range i)  ..   but this sets up a stream (serial thus !!)  , because this happens in serial breaking conditions can be composed  , it even can do (in-naturals ) , containing all ! the natural numbers in a stream, the list assignments (naturals )  would take till the end of time to generate.
-Compiler technology   (the Austin-Kyoto compiler from the late Mr Schelter converts tail recursion in iteration ) -- and certainly the "Glorious Glasgow Haskell Compiler" does same and more.

This mechanism (even if an iterative operator is provided) is very frustating , it makes me write DLL's for CL , and make me ask question as to Mike about a verdict of sensibility of documentation.  In the Bigloo I use C-pointers to overcome these problems.

Only Mr Lütz Mueller from NewLisp boldly and bravely introduced
(address obj)  ---  the real memory address !!!!!!!!      GCL si::address gives a local Lisp address
(dup /char i)  --- allocates i bytes with the value of /char   p.e. /000 for the null character.

but in this Scheme, there is no single spark of any iterative construction I can use , expand ... if there were one, it would give me the feeling as when the sinking Das Boot hitting the bottom of the sea :
" Eine Schaufel Sand, der liebe Gott hat uns eine Schaufel Sand unter den Kiel geschmissen"

I found back my Lisp Book from Springer Verlag --  quoting it :  (about Recursion)
"Just because it is possible to push a pea up a mountain with your nose does not mean it is a sensible way"

The English name of the book is : "the art of Lisp programming"  -- maybe it is on-line somewhere.
(in the meantime I found next :
    http://www.moz.ac.at/sem/lehre/lib/bib/software/cm/Notes_from_the_Metalevel/index.html   ... seems very good !! )
(for the music lovers ---  who isn't ??)

best Rob

(addendum , just had a look at the forum linked by Aurel, one of his statements is that Lisp is not capable of even being a hobbyist programming language  -- therefor I add something written in Lisp in less than 20 ' )











.
« Last Edit: August 22, 2014, 02:45:18 AM by RobbeK »

Charles Pegge

  • Guest
Re: Lisp in Basic
« Reply #658 on: August 22, 2014, 03:02:23 AM »
Mike,

This example indicates what is possible with o2 autoconversion, instead of using explicit conversion, or variants.

Code: [Select]
'AUTOCONVERSION


string s[100]
double d1,d2,d3

'no conversion needed

s[1]=4.25
s[2]=1.25
s[3]="10"

'transfer to doubles for direct arith expression
================================================

d1=s[1]
d2=s[2]
d3=s[3]

s[4]="Total: "+d1+d2+d3

print s[4] 'Total 15.5

'using autoconversion in function parameters
============================================

function sum(optional double n1,n2,n3,n4) as double
return n1+n2+n3+n4
end function

s[4]=sum s[1],s[2],s[3]
print s[4] '15.5


John,
Yes, I remember the tussle we had with passing char* params directly. It required the pointer to be created by SB - It wasn't a true char*. there were hidden attributes on the SB side.


Aurel,
Re: PWCT: th power is in the IDE, I think.


Rob,
Good Lisp reference.
Also:
Quote
"Just because it is possible to push a pea up a mountain with your nose does not mean it is a sensible way"
;D
« Last Edit: August 22, 2014, 03:12:20 AM by Charles Pegge »

Aurel

  • Guest
Re: Lisp in Basic
« Reply #659 on: August 22, 2014, 03:20:23 AM »
Quote
Aurel,
Re: PWCT: th power is in the IDE, I think.

No Charles
This is something like new paradigma
Programming Witout Coding Technologie