Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 05:30
    rogera47 opened #803
  • 03:29
    feeley commented #802
  • 02:25
    gambiteer commented #802
  • 01:31
    feeley commented #802
  • Dec 04 16:54
    Linux build of CI run 3614175140 failed
  • Dec 04 16:48

    gambiteer on master

    Adjust unit tests for SRFI 141 … Add R7RS large/SRFI 141 divisio… Test division operators with ar… and 3 more (compare)

  • Dec 04 16:48
    gambiteer closed #802
  • Dec 04 16:22
    gambiteer synchronize #802
  • Dec 04 15:41
    dpk commented #675
  • Dec 04 15:40
    dpk commented #675
  • Dec 04 15:40
    dpk commented #675
  • Dec 04 00:15
    gambiteer commented #802
  • Dec 03 22:41
    gambiteer commented #802
  • Dec 03 22:40
    gambiteer synchronize #802
  • Dec 03 22:32
    gambiteer commented #802
  • Dec 03 22:27
    gambiteer commented #802
  • Dec 03 11:56
    feeley commented #802
  • Dec 03 04:36
    gambiteer commented #802
  • Dec 03 03:55
    feeley commented #802
  • Dec 03 03:53
    gambiteer closed #801
Jaime Fournier
@ober
Where do we submit new bounties?
Marc Feeley
@feeley
@ober To announce a bounty that you are willing to pay, just add an issue and indicate the details of the bounty. If you want to contribute funds so that we (the Gambit maintainers = me) can offer bounties then just click the button on the Gambit github repo README (in the “Contributing” section).
Jaime Fournier
@ober
:thumbsup:
Steve Bigham
@vesten

Question re: the FFI and C function pointers. If I have this in C,

int cfcn (int (*cb)()) {
    cb();
}

and this in scheme,

(define call-cfcn
  (c-lambda ((function () int)) int "cfcn"))

(c-define (scmcallback) () int "cname" ""
  (display " ** scheme callback\n"))

(call-cfcn scmcallback)

I receive the message, 'ERROR (Argument 1) Can't convert to C function' upon executing instead of the ' ** scheme callback' message. What have I missed or mis-read?

Marc Feeley
@feeley
@vesten I’m not sure which version of Gambit you are using, but this works fine:
$ gsc -v
v4.9.4-39-g9a887b80 20220503145411 x86_64-apple-darwin21.4.0 "./configure '--enable-single-host' 'CC=gcc-9'"
$ gsc cffi.scm
$ gsi cffi.o1
 ** scheme callback
