d_run
2021-8-14 16:33:33

:wave: working on porting some of my existing libs over to RacketScript to see what primitives are missing. Looks like open-input-bytes is one of them. Is there a general strategy on handling ports?


d_run
2021-8-14 16:37:13

Looking at /compiler/runtime/core/ports.js


d_run
2021-8-14 16:39:41

Looks like it needs to be implemented in kernel.rkt


d_run
2021-8-14 16:43:24

Looks like we need to implement all the open-input-* procs?


soegaard2
2021-8-14 16:54:41

FWIW there is an implementation of open-input-string in urlang/rjs: Don’t know whether you can get some ideas. (Note: The syntax in that file looks like Racket, but it’s just JavaScript in S-expression form)

https://github.com/soegaard/urlang/blob/master/compiler-rjs/runtime.rkt


soegaard2
2021-8-14 16:58:15

The representation of string ports are explained here: https://github.com/soegaard/urlang/blob/master/compiler-rjs/runtime.rkt#L2564


d_run
2021-8-14 17:18:04

Nice thanks for that.


d_run
2021-8-14 17:18:24

(RacketScript) Looks like write is implemented but not read?


soegaard2
2021-8-14 17:21:05

Yes. At the time the Racket reader was implemented in C so I couldn’t just use that. However, I knew Flatt was working on moving to ChezScheme, which meant that with a little patience a reader in Racket would available.


soegaard2
2021-8-14 17:22:09

In hindsight I ought to have implemented a simple reader.


d_run
2021-8-14 20:06:10

Is there a JS equivalent of <eof> that we return?


d_run
2021-8-14 20:06:17

Just using null?