ryanc
2019-6-6 09:36:45

@lexi.lambda I think (and a test agrees) that marshalling and unmarshalling doesn’t make distinct uninterned symbols equal, but it can make equal uninterned symbols unequal. But if the uninterned symbol stays within a single compiled module, it should work as expected.


ryanc
2019-6-6 09:41:22

Marshalling compile-time gensym-generated symbols is still bad, though, because it breaks deterministic compilation. But that’s because the gensym counter doesn’t follow the rules for independent compilation of modules, and that affects the symbol names.


samth
2019-6-6 14:00:07

I think it was @notjack’s — at least, he did all the work


matias
2019-6-6 16:28:33

Are exceptions future safe?


matias
2019-6-6 16:29:06

er no, thinking about it I suppose they couldn’t be in the general case.


matias
2019-6-6 16:29:30

I’m asking about the case where the exception is thrown and caught in the future.


soegaard2
2019-6-6 16:32:05

From the docs: “Similarly, work in a future is suspended if it depends in some way on the current continuation, such as raising an exception. A suspended computation for a future is resumed when touch is applied to the future.”


soegaard2
2019-6-6 16:34:40

Can would-be-future be used to make an experiment that tests this?


notjack
2019-6-6 16:41:36

I think gensym should never be used


alexknauth
2019-6-6 16:42:39

Should we use (string->uninterned-symbol "temp") instead? /s


notjack
2019-6-6 16:42:44

notjack
2019-6-6 16:43:30

Definitely not :p



pocmatos
2019-6-6 18:40:08

Does anybody know if there’s an interface to compile a module down to a linklet and obtain that linklet? I can see compile-linklet from racket/linklet. That should allow me to compile the linklet once I get ahold of it, but I can’t seem to find something akin to expand that will take my module and spit out a linklet bundle/directory for it.


notjack
2019-6-6 19:11:13

@pocmatos don’t know, but FYI one module compiles to multiple linklets (because phases, mostly) and one source file can contain multiple modules


pocmatos
2019-6-6 19:12:27

@notjack right, that’s the linklet directory. that’s what I would like to have. :slightly_smiling_face: trying to find some code already doing that but not being very lucky at that.


notjack
2019-6-6 19:21:45

@pocmatos I want that too, so if you find something let me know. If you don’t find anything, consider opening an issue in rebellion asking for a nice source-to-linklets compilation API :p


pocmatos
2019-6-6 19:22:31

I will remember that. I heard the maintainer is open to feature requests. :slightly_smiling_face:


pocmatos
2019-6-6 20:04:14

I am trying just now to run the benchmarks to automate this process in CI. I have attempted the run.rkt script in shootout but it breaks due to a missing current-bm.rkt. I was luckier with auto.rkt but I assume that using your mini-bar-plot script I can get fancier results. It seems to take a file as input but I don’t quite get what this file is.


samth
2019-6-6 20:16:35

@pocmatos there isn’t something like that, and adding it would require being more specific about what you actually want


samth
2019-6-6 20:17:18

in particular, what do you want to do with compile-time computation? do you want to get those linklets? or just run them?


pocmatos
2019-6-6 20:18:42

ok


pocmatos
2019-6-6 20:19:19

so at a certain point in this presentation: https://www.youtube.com/watch?v=t09AJUK6IiM&t=894s


pocmatos
2019-6-6 20:19:36

^- by the way, for those who haven’t watched it, you should!


pocmatos
2019-6-6 20:20:28

in any case, @mflatt makes the case that given linklets we currently implement compile-linklet and a couple of other functions and get a different backend. Either normal racket or racketcs.


pocmatos
2019-6-6 20:21:15

So, in principle to compile racket to language X you should be able to grab a linklet and compile to X.


pocmatos
2019-6-6 20:21:43

and then you get Racket -> X.


pocmatos
2019-6-6 20:23:28

I wanted to attempt to do something like this. Implement in Racket, a Racket transpiler to Javascript using the nanopass framework. This would be for my own edification, so I am not concerned about getting all of racket or make it production complete.


samth
2019-6-6 20:23:44

That isn’t really an accurate summary of how it works


pocmatos
2019-6-6 20:24:00

That might be a problem indeed. :slightly_smiling_face:


samth
2019-6-6 20:24:02

Let me try to phrase it simply


samth
2019-6-6 20:24:10

and then I can clarify as needed


samth
2019-6-6 20:24:23

To write a racket implementation, you do the following:


samth
2019-6-6 20:25:22
  1. write an implementation of compile-linklet and instantiate-linklet (ie, write an interpreter for the linklet language)

samth
2019-6-6 20:25:55
  1. call compile-linklet and instantiate-linklet ~in~ on the linklet extracted from the expander

samth
2019-6-6 20:26:34

