Author Topic: Lisp in Basic  (Read 208468 times)

0 Members and 5 Guests are viewing this topic.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #1020 on: April 18, 2015, 06:53:47 PM »
You know I hate the console with all my heart, and FBSL v1 was originally built to escape from the Windows batch processor. I'm afraid I can't be of much help to you with this, especially on Linux. :)

Just in case, I'd like to point out again that TinyScheme is equipped with its own Scheme-to-dynamic-library interface (referenced as "dl"/"dynload" in the sources). I guess it extends to Linux too. So, TinyScheme can address 3rd party DLLs/SOs directly from Scheme code without any additional intermediation. Perhaps this can stimulate your imagination towards some scenarios that haven't yet been considered.

JRS

  • Guest
Re: Lisp in Basic
« Reply #1021 on: April 18, 2015, 06:59:54 PM »
Quote
Perhaps this can stimulate your imagination towards some scenarios that haven't yet been considered.

Like a Linux version of Script BASIC DYC or DLLC would be nice. I think I have the SQLite TinyScheme extension module working in this manor.

I'm also wondering what Perl may offer in this area. As AIR mention on the old BP.org site, Perl has an extensive 3rd party extension library. Just USE.

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #1022 on: April 18, 2015, 07:24:15 PM »
It's difficult for me to talk in terms of SQLite or Linux system libraries, but under Windows, it could mean, for example, writing an .scm library that would interface with user32.dll, gdi32.dll and opengl32.dll APIs, define a set of high-level macros and procedures on top of them, and using this library as an OpenGL-capable windowed GUI with standard forms, controls, dialogs and what not instead of that crooked Java trash Rob was polluting our gear with. :D

Tell you more, single-threaded nanoscheme/OxyScheme are my minimal extensions to the Public Domain code that was used to develop multi-threaded TinyScheme as we see it now. In fact there's very little difference between the two if we put aside the common access conflict prevention trickery that TinyScheme is full of. Theoretically there's nothing that can basically interfere if we choose to expand the nanoscheme/OxyScheme project into a full-blown microscheme/PeroxyScheme multi-threaded monster based off of TinyScheme sources. :)

JRS

  • Guest
Re: Lisp in Basic
« Reply #1023 on: April 18, 2015, 07:54:55 PM »
Quote
It's difficult for me to talk in terms of SQLite or Linux system libraries, but under Windows, it could mean, for example, writing an .scm library that would interface with user32.dll, gdi32.dll and opengl32.dll APIs, define a set of high-level macros and procedures on top of them, and using this library as an OpenGL-capable windowed GUI with standard forms, controls, dialogs and what not instead of that crooked Java trash Rob was polluting our gear with.

Could you post a simple example of the TinyScheme FFI calling a Windows message box as a .scm?

Code: Script BASIC
  1. INCLUDE dyc.bas
  2.  
  3. a$ = "message text" & CHR(0)
  4. PRINT dyc::dyc("ms,i,USER32.DLL,MessageBox,PZZL",0,a$,"title",3)
  5.  

FYI

Here is the Script BASIC sbhttpd server running the CGI echo example on Koding.com.
« Last Edit: April 18, 2015, 08:32:10 PM by John »

JRS

  • Guest
Re: Lisp in Basic
« Reply #1024 on: April 18, 2015, 09:47:03 PM »
Here is the TinyScheme Prime Number example that Mike wrote running under sbhttpd.

http://scriptbasic.koding.io/home/webscheme

Code: Script BASIC
  1. IMPORT cgi.bas
  2. IMPORT ts.inc
  3.  
  4. OPTION cgi$Method cgi::GET
  5. cgi::Header 200,"text/html"
  6.  
  7. sc = TS_New()
  8. TS_Cmd sc, "(load \"/home/scriptbasic/sbweb/init.scm\")"
  9. ts_src = """
  10. (define (prime? n)
  11.  (if (< n 4) (> n 1)
  12.      (and (odd? n)
  13.           (let loop ((k 3))
  14.             (or (> (* k k) n)
  15.                 (and (positive? (remainder n k))
  16.                      (loop (+ k 2))))))))
  17.  
  18. (define (main)
  19.  (do ((i 3 (+ i 2)))
  20.    ((> i 4999) #t)
  21.      (if (prime? i) (begin (display i)(display " ")) "")
  22.  )
  23.  (newline)
  24. )
  25.  
  26. (main)
  27. """
  28. PRINT """
  29. <html>
  30. <body>
  31. """ & TS_Cmd(sc, ts_src) & """
  32. </body>
  33. </html>
  34. """
  35. TS_Close sc
  36.  
