ryanc
2020-3-4 12:12:02

No, Racket preserves source location for syntax constants. Many versions ago, it didn’t. If you have syntax properties you want to persist across compilation, make sure they are preserved syntax properties.


greg
2020-3-4 13:14:03

@robby To bounce a handy-wavy idea off you: Could the contract system, when provide-ing a wrapper with some synthesized name, set a syntax property with the identifier of the thing being wrapped? So that things like drracket/check-syntax could give that identifier to identifier-binding (making jump-to-definition work in more cases)?


robby
2020-3-4 13:36:31

Yes, the contract system can cooperate with some protocol to help people jump from references to definitions past the contract.


robby
2020-3-4 13:36:55

I’ve found that, in the past, however, that jumping to the contract-out and then jumping from there to the actual definition is useful.


robby
2020-3-4 13:37:18

(I didn’t follow this conversation tho)


sorawee
2020-3-4 14:25:39

Thank you!


sorawee
2020-3-4 14:32:51

I want racket foo.rkt to have a regular behavior, but racket runner.rkt foo.rkt to run foo.rkt with a behavior of a macro modified. How can I do that?

Here are what I tried (and failed):

  • Define a syntax parameter which is initially #f. In the macro, use syntax-parameter-value to check if the parameter is #t or #f and rewrite accordingly. In runner.rkt, (syntax-parameterize ([... #t]) (dynamic-require the-file #f))

  • Define a parameter at phase 1 which is initially #f. In runner.rkt’s phase 1, set the parameter to #t. In phase 0, (dynamic-require the-file #f).

In both approaches, the {parameter, syntax-parameter} is always #f in the macro, even when running via runner.rkt.


capfredf
2020-3-4 14:40:28

I think I would use subprocess instead of dynamic-require. In doing so, add different flags to run foo.rkt, like foo.rkt --mode1 or foo.rkt --mode2 . In the runner.rkt, I would be able to run foo.rkt with subprocess in the specific mode


sorawee
2020-3-4 14:44:06

Thanks. Will use this approach if there’s no better solution. One problem with this approach is that foo.rkt might need to parse command line argument, and it would be difficult to design these “meta flags” in a way that doesn’t conflict with the actual flags.


sorawee
2020-3-4 14:46:01

(the same argument applies to subprocess + environment variable, but I guess environment variable might be a little more flexible)


deactivateduser60718
2020-3-4 14:47:17

That seemed to do it, thank you. I would not have figured that one out easily


mflatt
2020-3-4 14:51:26

If you control the language of foo.rkt, then I’d have the expansion of foo.rkt generate two modules: the main module with the default-expansion binding of the macro, and a submodule for the alternate macro binding. Then, runner.rkt can load the submodule.


soegaard2
2020-3-4 16:04:46

I figured it out by comparing the docs for eval and eval-syntax. One difference is that eval “enriches” the syntax object and eval-syntax doesn’t. Part of the puzzle is namespace-syntax-introduce.


deactivateduser60718
2020-3-4 16:21:38

I ended up stumbling on https://stackoverflow.com/questions/32061267/difference-between-eval-and-eval-syntax#32066856 (You were there in 2015!) I still don’t understand what it means for namespace-syntax-introduce to override top-level lexical information. Can I get more specifics?


carlosrogue
2020-3-4 17:45:09

Hello, living inside parens fellas, quick question, I just found this Clojure to Scheme library: https://github.com/wvdlaan/clojure-scheme\|https://github.com/wvdlaan/clojure-scheme and I wanted to know if anybody knows about something similar but for Scala (yes, you read right, Scala :smile:)



soegaard2
2020-3-4 17:47:56

Odd place to ask…


carlosrogue
2020-3-4 17:50:19

So, I just should use Dotty AST and generate racket code, right?


soegaard2
2020-3-4 17:50:34

Note that the link goes to a specific section - slack is showing the wrong one.


soegaard2
2020-3-4 17:51:41

I think the odds for a nice answer is better in a Scala slack :slightly_smiling_face:


carlosrogue
2020-3-4 17:54:08

Then, my Initial question mentioned: Clojure to Scheme, now I question if somebody knows about Scala to Scheme


carlosrogue
2020-3-4 17:54:56

I can’t ask Scala devs they do not know about Scheme


carlosrogue
2020-3-4 17:55:26

Not all of them, off course, but I will ask anyways. Thanks @soegaard2


soegaard2
2020-3-4 17:56:05

Well you’d be surprised. Noel Welsh for one is an old Schemer.


carlosrogue
2020-3-4 19:01:01

Off course, I was talking about avg. Scala dev (I am one of those) and I do know programming gods walk amongs us, :smile:


d_run
2020-3-5 00:08:21

If I wanted to create a logger that took structured messages (ex: hasheq?) instead of string? would I essentially need to roll my own logging system from scratch or is there a way to wrap log-message (https://docs.racket-lang.org/reference/logging.html?q=logging#%28def._%28%28quote._~23~25kernel%29._log-message%29%29) and friends?


samth
2020-3-5 02:26:39

Can’t you just use the data argument to log-message?