@i.am.corpix has joined the channel
I seem to have managed to botch my install of racket, as I get the error when running racket
on the command line: Welcome to Racket v7.7 [cs]. standard-module-name-resolver: collection not found for module path: (lib “racket/init”) collection: “racket” in collection directories: /home/marc/.racket/7.7/collects /usr/share/racket/collects/ … [12 additional linked and package directories]
The installation did work, but somehow today it suddenly kept giving this error message, as well as the following context:
context…: show-collection-err standard-module-name-resolver module-path-index-resolve [repeats 1 more time] module-declared? namespace-require+ thunk_10 call-in-empty-metacontinuation-frame call-with-empty-metacontinuation-frame-for-swap
The first time I saw the message was in Emacs, using Racket mode (to which I am trying to switch as of one/two weeks ago).
I can’t run the REPL or raco or any racket anything, not with sudo or otherwise. Any idea what might have happened to make a previously working install blow up like that? My sense was that it started going wrong while editing code in Emacs - but I am saying this only because for the first 10 minutes I did not see the error message, and then it started popping up all the time, with me thinking that it was a problem with my emacs config.
OK, solved it by reinstalling. I think the issue was that I had manually installed racket after uninstalling the ubuntu-ppa package. But I hadn’t purged the old ubuntu package. Then yesterday I removed some old packages - and Ubuntu helpfully deleted some (but not all) of the directories it associated with the old racket package. Suddenly things stopped working.
Nice feature in the numpy
manual. There is a link to the source on Github - it even links to the correct line.
It ought to be possible with Scribble based docs too.
^as a novice racketeer (correct term?), this is a feature I wish the docs had.
Its not too cumbersome to find the package on github and search for the identifier, but saving a few clicks is always appreciated
I think this is the tool they use: https://www.sphinx- http://doc.org/en/master/usage/extensions/linkcode.html\|doc.org/en/master/usage/extensions/linkcode.html
have you logged it as a FR against racket/scribble
?
No. Go ahead :wink:
I was sort of hoping something similar already existed.
nope
the scribble manual includes a link at the top, but nothing automated https://docs.racket-lang.org/scribble/index.html
some package authors have started to do it too.
The next release will have links to the source.
For a demo, go here: https://snapshot.racket-lang.org/ci-snapshots/20200528-2cca55c38b/doc/getting-started/index.html and click on the title
nice
That’s great - but that’s the source of the documentation. The numpy docs for, say, the function eig
links directly to the source code of eig
.
include section subverts it
Indeed; if you look at the discussion around the PR and issue it talks about that issue.
@soegaard2 I think it would be relatively easy to use similar techniques to link to the appropriate file.
ha that was me
in particular, the defproc
code will know the defining file, and the code for the section should know the package that the module is in. From that, you can do the same thing that I did there.
Was it a JavaScript solution only? I can only find: https://github.com/samth/scribble/commit/2a7ee73062dc4ef74c2165276c85b3c2838a364c
yes, but that was because the necessary info was already there
in the HTML
Got it.
A link to the documentation source sounds awesome! Especially if y’all will be comfortable with “casual” PRs — e.g. someone clones the repo on GitHub only, makes the edit on GitHub only, and doesn’t build or run tests locally. Instead they just rely on CI for the PR. That way, it amounts to a sort of “edit-this-documentation UI by other means”.
yes. it relies on reviewers who will do this and check.
Yes, that’s definitely one of the goals.
As for link to the source of the thing-being-documented (the “real” source code): I think this is nice, too.
My guess is the UX won’t be quite as nice as languages where this has been there from the start, and/or that don’t have real module systems, etc.
I say that from visiting definitions a lot in Racket Mode, to exercise that feature. My impression is that the immediate definition is useful/interesting less often in Racket, than in (say) Clojure or Emacs Lisp. Because more often the Racket definition is just a little layer of indirection, or was created by a macro, etc.
But even if it might be less satisfying, it will still be good to have, too!
I think there’s not much prospect for links directly to the definition from the documentation in the near term.
Linking to the source file is relatively easy, since that information is in the binding.
I’ll admit I don’t know off hand how to do this effectively. I have done some flyby, and build my own code. I’m assuming I need to switch branches to the pr branch, build and test, then switch back to whatever I was doing. Takes me 52 minutes to compile so I’m assuming there is a shortcut I can take?
But as you know, the binding doesn’t have the source line information.
So you’d need to go and expand the defining file during the documentation build, which seems expensive and maybe not the right approach.
@spdegabrielle it doesn’t take me that long to rebuild when there’s just a doc change
Yeah there’s currently a kind of “last mile” problem.
I’ll admit I use the search source functions in DrR and github,
Racket Mode handles that by walking the syntax. https://github.com/greghendershott/racket-mode/blob/master/racket/find.rkt#L120
thought I was doing something wrong. :disappointed:
if you expand the file drracket will find the definition
expand?
If you open the defining file in Dr Racket, and run Check Syntax (or it runs automatically), then you can visit the specific position of the definition.
The underlying drracket/check-syntax
module knows how to find bindings that are defined in your module, their position.
I think is what Sam means here.
right-click ‘open defining file’
Then if you somehow move the cursor to some usage of the thing (reference), Dr Racket’s jump to definition will take you to the definition.
tried it on send
So you can do it, it’s just 2 or 3 steps.
or if the file is open and already expanded in the background, you can “go to definition (in other file)” in one step
I didn’t know that. That’s good.
yup
This is better than linking to the source on g*hub/lab
So the view from orbit is, identifier-binding
will (usually) tell you the file in which something is defined. Then the expanded syntax needs to be walked. Using drracket/check-syntax
for this is probably the easiest way to do this.
and racket mode does the same thing via find-def-in-file
?
(The longer story is there are edge cases where this doesn’t work. Like chaperones, provides
that both rename and add a contract. Then you do the other stuff I did in that file I linked to, if you’re stubborn. :smile: But you probably don’t need to, certainly not for version 1.)
The view from orbit description is usually true.
I think linking to the source is valuable, and having go-to definition in the IDE is also valuable.
Yes so do I. I’m just saying it’s easy to make it work (say) 90% of the time. Another 9% is trickier. And 1% is AFAIK impossible.
Well, for some things it’s not obvious there’s a right answer at all
Having visit-def work from Racket docs online, 90% of the time, would be a nice first step.
Like, where is the doc
export from a scribble module?
in the meant time I need a) to review someone else’s PR of a docs change and build it locally. (and write down the git
commands so I don’t forget)
(and yes I’ve been lazy and used git like svn)
(we don’t use source control at work!)
@spdegabrielle I hope my TL;DR was clear. Don’t expect to it work perfectly. But it doesn’t need to. Even if it works only 90% cases, that’s more than the 0% we have now! So I’m trying to encourage not discourage you, really. :smile:
thank you - yes it took is as encouragement with a dose of realism :slightly_smiling_face:
(updated) in the meantime I need to a) review someone else’s PR of a docs change and build it locally. (and write down the git
commands so I don’t forget)
to add the ability to link from the docs to the defining file in the source, b) defproc
code will know the defining file, and the code for the section should know the package that the module is in alternative: use identifier-binding
to get the file (‘Linking to the source file is relatively easy, since that information is in the binding’) to add the ability to link from the docs to the DEFINITION in the defining file in the source, c) find the line/col with drracket/check-syntax
or use find-def-in-file
https://github.com/greghendershott/racket-mode/blob/master/racket/find.rkt#L120 NB see code in https://github.com/racket/scribble/pull/229/files
Most of the MZCONFIG…
s for the reader disappeared when the expander and reader moved from C to Racket. I’ll make a note to update the docs.
Just noting this was something I wanted to do as well (from Racket, not the C API) with eval
.
Something that doesn’t exist (that I know of), but would be great, would be functions like:
(eval-with-lang lang s)
scheme_eval_string_with_lang(lang, s);
My 2p.
Can you call scheme_eval_string("(read-accept-lang #t)")
or similar first?
Is it not necessary to call read-language
explicitly?
that file prints 42 for me
is that what you see?
With RacketCS embedded, is there a “simple” example of how to pass a foreign pointer into a call from C?
Currently I have: /* C */
ptr rkt_init_name = Sstring_to_symbol("racket-init");
ptr rkt_init = racket_dynamic_require(mod_name, rkt_init_name);
Scall1(rkt_init, p_application);
;;; Racket
(define (racket-init init-opts)
(displayln init-opts))
Of course this fails.
Example of evaluating “#lang ….” from C with Racket BC.
I doubt that I have enough context to see the real problem, but beware that p_application
is not valid after racket_dynamic_require
returns.
Thanks, that’s useful to know. I think it may be a problem with my procedure argument to Scall1
now.
The error I’m getting is invalid memory reference
And then a crash
racket_dynamic_require
returns a list. Using the result with racket_apply
gave me some more error context.
Yeah that’s what broke it.
@michaelrauh has joined the channel