
Re the := ohhh, okay.

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

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

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

I need to do something about the lack of documentation.

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

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

Thanks though.

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

Okay. No Skypack then :slightly_smiling_face:

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

Sadly no. :slightly_smiling_face:

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

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

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

To do string interpolation?

Yup

Basically, so I could do something like:

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

Instead of:

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

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

(That is, JSON.stringify
combined with object
.

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.)?

I mean, something like that would be cool.

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

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

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

Racket ones.

urlang ones would be much harder.

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

With existing JS solutions.

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

I don’t think so?

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

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

Thinking…

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

OH, ya

Right, I think it would be

let me try it:

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

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

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

Okay, got it

but eww…

#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}))

I see what you mean by lifting now though.

It’s not too bad :wink:

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

Yep.

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

That way we wouldn’t need eval at all…

thinking about that now.

Oh… that’s worth a try.

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

okay, enjoy. :slightly_smiling_face:

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

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

Anyway though, thanks for your feedback.

I guess I’ll ask one more JS question:

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.)

Like…:

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

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

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

Yes, that would work.

I haven’t thought it through though.

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

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

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.

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

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

Okay.

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:


Oh cool, thanks. :slightly_smiling_face:

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

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

Anyway thanks. :slightly_smiling_face:

can one make a C extension for Racket CS?

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.

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

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

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.

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>

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

oh ok, thank you

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.

yes i did

Is “https://github.com/tdhintz/tesseract4win64/blob/master/Tesseract.dll\|Tesseract.dll” the one you’re using?

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

“https://github.com/tdhintz/tesseract4win64/blob/master/x64/libtesseract400.dll\|libtesseract400.dll”? Does that depend on “https://github.com/tdhintz/tesseract4win64/blob/master/x64/liblept177.dll\|liblept177.dll”? If so, load “https://github.com/tdhintz/tesseract4win64/blob/master/x64/liblept177.dll\|liblept177.dll” first.

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

oh let me check

It works! thank you!!!!!

@azriel has joined the channel

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

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?

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

sorry for the late response, thanks for the link!

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.

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

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

That is, do all students use the same setting?