Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 18 13:44
    amirouche commented #748
  • May 18 13:34
    amirouche opened #750
  • May 13 20:51
    CI run 2321521995 passed
  • May 13 19:51

    feeley on master

    Universal backend: fix bitrot i… (compare)

  • May 09 16:57
    feeley commented #631
  • May 09 16:51
    cmcanulty commented #631
  • May 09 16:00
    feeley commented #631
  • May 09 15:11
    cmcanulty commented #631
  • May 03 15:57
    CI run 2264567713 passed
  • May 03 15:11
    donaldcallen commented #680
  • May 03 14:54

    gambiteer on master

    Add partition unit tests Merge branch 'master' of https:… (compare)

  • May 03 14:46
    gambiteer commented #680
  • Apr 29 18:15
    feeley closed #749
  • Apr 29 18:15
    feeley commented #749
  • Apr 29 17:14
    CI run 2246486183 passed
  • Apr 29 16:14

    feeley on master

    Windows: allocate new console o… (compare)

  • Apr 29 03:59
    bjornkihlberg commented #749
  • Apr 29 03:57
    feeley commented #749
  • Apr 29 03:49
    bjornkihlberg commented #749
  • Apr 29 03:04
    feeley commented #749
Marc Feeley
@feeley
second question: yes
safe in the sense that it will not crash the program… but you might get abandonned mutexes
philsuero
@philsuero

perhaps your design is wrong

For me to understand please provide pseudocode/a code example that illustrates how this would be done. I guess typical would be input available on port (say on two ports), port become writable (say on two ports), mutex lock completed, and sleep completed.

Bumping this up in case it was unnoticed

xgqt
@xgqt:matrix.org
[m]
Hi!
Bradley Lucier
@gambiteer
@rajeevn1 I recommend you download a new git repository and follow the instructions at the bottom of this page: https://github.com/gambit/gambit
rajeevn1
@rajeevn1
@gambiteer I found the issue, I was using a shallow copy of the git repository. Thanks.
philsuero
@philsuero
Just sent a question to the ML :)
philsuero
@philsuero
@feeley just curious, above what size again, is it, that a heap allocated object will be ___STILL automatically just because Gambit's policy i that 'big' objects will be still and not movable.. >1KB or is it >1MB, other threshold?
rajeevn1 @rajeevn1
Tom Elam
@tomelam
@feeley I haven't studied the building of the online Gambit REPL (https://github.com/gambit/gambit/tree/master/contrib/try) but I wonder if you could point me to a way to reduce the built size of the JavaScript for that. It was over 11 MB when I built it. Is there a part of it (say, without some of the SRFI code or some of the math code) that can be built by redefining some make or shell variable? Something like that? I'd like to have an online Gambit REPL in just 1 or 1.5 MB of JavaScript.
rajeevn1
@rajeevn1
@feeley @tomelam I wonder if https://en.wikipedia.org/wiki/Google_Closure_Tools can be used here, as is used by ClojureScript, maybe till a gambit smart-linker is ready.
Tom Elam
@tomelam
@rajeevn1 How would that reduce the size of a REPL?
@rajeevn1 I'm not familiar with what the Closure Tools do. I'm talking about an order of magnitude reduction in size. Gzipping or reducing variable name lengths and eliminating all comments and excess white space won't be nearly enough.
@rajeevn1 @feeley I've heard about the Gambit smart linker. Any idea when it will be ready for a test drive?
Tom Elam
@tomelam

@feeley I haven't studied the building of the online Gambit REPL (https://github.com/gambit/gambit/tree/master/contrib/try) but I wonder if you could point me to a way to reduce the built size of the JavaScript for that. It was over 11 MB when I built it. Is there a part of it (say, without some of the SRFI code or some of the math code) that can be built by redefining some make or shell variable? Something like that? I'd like to have an online Gambit REPL in just 1 or 1.5 MB of JavaScript.

Redefining a make target would be a good option, too, if it wouldn't make the build process fail.

Drew Crampsie
@drewc
@tomelam did you configure with --enable-default-compile-options=(compactness 9)?
Here's what I have for a "repl" (minus codemirror and browserFS):
du -hs VM.min.js*
  4.9M    VM.min.js 
  688K    VM.min.js.gz
Drew Crampsie
@drewc
Having said that, I have in the past dropped the .js size down to 1 meg or so, BUT, not the REPL. The REPL is basically a full gambit environment, as is required for read and eval and print, so cannot really be reduced more than that.
This is the point where I point out this:
find /nix/ -name 'libgambit.so' -exec du -h {} \;
8.5M    /nix/store/m27913wknikn3nkqiny6j0m68kily4np-gambit-unstable-2020-07-29/gambit/lib/libgambit.so
So, in JavaScript it ends up 1/2 the size of C? Not quite the same thing, of course, but really helped to give me perspective.
Drew Crampsie
@drewc
If you do not "lexicalize" certain toplevels the .gz can drop to almost 640k ... I just had to do that for gerbil packages essentially. and the 4.9 is like 3.2 or somesuch.
Can almost fit on a 5-1/4 floppy? Small enough for my purposes :).
Marc Feeley
@feeley

