Is there a way to embedded DSL code into existing code with different syntax? (same file)
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)
It’s worth mentioning drracket has keybinding for drawing the tables
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:
- Given a module (for instance
brag/support
), how do I figure out all the functions/macros that module exports? (In the case ofbrag/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.) - 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.
- 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?
Users usually just read documentation for these information. The documentation should be accurate, and if it’s not, that’s a doc bug.
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
.
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.
3) is a bit more complicated. There’s a package that does the work for you: https://docs.racket-lang.org/whereis/
E.g., > (whereis-module 'parser-tools/lex)
#<path:/Users/sorawee/projects/racket/extra-pkgs/parser-tools/parser-tools-lib/parser-tools/lex.rkt>
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.
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?
@spdegabrielle Kind of like that, but what if I want to mix the syntax of #lang brag and #lang 2d.
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
:
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
@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.
(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.)