« Last Edit: April 18, 2015, 11:52:02 PM by John »

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #1025 on: April 18, 2015, 11:27:41 PM »
Hehe, nice! :)


Sorry but I can't provide the example yet. The DLL interface that TS currently supports cannot work with Windows API directly. Instead, it expects the DLLs to be tailored to cater for TS so that the DLL is the active component in the link to establish the connection while TS remains almost entirely passive. In other words, TS would require either custom DLL proxies to be used similar to SB or the dynload module code to be extended/reworked so that TS itself can do what a normal Windows application would do under similar circumstances.

The older regexp and tsx modules you used to report here and on the SB site earlier were tailored to that model. But it is totally unnatural and too restrictive for a Windows application, whether executable or library.

I'll look into the matter more closely and will report back later about my findings.

JRS

  • Guest
Re: Lisp in Basic
« Reply #1026 on: April 18, 2015, 11:32:46 PM »
Sounds like the same issue with using SB extension module DLL/SO libraries. (custom calling methods)

Mike Lobanovsky

  • Guest
Re: Lisp in Basic
« Reply #1027 on: April 18, 2015, 11:59:17 PM »
Yeah, and it's totally beyond me why anyone would deliberately develop such restrictive and restricted functionality for as versatile an application as TinyScheme. Perhaps this was just another case when "the community" started to uncontrollably commit their unqualified "improvements" and "extensions" to an advanced project's main trunk... ::)


Is there any way in Linux to explore an SO's entry point addresses and literal function names like Windows LoadLibrary()/GetProcAddress() do?

[EDIT] More specifically, does an ELF format header contain something like a PE export table with literal (or mangled) function names and entry points?
« Last Edit: April 19, 2015, 12:06:40 AM by Mike Lobanovsky »

JRS

  • Guest
Re: Lisp in Basic
« Reply #1028 on: April 19, 2015, 10:41:07 AM »
Here is a Perl example of parsing the XML MLS listing example in a previous post.

Code: Perl
  1. use strict;
  2. use XML::Simple;
  3. use Data::Dumper;
  4.  
  5. my $listing = XMLin('sample.xml');
  6.  
  7. print Dumper($listing);
  8.  

Output

