Author Topic: Updating OxyScheme  (Read 18951 times)

0 Members and 1 Guest are viewing this topic.

Mike Lobanovsky

  • Hero Member
  • *****
  • Posts: 1993
Re: Updating OxyScheme
« Reply #60 on: December 08, 2019, 07:46:59 AM »
Aurel,

There are at least three, possibly four (taking John into consideration), people who care about Lisp/Scheme on this forum: Charles, Roland, and myself.

And there is but one person who doesn't -- and that's you.

At any rate, we're talking about OxyScheme -- a product that's been written in OxygenBasic, and as any other O2 product, it has every right to be discussed here as long as there's at least one person willing to do so.

(I thought after all these years, you grew to know better than spam the OxyScheme threads like you did in the past.)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4409
    • Oxygen Basic
Re: Updating OxyScheme
« Reply #61 on: December 10, 2019, 04:34:20 AM »
I don't see core Scheme as a complete programming language, but I'm interested in a compilable Scheme, with the few necessary extensions to work directly with DLLs, (and to perform loops without recursion!).

example:
http://matt.might.net/articles/compiling-scheme-to-c/

jack

  • Full Member
  • ***
  • Posts: 157
Re: Updating OxyScheme
« Reply #62 on: December 10, 2019, 11:35:39 AM »
hello Charles
Racket compiles to executable, though I only lightly touched it.
https://www.racket-lang.org/

Mike Lobanovsky

  • Hero Member
  • *****
  • Posts: 1993
Re: Updating OxyScheme
« Reply #63 on: December 10, 2019, 12:07:14 PM »
Charles,

Core Scheme seems as much abortive as a console-only BASIC and is therefore of limited interest only these days. Yet as I said, there are a number of Scheme implementations (mainly Linuxoid) that offer both dynamic library linking capabilities and GUI front-ends. What's more, their semantics is capable of interfacing Scheme apps with 3rd party OOP code and objects.

One such implementation is Bigloo. It's an established dialect whose binding grammar can be duplicated in OxyScheme to reimplement similar features in it as needed.

As far as loops are concerned, R5RS defines at least two looping macros, for-each and do, that has both been implemented in OxyScheme too -- see nsinit.scm. (though I'm not sure how functional the macros are now) Granted they are not exact replicas of their C/O2 counterparts, but in many cases they allow us to write code much more similar to that of procedural languages than Lisp-ish/Scheme-ish recursion.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

John

  • Hero Member
  • *****
  • Posts: 3779
Re: Updating OxyScheme
« Reply #64 on: December 10, 2019, 12:58:39 PM »
Recursion is like waiting for the top to stop.

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4409
    • Oxygen Basic
Re: Updating OxyScheme
« Reply #65 on: December 10, 2019, 03:45:22 PM »
The do macro  :o

I think this tortuous code is a symptom indicating that loops should have been built into core Scheme.

Code: [Select]
(macro do
  (lambda (do-macro)
    (apply (lambda (do vars endtest . body)
             (let ((do-loop (gensym)))
               `(letrec ((,do-loop
                           (lambda ,(map (lambda (x)
                                           (if (pair? x) (car x) x))
                                      `,vars)
                             (if ,(car endtest)
                               (begin ,@(cdr endtest))
                               (begin
                                 ,@body
                                 (,do-loop
                                   ,@(map (lambda (x)
                                            (cond
                                              ((not (pair? x)) x)
                                              ((< (length x) 3) (car x))
                                              (else (car (cdr (cdr x))))))
                                       `,vars)))))))
                  (,do-loop
                    ,@(map (lambda (x)
                             (if (and (pair? x) (cdr x))
                               (car (cdr x))
                               nil))
                        `,vars)))))
      do-macro)))

Mike Lobanovsky

  • Hero Member
  • *****
  • Posts: 1993
Re: Updating OxyScheme
« Reply #66 on: December 11, 2019, 02:09:07 AM »
Hehe, unlike anarchist BASICs, Scheme dialects are not allowed to expand the language core vocabulary at the developer's volition. Standard library extensions are supposed to first stay in the library in the form of macros for years if not decades to get their functionality (as set forth by RnRS recommendations) and usefulness field-proven by the community. Implementations may differ from dialect to dialect but not the interface or place in the language keyword hierarchy.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Mike Lobanovsky

  • Hero Member
  • *****
  • Posts: 1993
Re: Updating OxyScheme
« Reply #67 on: December 11, 2019, 02:20:43 AM »
BTW let me note again that oxy-/nano-/mini Schemes are not yet fully R5RS compatible as-is. They still lack vector (= array) and char data type functionality. I lost interest in developing the code before I had a chance to add those features to the core language.
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4409
    • Oxygen Basic
Re: Updating OxyScheme
« Reply #68 on: December 14, 2019, 03:54:52 AM »
Before the PC, every home computer had its own hardware, and came with its own built-in version of BASIC and integral operating-system. So diversity was there from the start :)

