kartiksabharwal7
2021-5-17 14:26:12

A follow-up to my previous message https://racket.slack.com/archives/C06V96CKX/p1621079039098700. The absence of Racket highlighting in Pandoc-flavored markdown bothered me a great deal so I wrote a Pandoc-compatible Racket syntax definition. Using it is as easy as passing a command-line argument --syntax-definition=racket.xml to Pandoc when generating an HTML or LaTeX document. The XML file with usage instructions and an example is at https://github.com/Fyrbll/pandoc-highlight-racket. Feedback is more than welcome.


soegaard2
2021-5-17 16:33:26

FWIW if you need a list of builtin operations or a (large) regular expression to match numbers, then look here: https://github.com/soegaard/racket-highlight-for-github


kartiksabharwal7
2021-5-17 17:48:12

Thanks! I got a list of builtins from a file in racket-mode. My strategy for numbers on the other hand, is “quick and dirty” and more or less only cares about recognizing a number’s beginning and end. I have assumed that if you’re publishing your code you have probably checked its syntactic correctness using the Racket interpreter. Long story short: thanks for the regex! It’ll surely improve the clarity and reliability of the highlighter.


soegaard2
2021-5-17 17:52:23

@k4rtik It’s the one used on Github now (I believe). There are a test suite for the syntax colorer in DrRacket. These files test quite a lot: https://github.com/racket/syntax-color/tree/master/syntax-color-test/tests/syntax-color


soegaard2
2021-5-17 17:53:48

The numbers are in scheme-lexer.rkt starting at line 467.


kartiksabharwal7
2021-5-17 18:04:54

I see. The tests ought to be handy in the future. I appreciate you sharing those as well.


stamourv
2021-5-17 19:39:08

Some of my students are seeing a strange FASL-related error message, and I’m not sure what’s the cause: fasl-read: incompatible fasl-object machine-type ’ta6osx found in #<binary input port bytevector>

Context: I’m giving my students compiled zo files for libraries they can use for their assignment. I created the zo files on Mac OS. I’ve had students/TAs get that error on both Ubuntu and Windows, but I haven’t seen anyone on Mac get it. And one of my TAs on Windows did not get it either, so not all Windows system seem to have issues, though I’m not sure how his system was different.

We’re all running on Racket 8.0, and I’m assuming all CS. (At least one of them I know was CS.) I’ve used that compiled zo trick in previous quarters, and it worked fine. I’m assuming something changed with CS, but I imagine zo files are still intended to be portable?


samth
2021-5-17 19:42:22

Is it possible that the student on CS has an M1?


samth
2021-5-17 19:42:54

In which case, they would have a different machine type because that’s an ARM processor


stamourv
2021-5-17 19:43:14

We’re all on CS (AFAIK), but it’s the people not on Mac OS who are seeing the error,.


stamourv
2021-5-17 19:43:20

I also just reproduced it on Debian.


samth
2021-5-17 19:43:40

For reliably distributing compiled files you need to use machine-independent zo file


stamourv
2021-5-17 19:43:55

Cool, how can I get one of those?


stamourv
2021-5-17 19:48:37

From a bit of docs reading, sounds like zos generated from BC are machine-independent. So is the solution to just compile them from a BC install?


samth
2021-5-17 19:49:02

no, zo’s generated on BC are machine-indepenent for BC, they won’t work on CS


samth
2021-5-17 19:50:27

you need to use the -M flag to racket


stamourv
2021-5-17 19:51:28

When generating the zos, or when running a program that requires them?


javier123mendoza
2021-5-17 19:52:00

Thank!!


samth
2021-5-17 19:52:29

I think you want to do something like racket -M -l raco -- make foo.rkt


stamourv
2021-5-17 19:53:15

Gotcha. Yeah, it doesn’t look like raco make supports that switch directly. Could be nice.


samth
2021-5-17 19:53:41

yes I think that would be a good addition, but I’m not 100% confident yet that what I suggested works


stamourv
2021-5-17 19:53:52

Trying it now.


stamourv
2021-5-17 19:57:34

It’s taking a while to compile.


stamourv
2021-5-17 19:59:52

