leif
2020-9-28 15:50:57

Re the := ohhh, okay.


leif
2020-9-28 15:51:26

Actually, I think your := syntax is better than the dotted identifiers…it just wasn’t documented so I missed it.


leif
2020-9-28 15:52:14

And references to dotted identifiers works fine, just not binding. So I can add the issue. :slightly_smiling_face:


leif
2020-9-28 15:52:57

I see. So basically either external tools or functions are my options. Thanks for the heads up. :slightly_smiling_face:


soegaard2
2020-9-28 15:53:19

I need to do something about the lack of documentation.


soegaard2
2020-9-28 15:55:10

That - or if you need only a few external libraries - simply load them from a cdn.


leif
2020-9-28 15:58:32

Unfortunately, since I’m trying to make a tool that can be used entirely offline, I don’t think that works. :disappointed:


leif
2020-9-28 15:58:35

Thanks though.


leif
2020-9-28 15:59:00

Unless I use some caching stuff, then it might work…


soegaard2
2020-9-28 16:05:09

Okay. No Skypack then :slightly_smiling_face:


soegaard2
2020-9-28 16:05:52

You are not the first to wonder where assignment to dotted identifiers are.


leif
2020-9-28 16:05:52

Sadly no. :slightly_smiling_face:


leif
2020-9-28 16:10:51

@soegaard2 I guess one feature request that would be nice (that is sort of there do to macros) is unquote.


leif
2020-9-28 16:11:19

That way I could, say, use @~a{} in urlang.


leif
2020-9-28 16:11:49

I guess I could just make an unquote macro myself though. :slightly_smiling_face:


soegaard2
2020-9-28 16:12:05

To do string interpolation?


leif
2020-9-28 16:13:05

Yup


leif
2020-9-28 16:13:19

Basically, so I could do something like:


leif
2020-9-28 16:14:08

(JSON.parse @~a{{"name":"bob","age":28}})


leif
2020-9-28 16:14:11

Instead of:


leif
2020-9-28 16:15:08

(JSON.parse "...\"...\"...\"...\"...")


leif
2020-9-28 16:15:26

I mean, in that particular case I’d be better off using JSON.stringify, but I think you get the idea. :slightly_smiling_face:


leif
2020-9-28 16:16:20