step 2 gives you a bunch of values in the resulting linklet instance, which are named things like eval and read and current-namespace


samth
2019-6-6 20:26:56
  1. set up some initial state for the expander

samth
2019-6-6 20:27:37
  1. call eval (or similar eval-like functions like dynamic-require) on things

samth
2019-6-6 20:27:48

That’s basically it


pocmatos
2019-6-6 20:29:24

ok. so although i didn’t get the details it’s not very far from what I expected. However, at the moment you can’t actually get step 2. You say linklet extracted from the expander but the expander gives you a fully expanded program, not a linklet. As far as I understand, they are not the same thing.


pocmatos
2019-6-6 20:30:56

So back to my initial question, what I really wanted was for a way to extract this linklet in racket. Something like extract-linklet (-> path-string? linklet?)


pocmatos
2019-6-6 20:31:43

or as mentioned earlier it would probably be a linklet-directory?, not just a linklet?


pocmatos
2019-6-6 20:32:41

My idea initially was to actually start the transpiling experiment from fully expanded programs. It was only after some research that I though… ah, maybe I should get fancy and do it using linklets… and my evening is suddenly gone. :slightly_smiling_face:


pocmatos
2019-6-6 20:35:04

The whole point of this is my own education. I am working at the moment on JavaScript JIT and GC technologies and I thought I should spend some time learning more about JavaScript. And what better way is there than to try to transpile Racket to Javascript…


samth
2019-6-6 20:39:19

sorry, step 2 should say “on”


samth
2019-6-6 20:40:03

The fundamental issue is that compile-linklet and instantiate-linklet are designed to be called inside the implementation of the expander (ie, inside the defintions of expand and eval)


samth
2019-6-6 20:40:20

you basically don’t call them yourself at all


pocmatos
2019-6-6 20:41:04

so for me to use linklets I need to reimplement expand?


samth
2019-6-6 20:41:50

no


pocmatos
2019-6-6 20:42:02

but expand gives me a fully expanded program, not a linklet. I see the definition of compile-linklet, instantiate-linklet in chez for example but I don’t actually understand how the connection is made.


samth
2019-6-6 20:42:11

you’re getting the direction of calls wrong


samth
2019-6-6 20:42:24

pocmatos
2019-6-6 20:46:01

ok. Thanks. I will take a look at the code and see if I understand how these things fit together.


samth
2019-6-6 20:46:12

but schematically a JS implemenation of racket would look like this: function instantiate_linklet(l, args) { .... } let expander = ... // some ast for the extracted expander linklet let expander_instance = instantiate_linklet(expander, []) while (1) { console.log(expander_instance.get("eval")(expander_instance.get("read")(get_input_from_user()))) }


samth
2019-6-6 20:47:23

where instantiate_linklet contains a core-racket interpreter + a bunch of primitives


pocmatos
2019-6-6 20:48:34

yes, that makes sense. I will need to look better at pycket (don’t think i had heard about it before!!!)


samth
2019-6-6 20:51:52

the other thing to note is that you can turn racket modules into linklets yourself using the various tools that are part of the expander implementation


samth
2019-6-6 20:52:22

but that won’t give you a linklet directory or really a good way to produce a racket implementation


samth
2019-6-6 20:53:14

see for example this entry in racket/src/expander/README: % racket bootstrap-run.rkt -s -c <dir> --linklets -l <module-path> Compiles the given file to a set of linklets in S-expression form, instead of compiling and running it.


pocmatos
2019-6-6 20:53:43

oh… ok, i definitely didn’t know about that. thanks.


samth
2019-6-6 20:54:44

one other thing you might be interested in is this code, from the original way Pycket worked: https://github.com/pycket/pycket/blob/master/pycket/pycket-lang/expand.rkt


samth
2019-6-6 20:55:07

which basically takes a racket source file and produces a JSON file with the fully-expanded result


samth
2019-6-6 20:55:31

that, however, doesn’t go to the linklet layer at all, so you’d still have to implement the module system


samth
2019-6-6 20:56:17

but if you just want to write something quick that doesn’t deal with require or anything else complex, that might be useful


pocmatos
2019-6-6 20:58:35

That might be a good alternative to start. Thanks for the references.


pocmatos
2019-6-6 20:59:02

Do you know who is behind pycket and what’s used for? Looks quite active.


pocmatos
2019-6-6 21:02:02

oh wait… you’re one of the pycket authors…


samth
2019-6-6 21:02:03

me and my students


pocmatos
2019-6-6 21:02:04

embarassing…


pocmatos
2019-6-6 21:02:09

ahahah


samth
2019-6-6 21:02:09

:wink:


pocmatos
2019-6-6 21:02:35

doh! :slightly_smiling_face:


pocmatos
2019-6-6 21:03:26

