wanpeebaw
2021-1-6 10:12:52

Is there a way to embedded DSL code into existing code with different syntax? (same file)


hazel
2021-1-6 14:58:00

open a temporary file, write the code as a string to it, and then dynamic-require the functions you need. (disclaimer: this is a joke, please do not actually do this)




spdegabrielle
2021-1-6 16:30:25

It’s worth mentioning drracket has keybinding for drawing the tables


cdep.illabout_slack
2021-1-7 06:37:52

I’ve been playing around with Racket for about a month now, and I’ve had some problems with the documentation. There seem to be a couple basic features that I just can’t figure out:

  1. Given a module (for instance brag/support), how do I figure out all the functions/macros that module exports? (In the case of brag/support, there is <https://docs.racket-lang.org/brag/index.html?q=brag%2Fsupport#%28mod-path._brag%2Fsupport%29|some documentation> that explains what is being re-exported from other modules, but I can’t seem to find some sort of programatically generated list of all available functions/macros.)
  2. Given a package, how do I figure out all the modules that package exposes? For instance, for the package https://pkgs.racket-lang.org/package/brag-lib\|brag-lib there is a list of modules, but it is hard to tell which are intended to be used, and which are just tests/examples/something else. Also, ideally I would be able to click on a module and then see all of the functions/macros that module exports.
  3. Given the documentation for a function (or macro), how do I find the source code for its definition? For instance, given the https://docs.racket-lang.org/brag/index.html?q=brag%2Fsupport#%28def._%28%28lib._brag%2Fsupport..rkt%29._token%29%29\|token function, how do I find how it is implemented?

sorawee
2021-1-7 06:54:03

Users usually just read documentation for these information. The documentation should be accurate, and if it’s not, that’s a doc bug.


sorawee
2021-1-7 06:54:50

I’m not sure if I understand your questions correctly. For 1), are you saying that there are things that are not documented in brag/support? If so, it would be nice to report the issue to brag.


sorawee
2021-1-7 06:55:27

For 2), you can just go through the documentation. That list in the package website might not be useful, because as you said, it includes several stuff that is not intended for users to see.


sorawee
2021-1-7 06:56:43

3) is a bit more complicated. There’s a package that does the work for you: https://docs.racket-lang.org/whereis/


sorawee
2021-1-7 06:59:27

E.g., &gt; (whereis-module 'parser-tools/lex) #&lt;path:/Users/sorawee/projects/racket/extra-pkgs/parser-tools/parser-tools-lib/parser-tools/lex.rkt&gt;


sorawee
2021-1-7 07:06:42

Specifically for 1) and 2), the problem is that what’s considered “for users” might not be apparent to Racket. So package authors usually use documentation to specify this information.


sorawee
2021-1-7 07:09:06

For example, a lot of packages have a convention that private directory indicates private stuff that users should not use directly. But it’s in fact totally fine to (require drracket/private/blah). How can Racket know which is public and which is private?


wanpeebaw
2021-1-7 07:24:59

@spdegabrielle Kind of like that, but what if I want to mix the syntax of #lang brag and #lang 2d.


soegaard2
2021-1-7 07:32:55

I believe ragg and brag are built on top of parser-tools, so I expect token to be defined in parser-tools and then reexported. The documentation on brag says:


soegaard2
2021-1-7 07:34:15

According to the docs for parser-tools the value field is named value, so maybe I am wrong? https://docs.racket-lang.org/parser-tools/Lexers.html?q=token#%28tech._token%29


cdep.illabout_slack
2021-1-7 07:58:28

@soegaard2 Ah, sorry, I should have made clear that I don’t actually have those questions about brag (because I am already looking through its source code on github), but they were just to illustrate the questions I was asking.


cdep.illabout_slack
2021-1-7 07:59:13

(Although I do feel like the fact that you weren’t able to look at the documentation and immediately answer the question is somewhat of a point in favor of the documentation not having enough functionality.)