The resulting zos work on mac so far, but they’re incredibly slow.


samth
2021-5-17 20:00:38

Yes they will definitely be slower, since they basically need to be compiled


stamourv
2021-5-17 20:01:15

Gotcha. They’re pretty fast on my debian machine, though. And I’m not sure it’s more powerful overall.


samth
2021-5-17 20:01:32

Is one of those bc?


stamourv
2021-5-17 20:01:39

No, all CS.


stamourv
2021-5-17 20:02:38

So I guess I can use these platform-independent zos as a backup, and provide the ones I had before for people on mac, and probably produce some other platform-specific ones for windows and linux. That can probably do for now.


stamourv
2021-5-17 20:02:58

What’s the medium/long term zo portability plan/story?


samth
2021-5-17 20:03:26

CS zos are not portable, and can’t be, and BC zos can’t run on CS.


samth
2021-5-17 20:03:45

The machine independent zo files you generated are the portability story


samth
2021-5-17 20:04:05

If they’re really slow on Mac compared to Linux that sounds like a bug


stamourv
2021-5-17 20:04:50

Ok, I’ll file a bug, then.


stamourv
2021-5-17 20:04:57

The difference is definitely noticeable.


stamourv
2021-5-17 20:05:18

Are these machine-independent zos here to stay, or are they just a stopgap?


badkins
2021-5-17 21:18:40

I agree @popa.bogdanp, I still haven’t gone very far with macros, but Racket is by far my favorite programming language. However, in my case, I think it has much to do with strongly preferring Scheme’s aesthetic over Common Lisp, so that may not help @massung I suppose.

Having said that, the robustness of the language & ecosystem, batteries included, tail call recursion, built-in web server, Dr Racket, community, and many other things are very attractive.

It’s nice to know there is even more awaiting with macros :)


badkins
2021-5-17 21:20:49

I can’t overemphasize the responsiveness of the core team, and the quality of the implementation. Other lisps I’ve looked into just seemed to suffer from a lot of bit rot in the ecosystem.


mflatt
2021-5-17 21:40:32

Using racket -M -l- raco make in your normal distribution is not a good idea.

Did the result load slowly on the machine where you used racket -M and quickly elsewhere?

Machine-independent .zos are here to stay, but there should be better tool support, possibly via raco cross.


stamourv
2021-5-17 21:50:42

It did load slowly locally, and everything else got slow afterwards. Running a regular raco make on a random file brought things back to normal.


stamourv
2021-5-17 21:51:19

Something like raco cross sounds like a good idea. In the meantime, would you recommend I keep a separate install for this kind of cross-compilation?


stamourv
2021-5-17 21:54:41

Or instead of a separate tool, would a flag for raco make make sense? That was the first place I looked.


mflatt
2021-5-17 22:51:44

A flag for make is tricky, because the problem is knowing where to stop when looking at dependencies. Adding to the new raco cross (which is implemented in the raco-cross package) is relatively straightforward.


stamourv
2021-5-17 23:13:47

Right, I see the issue. And that explains the behavior I was seeing; sounds like the whole tree was being recompiled machine-independent.


stamourv
2021-5-17 23:13:51

Thanks!


mflatt
2021-5-17 23:33:06

Yes, exactly.

I’ve added --target any support to raco cross, so the updated package will be available after as the package server notices.


stamourv
2021-5-17 23:38:43

Fantastic! Thanks!


capfredf
2021-5-18 01:37:55

@mflatt #lang racket (struct test (a)) (define tbl (make-hasheq)) (hash-set! tbl (test 1) 42) (hash-set! tbl (test 2) 1024) (for ([(k v) (in-mutable-hash tbl)]) (eprintf "k ~v v ~v ~n" k v)) I understand the iteration order of hash tables is not specified, but it seems the result of the program above with BC is consistent and yet the one with CS is relatively random


samth
2021-5-18 01:58:12

Yes, unfortunately (or fortunately) this is one consequence of the CS implementation


capfredf
2021-5-18 02:00:13

mflatt
2021-5-18 02:54:35

More repairs today, so hopefully tomorrow.