(That is, JSON.stringify combined with object.


soegaard2
2020-9-28 16:24:33

So this: (define x 28) ; pure Racket (define name "Bob") ; start of Urlang module (urlang (urmodule foo (JSON.parse @si{{"name":@name,"age": @age}}))) is expected to work?

Where si is short for string-interpolate. (or perhaps sl for string-literal.)?


leif
2020-9-28 16:27:25

I mean, something like that would be cool.


leif
2020-9-28 16:27:38

But ya, I can just make that macro easily enough.


soegaard2
2020-9-28 16:32:18

Or something like this: (urlang (urmodule foo (var [age 28] [name "Bob"]) (JSON.parse @si{{"name":@name,"age": @age}})))


soegaard2
2020-9-28 16:32:53

I.e. do you need the interpolated variables to refer to Racket or Urlang variables?


leif
2020-9-28 16:33:06

Racket ones.


leif
2020-9-28 16:33:26

urlang ones would be much harder.


leif
2020-9-28 16:33:45

(Although cool, seems like that’s more of a JS problem.)


leif
2020-9-28 16:33:51

With existing JS solutions.


soegaard2
2020-9-28 16:37:39

I am wondering whether a lifting mechanism is needed? (For evaluating the unquoted expressions)


leif
2020-9-28 16:40:28

I don’t think so?


leif
2020-9-28 16:40:46

Like, couldn’t you just use #, inside of an urlang macro?


leif
2020-9-28 16:41:28

Ah, wait, no, that would be at phase 1.


leif
2020-9-28 16:41:32

Thinking…


soegaard2
2020-9-28 16:42:35

Phase 1 for Urlang is phase 0 for Racket, so maybe it is okay?


leif
2020-9-28 16:42:54

OH, ya


leif
2020-9-28 16:43:00

Right, I think it would be


leif
2020-9-28 16:43:02

let me try it:


leif
2020-9-28 16:48:18

Mmmm….actually, being at phase 0 makes binding identifiers tricky.


leif
2020-9-28 16:48:45

Like, I can get the syntax name, but I think I’d have to evaluate it to get the value its bound to.


soegaard2
2020-9-28 16:50:51

Yes. One option is namespace-variable-value or eval . But maybe the urlang form can lift expressions from within urmodule ?


leif
2020-9-28 16:51:34

Okay, got it


leif
2020-9-28 16:51:36

but eww…


leif
2020-9-28 16:51:38

#lang scratch (require urlang) (define name "BOB") (define-namespace-anchor anch) (define-urlang-macro amac (syntax-parser [(_ a ...) #`#,(eval-syntax #'(~a a ...) (namespace-anchor->namespace anch))])) (urlang (urmodule testing @amac{Hi, my name is: @name}))


leif
2020-9-28 16:52:08

I see what you mean by lifting now though.


soegaard2
2020-9-28 16:52:29

It’s not too bad :wink:


leif
2020-9-28 16:52:48

I mean, its fine. But it does throw away @mflatt’s you want it when idea. :wink:


soegaard2
2020-9-28 16:52:58

Yep.


leif
2020-9-28 16:53:31

I wonder if its possible to tie an urlang macro with a racket macro though.


leif
2020-9-28 16:53:37

That way we wouldn’t need eval at all…


leif
2020-9-28 16:53:41

thinking about that now.


soegaard2
2020-9-28 16:53:55

Oh… that’s worth a try.


soegaard2
2020-9-28 16:54:15

I’ll be back later - I am going for a small walk (but it’s getting dark soon).


leif
2020-9-28 16:55:59

okay, enjoy. :slightly_smiling_face:


leif
2020-9-28 19:16:44

@soegaard2 Hmmph….ya, I got nothing (for the moment).


leif
2020-9-28 19:17:18

I think it might be possible in the urlang code generator, I’ll check it out later.


leif
2020-9-28 19:17:23

Anyway though, thanks for your feedback.


leif
2020-9-28 19:17:46

I guess I’ll ask one more JS question:


leif
2020-9-28 19:18:39

Do you know of a JS serialization library that works similarly to racket/serialize (obviously it wouldn’t be identical. But I more just mean, something capable of serializing and deserializing a circular javascript object.)


leif
2020-9-28 19:18:44

Like…:


leif
2020-9-28 19:19:01

x = {a: false} x.a = x


leif
2020-9-28 19:19:22

If not that’s okay, I suspect something like that is easy enough to write (just a graph traversal.)


soegaard2
2020-9-28 19:19:22

I have been about it too. I am inclined to think, that the cleanest solution is to add an <racket-literal> to the rule: ; <datum> ::= <fixnum> \| <flonum> \| <string> \| #t \| #f


leif
2020-9-28 19:19:50

Yes, that would work.


soegaard2
2020-9-28 19:20:31

I haven’t thought it through though.


leif
2020-9-28 19:20:33

Doing that would also make it easier to, say, add objects as hash tables.


soegaard2
2020-9-28 19:21:21

An alternative is to produce the entire urmodule as the output of a racket macro.


leif
2020-9-28 19:21:21

I think the biggest limitation would be that someone may want to generate expressions (through syntax objects), although that one should be possible with urlang macros.


leif
2020-9-28 19:22:03

> An alternative is to produce the entire urmodule as the output of a racket macro. Heh, that’s actually what I’m currently doing. ;)


soegaard2
2020-9-28 19:22:06

Wrt serialization: I know just a little JavaScript, so I only know of JSON.


leif
2020-9-28 19:23:29

Okay.


leif
2020-9-28 19:24:10

Basically just looking for an easy way to convert a circular object to json and back. I’ll look into it more later, thanks. :slightly_smiling_face:


soegaard2
2020-9-28 19:24:26

leif
2020-9-28 19:27:50

Oh cool, thanks. :slightly_smiling_face:


leif
2020-9-28 20:46:36

Oof though:

> const JSPON = require('jspon') > y = {"y":{"$ref":"$"}} { y: { '$ref': '$' } } > JSPON.parse(JSPON.stringify(y)) <ref *1> { y: [Circular *1] }


leif
2020-9-28 20:47:51

