laurent.orseau
2020-10-17 09:14:13

Starting to fell like it wasn’t all time lost, thanks :)


spdegabrielle
2020-10-17 14:11:00

Livestream started! I’m listening to the setup while cleaning the bathroom!


jestarray
2020-10-17 14:32:56

will the racketcon stuff be uploaded to youtube :0?


spdegabrielle
2020-10-17 14:38:34

yes - it is playing now on the racketlang channel


spdegabrielle
2020-10-17 14:39:19

joel
2020-10-17 18:13:17

I’m also in the “being at racket con while doing housework” club


spdegabrielle
2020-10-17 18:36:23

I like the racketmud idea


spdegabrielle
2020-10-17 19:02:53

Can you use Rust with Racket FFI?


yilin.wei10
2020-10-17 19:05:16

@spdegabrielle Rust exposes C-like ABI bindings iirc


spdegabrielle
2020-10-17 19:06:38

Thank you @yilin.wei10


yilin.wei10
2020-10-17 19:28:26

EDIT: Originally posted in beginner, but I think the question is too niche.

This is a bit of an niche question — suppose I have a C function which calls a Racket function multiple times and I want to get all the arguments which it has been called with (for the sake of argument, let’s call the function foo(int)). If this was a Racket function I would use a continuation like this:

(define foo (lambda (%) (shift k (cons % (k '())))))
(displayln
  (prompt
    (foo 1)
    (foo 1)))

However, this doesn’t work in the case that foo is called within the C library — this isn’t entirely surprising and I hypothesized it had to do with the fact that the C ffi used the continuations to do the callbacks and it does indeed work when using prompt-at as expected. Where in the C ffi code would I look to confirm the hypothesis?


dedbox
2020-10-17 19:32:31

Welp, Gather won’t stop crashing, so I guess it’s a Youtube exclusive for me this year. :shrug: Gonna miss seeing everyone this year!!


yilin.wei10
2020-10-17 19:39:28

Also on an unrelated note, first-class continuations are awesome.


samth
2020-10-17 19:40:57

The C FFI doesn’t use first class continuations


samth
2020-10-17 19:41:08

But I think I don’t totally understand your question


yilin.wei10
2020-10-17 19:43:36

Hmm; I’ll post the snippet of code to be concrete


yilin.wei10
2020-10-17 19:44:03

(let ([prompt-tag (make-continuation-prompt-tag)]) (call-with-continuation-prompt (λ () (wl-registry-listen registry (λ (_ name interface version) (shift-at prompt-tag k (cons (list name interface version) (k '()))))) ;; TODO: Probably use a different function — display roundtrip is really too powerful? ; 'wl-display-roundtrip' calls the registered Racket callback multiple times, returning ; the number of callbacks, but we want the data (and (wl-display-roundtrip) '())) prompt-tag))


yilin.wei10
2020-10-17 19:44:28

Originally I simply used a prompt and shift which didn’t work


yilin.wei10
2020-10-17 19:44:56

The functions prefixed with wl- are C functions. I pass in a callback in wl-registry-listen


yilin.wei10
2020-10-17 19:52:07

So I had assumed that it wasn’t working because the C-ffi was using the default prompt.


yilin.wei10
2020-10-17 19:52:14

Does that make sense?


samth
2020-10-17 19:52:58

You can’t capture continuations across the FFI boundary


samth
2020-10-17 19:53:11

That’s why it doesn’t work


yilin.wei10
2020-10-17 19:56:46

But it works when using a separate prompt (the snippet above works…)


yilin.wei10
2020-10-17 19:56:47

?


samth
2020-10-17 20:00:19

Is this on Racket CS or BC?


yilin.wei10
2020-10-17 20:06:32

Ah, I think it’s BC…


samth
2020-10-17 20:06:49

Then I wouldn’t have expected that to work


samth
2020-10-17 20:06:55

But maybe it does


yilin.wei10
2020-10-17 20:07:37

(system-type 'vm) = 'racket means BC right?


samth
2020-10-17 20:07:48

Right


yilin.wei10
2020-10-17 20:07:59

Let me see if CS works as well


jestarray
2020-10-17 20:43:52

is there a download of the racket con live stream because on youtube its painfully slow…


jestarray
2020-10-17 20:44:08

watching on 144p also..


jestarray
2020-10-17 20:44:13

its not my banwidth


jestarray
2020-10-17 20:44:45

i guess eventually youtube will fix it


samth
2020-10-17 20:55:42

It’s streaming nicely for me


badkins
2020-10-17 21:39:25

@jestarray I haven’t had any issues - it may have paused once or twice briefly.


jestarray
2020-10-17 22:02:05

i have no issues streaming it live but the new ones being stored in the youtube channel archive are slow atm


ben
2020-10-17 23:00:12

hi, can I use a syntax class as a contract on a macro?


samdphillips
2020-10-17 23:00:31

I bet @michael.ballantyne knows!


michael.ballantyne
2020-10-17 23:02:03

#lang racket (require (for-syntax racket/contract syntax/parse syntax/parse/experimental/reflect) (for-meta 2 racket/base syntax/parse )) (provide m) ; Option 1, allowing an arbitrary pattern: (begin-for-syntax (define-syntax syntax-parse/c (syntax-parser [(_ p) #'(flat-named-contract '(syntax-parse/c p) (syntax-parser [p #t] [_ #f]))]))) (define-syntax m (contract (-> (syntax-parse/c (_ e:string)) syntax?) (lambda (stx) #'5) 'foo 'bar)) ; Option 2, using a reified syntax class (begin-for-syntax (define (syntax-parse-arg/c cls) (flat-named-contract `(syntax-parse-arg/c ,cls) (syntax-parser [(_ (~reflect arg (cls))) #t] [_ #f])))) (define-syntax m2 (contract (-> (syntax-parse-arg/c (reify-syntax-class string)) syntax?) (lambda (stx) #'5) 'foo 'bar))


ben
2020-10-17 23:02:11

WOW!!!


ben
2020-10-17 23:44:40

hey folks — I have a Typed Racket survey for everyone: https://tinyurl.com/typed-racket-survey

please take a few minutes to fill it out, even if you are brand new to Racket and/or Typed Racket thank you!