@tomelam Please read the comments at the top of contrib/try/makefile.in:

# To build VM.js from VM.scm you need a recent Gambit with the JavaScript
# backend.  It can be compiled like this (from an existing bootstrapped
# recent installation):
#
#   cd gambit
#   git pull
#   make clean
#   ./configure --enable-single-host --enable-targets=js --enable-default-compile-options="(compactness 9)" --prefix=/usr/local/Gambit
#   make
#   make doc
#   make modules
#   sudo make install   (optional)

The VM.js file (the bulk of the Gambit online REPL) will be postprocessed by the google closure compiler and when the result is gzipped you will get a 640KB file
If you want to go even smaller, you can trim some stuff from the runtime library, such as support for complex numbers, exact rationals and bignums by using configure options such as --disable-cpxnum, etc. To enable the “smart linker” you need to do a “whole-program” compilation that includes the file lib/_univlib.scm and prefix the code with (declare (optimize-dead-definitions)). Note that this will remove some of the runtime library so your REPL won’t be able to access the definitions that were removed (it is a compilation strategy that works best for complete applications).

Bradley Lucier
@gambiteer
I don't think anyone has thoroughly tested the runtime with --disable-cpxnum, etc. Just a comment.
Tom Elam
@tomelam
@feeley @drewc Thank you both immensely! I am very excited about this!
Tom Elam
@tomelam
@gambiteer Thanks for the heads up!
Marc Feeley
@feeley
@tomelam Don’t hesitate to ask more questions here if you get stuck.
patternspandemic
@patternspandemic
Is it expected to require a positional #!optional when specifying a named #!key? In the following example, I thought opt-a would get a default value of #f:
> (define (f req #!optional opt-a #!key key-x) (list req opt-a key-x))
> (f 1)
(1 #f #f)
> (f 1 2)
(1 2 #f)
> (f 1 key-x: 3)
*** ERROR IN (stdin)@4.1 -- Wrong number of arguments passed to procedure
(f 1 key-x: 3)
1>
Marc Feeley
@feeley
@patternspandemic In your last expression, the keyword key-x: is a value that will be bound to the opt-a parameter. So the first two arguments are handled as required and optional parameters. What is left is the argument 3 which is not acceptable since there are no additional optional parameters to match to. Please read section 6.2 of the manual for the detailed semantics (which is the one specified for DSSSL).
patternspandemic
@patternspandemic
I see. After another read, I can see I've made incorrect assumptions with how 'actual arguments' are considered. Thank you.
Tom Elam
@tomelam

@tomelam Don’t hesitate to ask more questions here if you get stuck.

@feeley So very kind of you. Gambit's JS target is the 3rd Scheme in JS I've used. Currently I'm using Biwascheme for my hobby project (https://tomelam.gitbook.io/mashweb, http://web-call.cc, https://mashweb.club). If I can get the payload small enough, it will be a great boon to my project. Currently Biwascheme is missing some important things, even though it's interesting to work with. My degree was in EE, not CS. Compiler-like stuff is way over my head.

Marc Feeley
@feeley
@tomelam I guess that makes you a perfect guinea pig for testing the practicality of the JS backend… For your use it might be simplest to just take the VM.min.js.gz file “as is” and to write the rest of your app as a module that is loaded by the runtime system using load or import or eval. What programming language features are needed by your app?
Marc Feeley
@feeley

@tomelam To get you started, here is how to compile a minimal web app to Scheme… First you should build Gambit with:

./configure --enable-single-host --enable-targets=js --enable-default-compile-options="(compactness 9)”
make
make modules

This will build the JS version of the Gambit runtime library and produce compact JS code. Then create a mini-web-app directory and put in it this makefile, index.html and app.scm:

all: app.min.js

app.js: app.scm
    gsc -target js -label-namespace "z" -exe -o app.js app.scm

app.min.js: app.js
    npx google-closure-compiler --language_in=ECMASCRIPT_2015 --language_out=ECMASCRIPT_2015 --js app.js --js_output_file app.min.js
    sed -I .tmp -e "s/^'use strict';//" app.min.js
    gzip -k -9 app.min.js  # optional but useful if the web server can send .gz files

clean:
    rm -f app.js app.min.js app.min.js.gz
<!doctype html>
<html>
  <head><script src="app.min.js"></script></head>
  <body onload="scheme_program_start();"></body>
</html>
;;; File: "app.scm"

(include "~~lib/_gambit#.scm")
(include "~~lib/_six/js#.scm")

(##inline-host-declaration #<<end-of-host-code

// Defer Scheme code execution until scheme_program_start is called.
scheme_program_start = @all_modules_registered@;
@all_modules_registered@ = function () { };

end-of-host-code
)

(define alert \alert)
(define prompt \prompt)
(define (body-html-set! html) \document.body.innerHTML=`html)

(body-html-set! (string-append "<h1>"
                               (prompt "Please enter your name")
                               "</h1>"))

(thread-sleep! 0.1) ;; let browser update the screen

(alert "The body now contains your name!\nClick OK to replace it with the New-York weather forecast.\n")

(define (fetch-json url)
  \fetch(`url).then(function (r) { return r.json(); }))

(define x
  (fetch-json "https://forecast.weather.gov/MapClick.php?lat=40.78333&lon=-73.96667&FcstType=json"))

(define temp \(`x).currentobservation.Temp)
(define name \(`x).currentobservation.name)

(body-html-set! (string-append "<h1>" name ": " temp "F</h1>"))

;; uncomment the following to start a REPL:
;;(thread-sleep! 0.1) ;; let browser update the screen
;;(##repl-debug-main)

Then after a make just open index.html in a browser.

Tom Elam
@tomelam
@feeley The programming language features I need are rich flow control forms, including also call/cc, a arithmetic operations (at least block floating point), hopefully a module system, the ability to load a full Scheme implementation bit by bit, and a foreign function interface for JavaScript.
Marc Feeley
@feeley
@tomelam You’re all set with Gambit then!
Tom Elam
@tomelam
@feeley Thanks for all your help! It's great! I am really happy to be a guinea pig for this. I have compiled Gambit to JavaScript according to the procedure outlined at https://tomelam.gitbook.io/mashweb/part-3-the-key-to-zen-a-nano-framework-for-sequential-programming/biwa-to-gambit-the-rationale and I will be trying to reduce the size of the result according to your advice.
@feeley Right now my wife is calling me to dinner, so I must leave my computer...
Tom Elam
@tomelam
@feeley The web page https://tomelam.gitbook.io/mashweb/part-3-the-key-to-zen-a-nano-framework-for-sequential-programming describes my main use of call/cc. Briefly, the idea is to create something like POSIX's system calls select(2) and poll(2). I will sort out the priorities of the events in the top-level event loop.
@feeley I'll work on this tomorrow.
Tom Elam
@tomelam
@feeley I forgot to mention that I have demos of all this working on http://web-call.cc . The best demo is the 'financial blog' (which is only a barebones sketch of part of a web app).
@feeley The code is at github.com/mashweb/web-call.cc .
Marc Feeley
@feeley
@tomelam I did a quick check and I think Gambit is the right fit for your needs because it directly implements your “sequential programming” model in the browser… I’m not sure I understand your need for call/cc (it is probably better to use Scheme threads to have independent computations), but of course call/cc is there if it is required… concerning event handling, please have a look at this paper, especially section 5.2: http://www.iro.umontreal.ca/~feeley/papers/BelangerFeeleyELS21.pdf
Tom Elam
@tomelam
@feeley I know there are many models of multitasking (probably more than my brain can hold), but working from the top down, I decided that at some point a human user interface must accomplish (sometimes random) tasks only in sequence. Therefore it would be easier to funnel all possible expected inputs (like key presses, mouse clicks, form submissions, Ajax events) into a single control flow operator (in my code it's with-handlers, which is perhaps not the best name). If a particular type of input could best be handled in a different thread (like Ajax events from the loading of a large file), that could also be done. But at some point the page will need to change state to reflect a pivotal event like the completion of an input string or the press of a submit button. Since the human user could direct a different response (for example, by pressing a 'Cancel' button), I designed with-handlers to gate any and every event that could affect the subsequent flow of the main loop of the program.
@feeley When I create some web apps using Gambit, I will first look at using Scheme threads, as you suggest. Then I will have to find some technique like semaphores to achieve the same gating effect I just described.
@feeley Your paper is very interesting. I will read it tomorrow.
@feeley Thanks again! I hope I can be a good and helpful guinea pig! Oink, oink! (Or is it 'Squeak, squeak'?)
Tom Elam
@tomelam
@feeley Now this guinea pig needs his sleep. Zzz.
Tom Elam
@tomelam
@feeley @drewc By the way, I couldn't understand in a minute's perusal what Gerbil is about. Do I need that for my project as I've described it? (Basically I need a full Scheme in the browser with a quick initial load of a REPL in the browser.)