Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Apr 22 22:58
    gambiteer commented on 14554bd
  • Apr 22 22:58
    gambiteer commented on 14554bd
  • Apr 22 22:48
    Windows-mingw build of CI run 775826755 failed
  • Apr 22 22:21

    feeley on master

    This adds --enable-c-opt-rts to… Merge pull request #684 from ia… (compare)

  • Apr 22 22:21
    feeley closed #684
  • Apr 22 22:21
    feeley reopened #684
  • Apr 22 22:20
    feeley closed #684
  • Apr 22 22:20
    feeley commented #684
  • Apr 22 20:40
    iains commented #684
  • Apr 22 20:38
    feeley reopened #684
  • Apr 22 20:38
    feeley commented #684
  • Apr 22 19:21
    iains closed #684
  • Apr 22 19:21
    iains commented #684
  • Apr 22 18:43
    iains opened #684
  • Apr 22 18:41
    iains closed #683
  • Apr 22 18:41
    iains commented #683
  • Apr 22 18:40
    iains synchronize #683
  • Apr 22 18:14
    feeley commented #683
  • Apr 22 17:04
    iains commented #683
  • Apr 22 16:17
    iains opened #683
amirouche
@amirouche
what are the namespaces or procedures available in javascript runtime?
when I type (apropos) in the normal REPL I get some procedure names, but I am not sure which one is available in js runtime
Marc Feeley
@feeley