jrs@laptop:~/sb/sb22/test$ time perl getxml.pl
$VAR1 = {
          'xmlns' => 'http://www.nwmls.com/Schemas/Standard/StandardXML1_1.xsd',
          'Residential' => {
                           'SNR' => 'N',
                           'ProhibitBLOG' => 'Y',
                           'OLP' => '599950.00',
                           'FPM' => '1',
                           'INDT' => '1800-01-01 00:00:00',
                           'SAP' => '0',
                           'MR' => 'Third of three New Contemporary Homes w/fantastic open floor plans and great level and fenced backyards.These homes have wonderful tall ceilings,designer paint,fully wrapped windows,solid core/glass int doors and top of the line strand Bamboo flrs.The kitchen is an entertainers dream w/an enormous open eating bar,honed granite counters,custom wood cabinets,top of the line stainless steel appls and french doors to the ent backyard. Quality and Designer features from top to Bottom, a must see!!',
                           'VIRT' => {},
                           'BLK' => '14',
                           'TBL' => '0',
                           'FBU' => '2',
                           'MBD' => 'U',
                           'ECRT' => {},
                           'ZIP' => '98126',
                           'BDI' => 'E',
                           'LSZS' => {},
                           'WHT' => {},
                           'LT' => '16',
                           'ENS' => 'B',
                           'PTYP' => 'RESI',
                           'PDR' => '1800-01-01 00:00:00',
                           'TBU' => '0',
                           'DNO' => 'L',
                           'LDE' => 'H|J',
                           'MHS' => {},
                           'LRM' => 'M',
                           'SHOADR' => 'Y',
                           'HTC' => 'B',
                           'GRDX' => 'G',
                           'LONG' => '-122.362210',
                           'LSD' => {},
                           'STY' => '18',
                           'GAR' => '2',
                           'BRM' => {},
                           'BREO' => 'N',
                           'YBT' => '2010',
                           'TX' => '0',
                           'BSM' => 'A|B',
                           'FP' => '1',
                           'FND' => 'E|F',
                           'TRM' => 'B|C',
                           'SFF' => '0',
                           'SCA' => '0',
                           'FLS' => 'J|A|G',
                           'LO' => '1401',
                           'DSR' => 'Pigeon Point',
                           'DRS' => 'SW',
                           'KES' => 'M',
                           'JH' => {},
                           'WFT' => {},
                           'SFU' => '0',
                           'ARC' => 'K',
                           'BLD' => 'JDR Development Inc',
                           'ADU' => {},
                           'FBM' => '0',
                           'BDM' => '0',
                           'EFR' => {},
                           'FEA' => 'A|D|F|G|J|M|P|T',
                           'GR' => 'C',
                           'EXT' => 'J|E',
                           'TQBT' => '0',
                           'FPU' => '0',
                           'STA' => 'WA',
                           'AllowAVM' => 'Y',
                           'UNT' => {},
                           'FPL' => '0',
                           'POS' => 'A',
                           'PTO' => 'Y',
                           'LSF' => '4800',
                           'RRM' => 'L',
                           'HBM' => '1',
                           'AR' => '140',
                           'TAX' => '1773600264',
                           'WFG' => {},
                           'EL' => {},
                           'SSUF' => 'Ave',
                           'RF' => 'C',
                           'SFS' => 'Per Builder Plans',
                           'PL4' => {},
                           'SWC' => 'SEA',
                           'BR' => '5.00',
                           'LP' => '599950.00',
                           'PIC' => '1',
                           'CIT' => 'Seattle',
                           'POC' => 'SEA',
                           'HBT' => '1',
                           'AVDT' => '1800-01-01 00:00:00',
                           'HBG' => '0',
                           'SH' => {},
                           'KIT' => {},
                           'SD' => 'SEA',
                           'SWR' => 'A',
                           'BUSR' => {},
                           'QBT' => '0',
                           'LAG' => '27022',
                           'HSN' => '4538',
                           'CTDT' => '2010-04-24 00:00:00',
                           'DSRNUM' => '7215',
                           'SML' => 'Y',
                           'FIN' => {},
                           'LAT' => '47.561975',
                           'WAC' => 'SEA',
                           'NC' => 'U',
                           'PARQ' => 'N',
                           'ZNC' => 'SF 5000',
                           'UD' => '2010-04-24 14:59:25',
                           'BTH' => '3.50',
                           'HSNA' => {},
                           'HOD' => '0',
                           'HBU' => '0',
                           'DD' => 'From Delridge Way head east on Oregon which becomes 23rd.',
                           'NIA' => 'Y',
                           'PRJ' => 'Cottage Grove # 3',
                           'LD' => '2010-04-24 00:00:00',
                           'FBT' => '3',
                           'FBG' => '0',
                           'LTV' => 'E|F',
                           'SDT' => '2010-04-24 00:00:00',
                           'ST' => 'CT',
                           'BDC' => {},
                           'SAG' => '0',
                           'SCO' => '0',
                           'LDR' => '2010-04-24 00:00:00',
                           'APS' => 'A|D|E|F|G',
                           'TBG' => '0',
                           'VEW' => 'D|L',
                           'BDU' => '3',
                           'ASF' => '3650',
                           'HBL' => '0',
                           'POL' => {},
                           'COLO' => '0',
                           'MOR' => '0',
                           'DRP' => {},
                           'DRM' => 'M',
                           'F17' => 'A',
                           'MAPBOOK' => 'THOM',
                           'BUS' => 'Y',
                           'CMFE' => {},
                           'ENT' => 'M',
                           'WAS' => 'D',
                           'CDOM' => '0',
                           'CLA' => '0',
                           'LN' => '62981',
                           'MHN' => {},
                           'UTR' => 'U',
                           'LSZ' => {},
                           'COU' => 'King',
                           'ZJD' => 'A',
                           'TXY' => '0',
                           'FAM' => 'M',
                           'MHM' => {},
                           'SIT' => 'G|H|M|Y|N',
                           'MAP' => '594',
                           'GRDY' => '4',
                           'SO' => '0',
                           'TBM' => '0',
                           'CLO' => '1800-01-01 00:00:00',
                           'BDL' => '2',
                           'FBL' => '1',
                           'SP' => '0.00',
                           'STR' => '23rd'
                         }
        };

real   0m0.091s
user   0m0.086s
sys   0m0.004s
jrs@laptop:~/sb/sb22/test$