However R5RS Scheme is, in my view, an incomplete language, so the standardisation is a bit of a cheat.

I would like to see how Scheme would encode a Windows GUI app.

Mike Lobanovsky

  • Hero Member
  • *****
  • Posts: 1993
Re: Updating OxyScheme
« Reply #69 on: December 14, 2019, 02:02:48 PM »
I can recollect vaguely the late Robbek used to upload a few Lisp apps here bundled with some GUI framework DLL that hung in memory so tightly we had to use the Task Manager to kill the process...
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

John

  • Hero Member
  • *****
  • Posts: 3779
Re: Updating OxyScheme
« Reply #70 on: December 15, 2019, 09:27:43 PM »
IUP has a Lisp binding.

Code: Lisp
  1. ;;; Generated from org-mode, do not edit
  2.  
  3. (eval-when (:compile-toplevel :load-toplevel :execute)
  4.   (ql:quickload '("iup" "iup-scintilla")))
  5.  
  6. (defpackage #:iup-examples.dialogs
  7.   (:use #:common-lisp)
  8.   (:export #:dialogs))
  9.  
  10. (in-package #:iup-examples.dialogs)
  11.  
  12. (defun dialogs ()
  13.   (iup:with-iup ()
  14.     (iup-scintilla:open)
  15.     (flet ((button (title callback)
  16.              (iup:button :title title
  17.                          :action callback
  18.                          :expand :horizontal)))
  19.       (let* ((dialog (iup:dialog
  20.                       (iup:vbox (list (button "File Dialog" 'file-dialog)
  21.                                       (button "Message Dialog" 'message-dialog)
  22.                                       (button "Color Dialog" 'color-dialog)
  23.                                       (button "Font Dialog" 'font-dialog)
  24.                                       (button "Scintilla Dialog" 'scintilla-dialog)
  25.                                       (button "Layout Dialog" 'layout-dialog)))
  26.                       :title "IUP Predefined Dialogs")))
  27.         (iup:show dialog)
  28.         (iup:main-loop)))))
  29.  
  30. (defun file-dialog (handle)
  31.   (let ((dialog (iup:file-dialog)))
  32.     (unwind-protect
  33.          (progn
  34.            (iup:popup dialog iup:+center+ iup:+center+)
  35.            (iup:message "File Dialog Example"
  36.                         (format nil "Selected ~A" (iup:attribute dialog :value))))
  37.       (iup:destroy dialog)))
  38.   iup:+default+)
  39.  
  40. (defun message-dialog (handle)
  41.   (let ((dialog (iup:message-dialog
  42.                  :dialogtype :warning
  43.                  :buttons :retrycancel)))
  44.     (unwind-protect
  45.          (progn
  46.            (setf (iup:attribute dialog :value) "Heap exhausted, game over.")
  47.            (iup:popup dialog iup:+center+ iup:+center+)
  48.            (iup:message "Message Dialog"
  49.                         (format nil "Got button response ~S"
  50.                                 (iup:attribute dialog :buttonresponse))))
  51.       (iup:destroy dialog)))
  52.   iup:+default+)
  53.  
  54. (defun color-dialog (handle)
  55.   (let ((dialog (iup:color-dialog
  56.                  :title "IUP Color Dialog"
  57.                  :showhex "YES"
  58.                  :showcolortable "YES"
  59.                  :showalpha "YES")))
  60.     (unwind-protect
  61.          (progn
  62.            (iup:popup dialog iup:+center+ iup:+center+)
  63.            (iup:message "Result"
  64.                         (format nil "Got button response ~S~%Got color ~A RGB (~A HSI, ~A)"
  65.                                 (iup:attribute dialog :status)
  66.                                 (iup:attribute dialog :value)
  67.                                 (iup:attribute dialog :valuehsi)
  68.                                 (iup:attribute dialog :valuehex))))))
  69.   iup:+default+)
  70.  
  71. (defun font-dialog (handle)
  72.   (let ((dialog (iup:font-dialog :title "IUP Font Dialog")))
  73.     (unwind-protect
  74.          (progn
  75.            (iup:popup dialog iup:+center+ iup:+center+)
  76.            (iup:message "Result"
  77.                         (format nil "Got button response ~S~%Got font ~S"
  78.                                 (iup:attribute dialog :status)
  79.                                 (iup:attribute dialog :value))))
  80.       (iup:destroy dialog)))
  81.   iup:+default+)
  82.  
  83. (defun scintilla-dialog (handle)
  84.   (let ((dialog (iup-scintilla:scintilla-dialog :title "IUP Scintilla Dialog")))
  85.     (unwind-protect
  86.          (iup:popup dialog iup:+center+ iup:+center+)
  87.       (iup:destroy dialog))))
  88.  
  89. (defun layout-dialog (handle)
  90.   (let ((dialog (iup:layout-dialog nil)))
  91.     (unwind-protect
  92.          (iup:popup dialog iup:+center+ iup:+center+)
  93.       (iup:destroy dialog)))
  94.   iup:+default+)
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104. #-sbcl (dialogs)
  105.  
  106. #+sbcl
  107. (sb-int:with-float-traps-masked
  108.     (:divide-by-zero :invalid)
  109.   (dialogs))
  110.  

Arnold

  • Hero Member
  • *****
  • Posts: 973
Re: Updating OxyScheme
« Reply #71 on: January 07, 2020, 02:16:46 AM »
Hi Charles,

did you find out why "when" and "do" are seen as <closure> instead of <macro>? I tried to create o2scm.o2bas with int instead of quad, but also failed miserably. For the moment, I have given up.

In the past I was unable to attend the forum for a while. That is why I missed almost everything about 'Lisp in Basic'. I now understand that I have asked some superfluous questions that have already been answered. I also noticed that John also started a topic about Tinyscheme. He referred to the link in GitHub:

https://github.com/armornick/TinyScheme

This (adapted) contribution is interesting because the prepared CMakeList.txt can be used to create a tinyscheme dll for 32-bit and 64-bit. These were my steps to create the DLLs after unpacking:

create subfolders build32, build64
using msys mingw32 / mingw64, I applied these commands in the build directories:

cmake -G "MSYS Makefiles" ..
make

which will create the dll and a main app which calls the dll. These files can be compressed with the "strip" command.

Perhaps it is also possible to call the routines of the DLLs with O2. Then everything would be there to establish the collaboration between Oxygenbasic and Scheme, which would be my real goal. I think you mentioned something similar in Message 61.

Roland
 
« Last Edit: January 07, 2020, 05:25:47 AM by Arnold »

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 4409
    • Oxygen Basic
Re: Updating OxyScheme
« Reply #72 on: January 09, 2020, 06:29:52 AM »
Hi Roland, Mike,

I have not cracked it yet. It might be beneficial to do a complete recode from scratch, with unit tests, improved recursion depth, and other features to make it a more complete language. I think this would be a better investment of time if the intention is to do any significant programming with Scheme.

What do you think?


Arnold

  • Hero Member
  • *****
  • Posts: 973
Re: Updating OxyScheme
« Reply #73 on: January 09, 2020, 09:42:58 AM »
I myself am impressed with how Mike managed to keep the spirit of Minischeme / Tinyscheme and to implement pointer structures. After a few experiments, I do not think there is a better way in Oxygenbasic, especially as far as applying macros like car(p), cdr(p) etc. are considered. But perhaps too many sys variables are used. Another problem for me is the multiple use of ivalue and the associated casts:  quad, double or integer index of a procedure. All of this worked for previous versions of Oxygen, but in the meantime O2 has changed a bit and some side effects will have been revealed somewhere.