@amirouche I’m not sure what you mean by the “normal REPL” but if you execute (apropos) in the web app REPL then you will get the procedures defined in the web app’s Scheme library. Unfortunately the web app’s REPL will only show the last few lines of output, so you might want to evaluate this instead (tested on the last page of https://udem-dlteam.github.io/webapp-tutorial):

(define (show thunk)
  (host-exec
    "var text = g_scm2host(@1@);
     var parent = document.querySelector('.slide.present') || document.body;
     var elem = document.createElement('textarea');
     elem.style = 'position: absolute; font-family: monospace; font-size: 10px; height: 500px; width: 500px; left: 0px; top: 0px; z-index: 99999; overflow-y: scroll;';
     elem.value = text;
     elem.addEventListener('dblclick', function (event) { event.target.parentNode.removeChild(event.target); });
     parent.appendChild(elem);"
    (with-output-to-string thunk)))

(show (lambda () (apropos "" (current-output-port))))

You’ll see that most of the procedures of the C backend’s Gambit library are available. Obviously some “desktop OS specific” functionality is not implemented :

> (shell-command "ls")
unimplemented ##os-environ called
*** ERROR IN (console)@1.1 -- Unknown error
(shell-command "ls")
amirouche
@amirouche
Thanks!
amirouche
@amirouche
I do not have the procedure host-exec on my side
Marc Feeley
@feeley
host-exec is a macro that is specific to the universal library. Look for "Host FFI" in lib/_univlib.scm. There is an implementation for the JS and Python backends (languages that have a run time eval construct). If you want to avoid host-exec then use ##inline-host-expression which has the same API but is static (you can’t (eval '(##inline-host-expression …)))
amirouche
@amirouche
I do not understand, because it does not work on my side...
% cat index.scm
(define (show thunk)
  (host-exec
    "var text = g_scm2host(@1@);
     var parent = document.querySelector('.slide.present') || document.body;
     var elem = document.createElement('textarea');
     elem.style = 'position: absolute; font-family: monospace; font-size: 10px; height: 500px; width: 500px; left: 0px; top: 0px; z-index: 99999; overflow-y: scroll;';
     elem.value = text;
     elem.addEventListener('dblclick', function (event) { event.target.parentNode.removeChild(event.target); });
     parent.appendChild(elem);"
    (with-output-to-string thunk)))

(show (lambda () (apropos "" (current-output-port))))
% cat ../../scm2js.sh
#!/bin/sh

docker run -v $(pwd):/mnt --rm -it schemers/gambit:head gsc -target js -exe /mnt/$1
tail -n +2 $(basename $1 .scm) > "$(basename $1 .scm).js"
rm -f $(basename $1 .scm)
% ../../scm2js.sh index.scm
% node index.js
*** ERROR -- Operator is not a PROCEDURE
(#!void
 "var text = g_scm2host(@1@);\n     var parent = document.querySelector('.sl...
 "\"##\" namespace:\n  *, *2, +, |+2|, -, |-2|, /, /2, <, <2, <=, =, =2, >, ...
)
>
*** EOF again to exit
%
Marc Feeley
@feeley
Did you (eval ‘(host-exec “…”)) or do (host-exec “…”) in the web app’s REPL? It won’t work in compiled code… you need to use (##inline-host-statement “…”) for that.
amirouche
@amirouche
ah ! ok :)
host-exec is usable only in eval
Good thing eval works :)
Marc Feeley
@feeley
or in the REPL, which hides eval… ideally the two forms should be unified
François-René Rideau
@fare
How good is the JS backend, and could I reasonably have my DApp runtime run on top of it?
How much work would be required to bring the backend up to shape?
François-René Rideau
@fare
Another parameter question: it looks like (define foo (make-parameter #f)) creates a global binding that is side-effected rather than thread-locally shadowed by a (foo 'bar) unless I first use (parameterize ((foo #f)) ...) in the thread. Is that expected behavior?
François-René Rideau
@fare
This interesting makes parameters more like special variables in SBCL, and less like parameters in Racket.
François-René Rideau
@fare
the most "interesting" to me is to spawn a thread within a parameterize, then the threads inherit the cell, not the value, and can concurrently edit that shared cell.
François-René Rideau
@fare
is there a way to access the list of currently bound parameters? The equivalent of CL's PROGV ?
François-René Rideau
@fare
... the answer is a list of parameter-binding procedures.
François-René Rideau
@fare
and call parameterize on each one in a loop around the internal thunk.
amirouche
@amirouche
@fare JS backend is definitely usable!
I was planning to do a clone of slack, but the target application is little bit different than "corporate chat", so I am experimenting with a conversation that ressembles a tree.
François-René Rideau
@fare
@amirouche nice!
I'll need some chat capability in my app manager... after all, players have to be able to find each other.
Jason Felice
@eraserhd
I just discovered that (equal? (make-table) (make-table test: equal?)) ;=> #f, and it's probably because (equal? equal? ##equal?) ;=> #f. This is non-obvious from the docs, is it bad?
amirouche
@amirouche
re javascript backend: that said I stumbled upon an error that says something along the lines of r1 register undefined... Next time I will try to pin point a simple way to reproduce, I mostly debug with print but before convert argument to string with write
The error I mentioned above is a javascript error, 99 time out of 100 the error raise a popup with a REPL with where the error is.
Marc Feeley
@feeley
@eraserhd nice catch! yes definitely what I consider to be a bug… will come up with a fix...
François-René Rideau
@fare
what is the Right Way™ to cond-expand on the presence of symbols in openssl?
use #ifdef in C, and export dummies if not present?
François-René Rideau
@fare
I ended up doing a #if in C that returns NULL when the thingie is undefined, so you get a #f at runtime on the Scheme side.
François-René Rideau
@fare
Has anyone here experience with SchemeSpheres and/or LambdaNative ? Which should I use if I wanted to write applications targetting iOS, Android, JS, etc.?
François-René Rideau
@fare
is there a way to tell the FFI that an EVP_PKEY* is a special case of EVP_MD* or must I somehow cheat via void* ?
François-René Rideau
@fare
^ I assume that's what the tags in (pointer ...) are for, though I'm a bit surprised by the "T’s primary tag is a member of E’s tags" criterion.
junkerjoe
@junkerjoe

I'm getting a failed unit test from make check when trying to build the Gambit master branch with the options:

./configure --prefix=/usr/local/gambit 
                       --enable-single-host
                       --enable-multiple-versions
                       --enable-shared
                       --enable-smp 
                       --enable-gcc-opts
                       --enable-openssl
                       --enable-absolute-shared-libs
                       --enable-poll
                       --enable-bignum

The relevant make check output is:

LD_LIBRARY_PATH=../lib:../gsi:../gsc: ../gsi/gsi -:tl,~~bin=../bin,~~lib=../lib,~~include=../include -f ./run-unit-tests.scm
[226|  0]  90% ##############.. 6.9s 13-modules/prim_exception.scm
*** FAILED 13-modules/prim_exception.scm WITH EXIT CODE HI=1 LO=0
(with-exception-handler ##list (lambda () (##cons 1 (##raise 123)))) in (include "~~lib/gambit/prim/exception#.scm") returned #<unbound-global-exception #2> but expected (1 123)
(with-exception-handler ##list (lambda () (##cons 1 (##raise 123)))) in (namespace ("##")) returned #<unbound-global-exception #3> but expected (1 123)
[250|  1] 100% ################ 7.5s
FAILED 1 UNIT TESTS OUT OF 251 (.4%)

This is my first time building Gambit with this many options. Any insights to share on why this might be happening?

Bob Coleman
@skilldown

@junkerjoe Those tests rely on the optional module system. From a fresh clone build with a normal make and build the module system with make modules before running the make check. This fixed the issue for me.

Make sure to use a fresh clone to avoid issues with build artifacts.

Jaime Fournier
@ober
@junkerjoe you should not need the --enable-gcc-opts any longer
junkerjoe
@junkerjoe
@skilldown I thought --enable-smp required make bootstrap; make bootclean; make before make modules; make check. I can try it without.
@ober Noted. I'll get rid of this option
junkerjoe
@junkerjoe
Decided to revert back to non-SMP, but I made a ticket on the issue I was having to get clarity on whether it was expected behavior: gambit/gambit#502
junkerjoe
@junkerjoe
Linked the wrong ticket woops. Correction: gambit/gambit#640
Bradley Lucier
@gambiteer
Marc: Simple file:
(define-structure point x)

expands to

gsc -c -expansion crap.scm
Expansion:

(define ##type-1-point
  ('#<procedure #2 ##structure> ##type-type ('#<procedure #3 ##string->uninterned-symbol> "##type-1-point") 'point 8 #f #(x 0 #f)))

(define make-point (lambda (p1) ('#<procedure #2 ##structure> ##type-1-point p1)))

(define point-copy (lambda (obj) (##structure-copy obj)))

(define point? (lambda (obj) ('#<procedure #4 ##structure-direct-instance-of?> obj ('#<procedure #5 ##type-id> ##type-1-point))))

(define point-x
  (lambda (obj)
    (let ((temp.3 point-x) (temp.2 ##type-1-point))
      (if ('#<procedure #4 ##structure-direct-instance-of?> obj ('#<procedure #5 ##type-id> temp.2))
          ('#<procedure #6 ##unchecked-structure-ref> obj 1 temp.2 temp.3)
          ('#<procedure #7 ##direct-structure-ref> obj 1 temp.2 temp.3)))))

(define point-x-set!
  (lambda (obj val)
    (let ((temp.8 point-x-set!) (temp.7 ##type-1-point))
      (if ('#<procedure #4 ##structure-direct-instance-of?> obj ('#<procedure #5 ##type-id> temp.7))
          ('#<procedure #8 ##unchecked-structure-set!> obj val 1 temp.7 temp.8)
          ('#<procedure #9 ##direct-structure-set!> obj val 1 temp.7 temp.8)))))

(define point-x-set (lambda (obj val) (##direct-structure-set obj val 1 ##type-1-point point-x-set)))

How do I get rid of point-copy? I want to define my own with that name.

Bradley Lucier
@gambiteer
If it's not easy to get rid of point-copy I'll just rename my function.
Marc Feeley
@feeley
@gambiteer (define-structure point x copier: #f)
junkerjoe
@junkerjoe
Should I expect an executable to be killed off, after exceeding a certain memory limit, when providing the -:max-heap runtime option to gsc?
junkerjoe
@junkerjoe
I'd love to see an example program compiled with the -:max-heap setting and heap overflow. I think I just don't understand how it works.
Bradley Lucier
@gambiteer

-:max-heap is a runtime setting, so if c.scm is

[Bradleys-Mac-mini:~] lucier% cat c.scm
(do ((r '() (cons (make-vector 1000000) r)))
    (#f))

then you get

gsi -:max-heap=1000 c.scm
*** ERROR IN ##make-vector -- Heap overflow