Although I think that would still work if I wrangled/unwrangled the data before serialization/after deserialization.


leif
2020-9-28 20:47:59

Anyway thanks. :slightly_smiling_face:


cris2000.espinoza677
2020-9-28 21:27:38

can one make a C extension for Racket CS?


mflatt
2020-9-28 21:49:12

Not in the same sense as Racket BC. For both variants, it’s better to use ffi/unsafe to access C functionality from the Racket side. Making a new, C-implemented shared object to provide an API friendly to ffi/unsafe can be a good idea, though.


cris2000.espinoza677
2020-9-28 21:50:35

oh i see, is there any article i can look into? there does not seem to be a section for that for racket cs only for bc


cris2000.espinoza677
2020-9-28 21:53:41

mmm… i know ppl are busy, but im trying to use https://github.com/tesseract-ocr/tesseract\|tesseract (an ocr) with ffi, im using this <https://github.com/tdhintz/tesseract4win64|prebuilt dynamic library (.dll)> (x64) since i had trouble building tesseract myself… i get a win_err=126 and i have no idea why, it’s in a relative position to the script, and i suppose persmissions isnt an issue


mflatt
2020-9-28 21:59:07

I’m not sure I understand the question, but when using ffi/unsafe, there’s not much difference between BC and CS (although there are a few corners where there are documented differences). The unsafe/ffi documentation is different than the “Inside Racket” document. The unsafe/ffi documentation with the examples at https://docs.racket-lang.org/foreign/intro.html should work in both.


cris2000.espinoza677
2020-9-28 22:00:55

ah i mean if you can make a C extension for racket CS like in racket BC as described in <https://docs.racket-lang.org/inside/Writing_Racket_Extensions.html|Writing Racket Extensions>


mflatt
2020-9-28 22:02:36

No, you can’t do that for CS, and I would not recommend it for BC.


cris2000.espinoza677
2020-9-28 22:02:54

oh ok, thank you


mflatt
2020-9-28 22:04:20

Did you use something like define-runtime-path to refer to “prebuilt.dll”? Just using "prebuilt.dll" would not necessarily work, since the current directory may not be the enclosing module’s directory.


cris2000.espinoza677
2020-9-28 22:04:41

yes i did


mflatt
2020-9-28 22:07:25

cris2000.espinoza677
2020-9-28 22:07:43

no the one inside the 64x folder, Tesseract.dll is empty as shown by a .dll viewer I downloaded



mflatt
2020-9-28 22:09:15

(Windows will look for dependencies in the executable path, but not necessarily just adjacent to a loaded DLL.)


cris2000.espinoza677
2020-9-28 22:09:31

oh let me check


cris2000.espinoza677
2020-9-28 22:10:42

It works! thank you!!!!!


azriel
2020-9-29 00:22:12

@azriel has joined the channel


azriel
2020-9-29 00:23:13

Hi! Quick question (figured I’d try here before filing on Github).


azriel
2020-9-29 00:25:00

We’re running student code through an automated command line script, something like “racket -l errortrace -t <student.rkt>”. We’d like to evaluate student.rkt in Beginning Student Racket and produce output according to the language used, but it seems that "-l errortrace" reverts to standard syntax. That is, #true becomes #t, lists are formatted with quote notation, etc. Is there a way to turn on errortrace but produce output in, say, Beginning Student syntax?


samth
2020-9-29 01:11:31

There’s certainly a way to do this (DrRacket does it, after all) but you probably have to use errortrace in a less simple way


cris2000.espinoza677
2020-9-29 01:13:45

sorry for the late response, thanks for the link!


azriel
2020-9-29 02:14:49

Thanks. We tried a few things, but “less simple” is beyond my threshold of understanding at this point. You can load up errortrace in code rather than on the command line, which might help, but that’s not compatible with the -t option, because you can’t load it from within a module. Still looking for a suitable workaround.


azriel
2020-9-29 02:15:37

Our current workaround is to run the code twice: once to get the BSL output, and once to get the errortrace info. Yuck.


sorawee
2020-9-29 02:26:01

@azriel: do you have control over the student language setting?


sorawee
2020-9-29 02:26:28

That is, do all students use the same setting?