I typically develop in Emacs, but I’m exploring some DrRacket features. When I right-click a function invocation, I see an option to open the defining file, but if DrRacket knows the defining file, can’t it also jump to the definition in that file?
It can, but you need to open the file first
That is, at first, the menu item is “open the defining file”
After you open the file, the menu item will be changed to “jump to definition”
I’m sorry, but I don’t understand that limitation. DrRacket knows the file to open, and it knows the symbol to jump to in that file.
Also, the menu didn’t change for me, even after opening the file.
As for why it can’t do that at once… it’s a good question. To quote @robby :
> It doesn’t do that because it takes (potentially a lot) of time to find the definition. So it jumps to the definition only when it already knows where the definition is. https://github.com/racket/drracket/issues/273
Now, if I 1) open the defining file, and then 2) click “Check Syntax”, then the menu changes, but I’m trying to avoid work here :)
I think if you have background expansion enabled, you shouldn’t need to separately click Check Syntax
No idea why it would take so long as to be a concern, what types of files are they worried about? Or, alternatively, how slow is this process of finding the definition? So many questions …
Regardless, it’s a 2+ year old issue, so I guess there’s not huge demand.
it can take several seconds
or, for Typed Racket, significantly longer than that
Will it take longer than the user doing it manually ?!?!
Yeah, I think it should be supported regardless of how long it takes, too. User doing it manually is always gonna be worse.
The concern is that the user experience would not be great — you select the menu item, and then the file opens and you wait some indetermiate amount of time and then it scrolls
@samth - that last part confuses me, unless were talking about GB sized files
Also, I think racket-mode approximates things by looking at the surface syntax for things that look like definitions, and Robby has been reluctant to do that for DrRacket
To be clear, it has to expand the entire file to find it.
This can take significant time.
Much more than is acceptable to wait for a menu item response
There is some hope I will be able to improve this eventually.
I’m on an 8 year old computer, and I have UX problems like that with KB-sized files.
Not today tho. :)
@seanbunderwood I will try not to make them worse.
Personally I find the racket-mode experience nice, where it does jump to the definition in the other file via a combination of waiting and heuristics (maybe @greg can say more?) but I understand that other people preferring other approaches.
Racket Mode also needs to fully expand the file. Its “trick” is that it uses a cache of fully-expanded syntax, and, sometimes the other file will already be in that cache.
Perhaps it’s good to have a selection of different tools that take different approaches.
Robby has an idea about a sqlite db of fully-expanded syntax.
If/when that became real, Dr Racket (and Racket Mode) could use that to improve jump-to-def.
Also I’ve been experimenting with a sqlite db of check-syntax results. To support stuff like “find references” (the “opposite” of jump to def) as well as multi-file renaming.
But that’s still WIP.
Wow, I’ve been lazy about leveling up with racket-mode
- there’s some really nice features there!
Quick question, when you “run” a file in the REPL in racket mode, it doesn’t run the main module, right?
I have quite a few files in my project that have a (module+ main ...
that should not be run except in very special circumstances :-o
C-c C-c
is bound to`https://www.racket-mode.com/#racket_002drun_002dmodule_002dat_002dpoint which runs and “enters” the module around point.
However F5
does https://www.racket-mode.com/#racket_002drun which is more like Dr Racket
I was referring to what happens when I hit M-.
and it asks to “run” the file and try again. I put some invalid code in my main, and it didn’t seem to fire, so I assume that doesn’t actually run it.
Of course its Emacs those are the default keybindings but you can change :slightly_smiling_face:
The thing where M-.
would ask to “run” the file again sounds like a quite old version of Racket Mode.
These days you’d probably use the minor mode racket-xp-mode
, and it would be able to go right away.
Yes, it also fails to “save for future sessions” in customize - I’ll go update now. Melpa confuses me, can I do this the old fashioned way by plopping a directory ?
Usually in Emacs to upgrade a melpa package I just package-delete
it and package-install
it again
I guess the important question is whether some of my files with a main module will be accidentally run - maybe I should just comment them out for now.
I actually have to go now, someone waiting for me!, but I can check back later and hopefully that web page with the Racket Mode docs can help you in the meantime — cheers!
Thanks!
Vim + racket langserver has been able to get this correct for me with no trouble, for the record
@badkins drracket does not run any program unless you click the run button. It will expand them when you open them (but it will disable filesystem access (except for reading for requires) and network access, etc).
oh, sorry. I see those were racket mode questions. Sorry!
am i the only one using racket lang server + vscode? seems like the lot of you are on emacs and vim (i only use vim for quick edits when im on the command line)
I’m using1 both DrRacket and vscode + racket-langserv
Hmm… I deleted racket-mode from my Emacs packages, so I could reinstall it, but now it’s no longer in the list. I’ve refreshed the package list, but it’s still missing. Anyone know how to get it back in the list so I can reinstall it?
<sigh> and everytime I do something with melpa, I lose my colors config
Changing the ’package-archives to conform to the latest racket-mode docs seems to have brought racket-mode back, so problem solved at the moment.
yay, everything is working now, which begs the question, “why, oh why, did I wait so long to get racket-mode properly configured” ! @greg this is going to be a big boost to my productivity - do you have a donation page setup anywhere?
Hmm… doesn’t look like github allows entering a custom amount - I was looking for something between the $5 and $50 tiers.
I’m having a bit of a hard time understanding the difference between standard vectors and arrays (from the math library). It says in the docs that vectors are constant time access and updates, whereas arrays seem a lot more complicated. Is there an advantage to using arrays over vectors?
As I see from the doc, vectors are only 1D and have no special account for multidimensional creation, accessing, transformation and slicing. Whats more, vectors have arbitrary & irregular shapes