This project creates a racket implementation in python but doesn’t transpile racket to python.


lexi.lambda
2019-6-6 21:04:01

Thanks, you’re right. I could have sworn there was something related to binding or marshalling uninterned symbols that could cause one to get shot in the foot, but I’m not sure what I was thinking about.


samth
2019-6-6 21:04:27

right


samth
2019-6-6 21:04:45

fundamentally it’s an interpreter for racket written in python


samth
2019-6-6 21:05:02

but using a special dialect/tools that generate a JIT along with that interpreter


pocmatos
2019-6-6 21:05:43

the jit generation would come from rpython.


samth
2019-6-6 21:05:49

yes


pocmatos
2019-6-6 21:06:23

ok, thanks.


mflatt
2019-6-6 21:29:59

The auto.rkt script uses run.rkt, if I remember correctly, so use auto.rkt. When you use auto.rkt, the -o flag copies the output to a file. The min-bar-plot script wants that file.


notjack
2019-6-7 00:43:07

@samth more linklet questions: would sending linklets to a service which instantiates them make sense? would that be a good way to communicate over http with a remote racket runtime?


samth
2019-6-7 00:43:43

@notjack I think a repl with a sandbox makes more sense


samth
2019-6-7 00:44:18

There’s no real need for the linklet level


samth
2019-6-7 00:44:32

And you’d have to run the expander locally


samth
2019-6-7 00:44:39

Which would defeat the purpose


notjack
2019-6-7 00:45:24

linklets are serializable though - I’m wondering if you could store compiled linklets in a database and use that as a reasonable basis for distributed builds


notjack
2019-6-7 00:46:33

it’s okay if you run the expander locally for -your- code, as long as you can download precompiled stuff for your dependencies


notjack
2019-6-7 00:48:27

But I don’t have a feel for this stuff yet. Hard to tell what’s a good idea and what isn’t.


sorawee
2019-6-7 01:06:05

I have a macro m that sometimes expands to (define x 1), and sometimes expands to (void), depending on the operand. Consequently:

(println (m foo))

might or might not result in an error (because function application arguments are supposed to be expressions and not define). I want to make it always an error when people try to use this macro in an expression context. How could I do that?


sorawee
2019-6-7 01:07:32

One possible way is to add a dummy define, though I don’t think that’s a great solution.


lexi.lambda
2019-6-7 01:08:42

You can check what context you’re in with (syntax-local-context).


sorawee
2019-6-7 01:08:52

Right, forgot about that. Thanks :slightly_smiling_face:


lexi.lambda
2019-6-7 01:09:34

There’s also prop:expansion-contexts, but to be honest I’ve never seen it used.


samth
2019-6-7 01:48:59

@notjack Linklets don’t have unique names, though


notjack
2019-6-7 02:27:12

@samth That’s fine. I was thinking something like a /linklets collection you POST to and get back a URL, then an /instances collection you POST a message to that says “I want to instantiate the linklet at this url, and here is a list of other instances to use for the linklet’s imports”


samth
2019-6-7 02:29:01

That seems potentially interesting but I don’t see what linklets buy you over module source code.


notjack
2019-6-7 02:37:27

I’m not sure either. But it seems like a much simpler starting point.


samth
2019-6-7 02:39:46

I really think “sandbox as a service” will be a simpler starting point.


notjack
2019-6-7 02:46:44

Why’s that?


sorawee
2019-6-7 06:33:06

Another question about macro. Suppose I have a recursive helper macro. I want to report a syntax error, so I need to keep around the original syntax object. This involves adding an operand to every case in syntax pattern matching, and also macro invocation, which is really tedious. Is there a way to lift the original syntax up somehow so that I can refer to it in the helper macro without making it an operand?

E.g.

(define-simple-macro (foo . xs)
  #:with this-stx this-syntax
  (helper xs () () this-stx))

(define-syntax-parser helper
  [(_ () accum-var-1 accum-var-2 orig-stx) ...... (raise-syntax-error ...... #'orig-stx) ...... (syntax ......)] ; base case
  [(_ (x . xs) accum-var-1 accum-var-2 orig-stx)
   ...... (syntax ...... (helper xs accum-var-1* accum-var-2* orig-stx) ......)]) ; inductive case

jaklingonzal
2019-6-7 06:45:06

Why did Apple remove all non-Thunderbolt 3 ports? :thinking_face: http://snip.ly/u52g4r


alexknauth
2019-6-7 06:51:16

Does the helper macro have to be a macro, or can you change it into a compile-time helper function?

If it’s a compile-time helper function you can bind the original syntax object in the scope outside the function-definition so that it doesn’t have to be passed as an extra argument.

If the helper does have to be a macro, the only other thing I can think of is using a syntax-parameter, just like a parameter like current-output-port can be used instead of an argument to print.