42
$ cat cffi.scm
(c-declare "

int cfcn (int (*cb)()) {
  return cb() * 7;
}

")

(define call-cfcn
  (c-lambda ((function () int)) int "cfcn"))

(c-define (scmcallback) () int "cname" ""
  (display " ** scheme callback\n")
  6)

(pp (call-cfcn scmcallback))
Steve Bigham
@vesten
@feeley Thanks for taking up something so trivial Marc. I'm using the Void Linux 4.9.4 Gambit package and can reproduce your results. Checking back with my original code, I had a typo - called scmcccallback <facepalm>. Ultimately I'm trying to interface to Lua and am having trouble with a function that pushes a function pointer to the Lua stack. I'll check for PEBKAC issues. Sorry for the stumble.
cs7
@cs7:matrix.org
[m]
Just curious, is there a Rust language backend, would it have tail calls or other features that make it a suitable target. Not a suggestion, just curious.
Marc Feeley
@feeley
@cs7:matrix.org There is no Rust backend currently or in the works. I don’t see immediate advantages to using Rust as a target language… it is hard to beat C for portability and execution speed. Last time I checked, Rust did not have TCO so a trampoline would be needed, like C/C++. A backend as complete as the C backend is a multi-year effort. An extension to the universal backend for Rust would be an easier task but with unclear optimizability to achieve max performance.
Ben Cornett
@cornett

If I compile the following:

(let loop ((i 0))
  (when (< i 100000000)
    (display i)
    (newline)
    (loop (+ i 1))))

and then pipe the output to head like this

 ./x | head

the pipeline appears to hang. I'm not sure what ./xis doing, since it has no place to write to, but it nevertheless consumes a lot of cpu time.

Jaime Fournier
@ober
does display add a \n?
Bradley Lucier
@gambiteer
No.
Marc-André Bélanger
@belmarca
An equivalent Python program has a different behavior
➜  flub cat foo.py
i = 0
while i < 10000:
    print(i)
    i+=1
➜  flub python3.10 foo.py | head  
0
1
2
3
4
5
6
7
8
9
Traceback (most recent call last):
  File "/tmp/flub/foo.py", line 3, in <module>
    print(i)
BrokenPipeError: [Errno 32] Broken pipe
Marc Feeley
@feeley

@cornett By default the interpreter uses stdin and stdout as the “REPL channel” to interact with the user. This can be changed with the -:dc runtime option so that the REPL channel is connected to the controlling terminal. This allows observing the error:

$ cat head.scm
(let loop ((i 0))
  (when (< i 100000000)
    (display i)
    (newline)
    (loop (+ i 1))))
$ gsi -:dc head.scm | head
0
1
2
3
4
5
6
7
8
9
*** ERROR IN ##wr-substr -- Broken pipe
(write-substring "923" 0 3 '#<output-port #2 (stdout)>)

So when the -:dc option is not used the runtime system will attempt to output this error message on the REPL channel which is stdout, but this generates a similar error that the runtime system tries to output to stdout, and an infinite error loop results.
In the past Gambit used the controlling terminal for the REPL channel, but this was changed because users found this to give surprizing behavior, in particular they expect echo "(+ 1 2) (exit)" | gsi to feed the REPL with commands, which did not work when the controlling terminal is used as the REPL channel.
If you prefer the old behavior, you could set the GAMBOPT environment variable with export GAMBOPT=dc

Note also that you can get more context for the error by adding 2 or 3 to the -:d runtime option:
$ gsi -:d2c head.scm | head
0
1
2
3
4
5
6
7
8
9
*** ERROR IN ##wr-substr -- Broken pipe
(write-substring "923" 0 3 '#<output-port #2 (stdout)>)
0  ##wr-substr             
1  ##write-generic-to-character-port 
2  ##display               
3  loop                    "head.scm"@3:5          (display i)
4  (interaction)           "head.scm"@1:1          ((letrec ((loop (lambda (...
5  ##load                  
6  ##load                  
7  ##main                  
$ gsi -:d3c head.scm | head
0
1
2
3
4
5
6
7
8
9
*** ERROR IN ##wr-substr -- Broken pipe
(write-substring "923" 0 3 '#<output-port #2 (stdout)>)
0  ##wr-substr             
1  ##write-generic-to-character-port 
2  ##display               
3  loop                    "head.scm"@3:5          (display i)
        i = 923
        loop = (lambda (i) (if (< i 100000000) (begin (display i) (newlin... #3
4  (interaction)           "head.scm"@1:1          ((letrec ((loop (lambda (...
5  ##load                  
6  ##load                  
7  ##main
Marc Feeley
@feeley
Yet another option is the -:d0 runtime option that does not output error messages, so the infinite error loop is not even entered:
$ gsi -:d0 head.scm | head
0
1
2
3
4
5
6
7
8
9
$
Ben Cornett
@cornett
@feeley Thanks Marc! That makes sense now. I also appreciate the effort you have put into the debugging facilities. Some other scheme implementations I've used leave a lot to be desired in that regard.
cs7
@cs7:matrix.org
[m]

(Repeat,) there will be a video call a bit later this year with Marc to learn more about compiler internals.

Datetime TBD. Feel free to signal interest to me and i’ll remind when it approaches.

Bob Coleman
@skilldown
@cs7:matrix.org I'm definitely interested in the call. Gambit@30 was a blast and I'd love to learn more about the compiler.
Bheesham Persaud
@bheesham

hey all. i seem to be having trouble compiling gambit (just cloned from github) on fedora 36 (GCC 12.1.1)

the output is

gcc -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -foptimize-sibling-calls -fomit-frame-pointer -march=native -fPIC -fno-common -mpc64
    -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -foptimize-sibling-calls -fomit-frame-pointer -march=native -fPIC -fno-common -mpc64
   -rdynamic  -I"../include"  -o gsi    _gsi.o _gsi_.o "../lib/libgambit.a"  libgambitgsi.a                                                                                                                                      
/usr/bin/ld: ../lib/libgambit.a(_num.o): in function `___H___num':                         
_num.c:(.text+0x25b73): undefined reference to `log1p'                                                          
/usr/bin/ld: _num.c:(.text+0x25c9f): undefined reference to `atan'                                              
/usr/bin/ld: _num.c:(.text+0x2652e): undefined reference to `log' 
/usr/bin/ld: _num.c:(.text+0x26df6): undefined reference to `exp'  
/usr/bin/ld: _num.c:(.text+0x26f12): undefined reference to `exp'

the configure command was:

./configure --enable-single-host --enable-march=native --enable-dynamic-clib

I can get further if I add CFLAGS="-lm" to my environment, but it just fails past that. did anyone run into this before? is there something i'm missing?

Bheesham Persaud
@bheesham

though, interestingly the docker build passes. I tried with:
./configure --enable-single-host --enable-march=native --enable-dynamic-clib && docker build -t gambit .
(again in a fresh repo)

hhmmm... I'm not too sure what's going on here

Bheesham Persaud
@bheesham
ah! so i think there's something wrong with my machine (or potentially some flags?) -- i was able to build gambit using fedora:latest (see this Dockerfile: https://gist.github.com/bheesham/13b690846017b01ad7aec1b49ef498a4)
Bheesham Persaud
@bheesham
uh, nvm, seems like asking for help fixed my problem. I ended up calling a bunch of variations of ./configure and now the original command works. :tada:
Marc Feeley
@feeley
@bheesham could you explain what worked? some other people have encountered a similar experience so it would be good to point them to a solution.
4 replies
cs7
@cs7:matrix.org
[m]
feeley (Marc Feeley): Is the Gambit wiki obsoleted?
Marc Feeley
@feeley
@cs7:matrix.org The Gambit wiki is no longer being updated and is in read-only mode (because there was too much spam). I don’t have time to police it or maintain it but if someone wants to do it then that would be OK. So the current plan is to keep it as-is for people who want to find some documentation there (and for hyperlinks to the wiki to remain valid)
cs7
@cs7:matrix.org
[m]
Aha. Uu. Wait, only email signuped users had write access wasn’t it
What about just saying after email signup also needs moderator approval?
Marc Feeley
@feeley
there was a captcha but that wasn’t foolproof…
The wiki was never very active and there were only a few contributors… if someone wants to maintain it I can give them access.
cs7
@cs7:matrix.org
[m]
Invite only wiki makes sense
Bheesham Persaud
@bheesham

may I have an invite to the wiki please? there's a quick link I want to update.

the link to the mailing list on https://gambitscheme.org/wiki/index.php?title=How_to_contribute is broken, as reported in gambit/gambit#750, similar to gambit/gambit#495 (now closed)

Marc Feeley
@feeley
I have changed the settings on the wiki so that all current users can edit pages. I’ll add new users manually so I can filter out spammers. So if you want an account please DM or email me. If there is enough interest we can un-phase-out the wiki...
Bheesham Persaud
@bheesham
thank you! :)

re: the flags used to configure gambit

I'm not entirely sure what to think about that. it seems strange that I'd need to build with --enable-dynamic-clib (or any of the variations I found to work) and then pass in all the flags I want afterwards

Steve Bigham
@vesten
Can I make a c-lambda procedure from a variadic C function?
Marc-André Bélanger
@belmarca
says no in the doc, maybe write surrogates up to N args?
Steve Bigham
@vesten
Thanks @belmarca . It's absolutely clear in the docs. I can't believe I missed that.
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
hello gambit people!
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
I am interested in bootstrapping gambit without using any prebuilt artefacts. From what I am reading gambit has pregenerated C files that can be compiled with a regular C compiler which then builds gambit and starts the bootstrap chain. Is it possible to create those C files from scratch, with an older version of gambit or something?
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
by bootstrapping I mean this: https://bootstrappable.org/
Marc-André Bélanger
@belmarca
It's turtles all the way down!
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
hey its me again ha!
Bradley Lucier
@gambiteer
Do you have a Scheme interpreter already in your system?
Marc-André Bélanger
@belmarca
they seem to make the distinction between "self hosted" and "bootstrapped", but the "bootstrapping" process is precisely that which allows the compiler to compile itself
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
I can have, such as guile
Marc-André Bélanger
@belmarca
So in essence, it's turtles all the way down - who compiles the compiler?
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
a lot of times its required to have an alternative compiler to compile the compiler
or go backwards to an earlier version of the compiler, before it was self hosted
(and then start working from version to version, very painfully :p)
Marc-André Bélanger
@belmarca
which begs the question, who compiles the alternative compiler?