
Do you just need to get the next ref, or do you need to go through all refs anyway?

At the moment I just need to get the next reference. Maybe one day in the future I’ll need to go through them all.

But there’s no need to make any great effort to solve this problem for me - the major need is accomplished.

I think we all took this as a puzzle ;)

Is it possible to create a macro that produces a list of all bound identifiers at that position?

So, not only top level identifiers, but also local variables introduced from let
, etc.

I mean it can’t be /that/ fast I guess anyway - there are 17 million of them to go through after all!

Well, I believe you may be underestimating Racket :wink: here’s an example that it can be blazingly fast (of course it does almost nothing per iteration): #lang racket
(define ups (build-list 26 (λ (i) (integer->char (+ i (char->integer #\A))))))
(define nums (build-list 10 (λ (i) (integer->char (+ i (char->integer #\0))))))
(define last #f)
(define n 0)
(time
(for* ([x1 (in-list ups)]
[x2 (in-list ups)]
[x3 (in-list ups)]
[x4 (in-list nums)]
[x5 (in-list nums)]
[x6 (in-list nums)])
(set! n (+ n 1))
(set! last (string x1 x2 x3 x4 x5 x6))))
n
last
Result when run from the terminal: $ racket richard_parsons_matter.rkt
cpu time: 292 real time: 292 gc time: 21
17576000
"ZZZ999"

(of course if you need to do something that takes 1ms per iteration of the loop, that will take 17 576 seconds)

One horrible solution is to use check-syntax on the module, and check for all available identifiers at the syntax source location. Complicated and overkill I guess.

Though there’s an intriguing ‘meta’ feel to it :wink:

I had to do something close (though probably not ideal) for the extract-function script: https://github.com/Metaxal/quickscript-extra/blob/master/scripts/extract-function.rkt

Has anyone written a list-box+search-box standalone widget by any chance? (@alexharsanyi?) The contents of the list-box are filtered by whatever is written in the text-field

I’d love to know if there’s a nice way to do this (edit to clarify: a nice way for a macro to get a listing of the variables in scope). I’ve been casually looking for some way to get a list of currently-known-to-be-bound variables for a while.
(I assume it’s more challenging when a macro call is being partially expanded in a definition context, since later definitions haven’t been processed yet to find out all the variables they bind. But I think even a solution that excluded those variables would be good enough for me.)


Thanks. I’m already past that point anyway :slightly_smiling_face:

Btw, I really like that you always include a demo, it’s very helpful

Have you found a way to make the list-box react on #\return? only #\space works for me

In general, no, there’s not a way to get this information. I could give some reasons why it’s tricky to figure out what the right answer is but the basic answer is that the API doesn’t exist

@sorawee Is there an evil-forward-sexp-begin
? That sounds like the command you would want. (idk evil mode).

Doing two forward-sexp
commands followed by a backward-sexp
command will put point before the #
as you want.

racket-mode
does give the #
and '
characters Emacs’ “Prefix Character” char-syntax classification in the buffer. So programming mode commands like forward-sexp
, modes like paredit
, and so on, should all work correctly.

So “word” is a natural language editing concept, and “sexp” is a program code editing concept, in Emacs world.

Thanks!

“sexp” can mean “expression” or “block” in a non-s-expression lang, in Emacs, too.

All the Emacs “forward-” commands mean “forward to the end of the thing”. Often you want “forward to the end of the current thing, or if already at the end, then beginning of the next thing”. So you have to do the 2X forward, 1X backward dance. Which is annoying. So I totally get why there is an evil-mode “forward-word-begin” command; nice! But there probably needs to be a forward-sexp-begin flavor, too.


(package created)

Are there libs like numpy for racket?

Yes there seems to be a dataframe lib.

Another q: is it possible to make android ios apps or web frontend like clojurescript?

@cancandan What kind of math are you interested in? Floating matrices are here: https://docs.racket-lang.org/manual-flomat/index.html?q=sci

Smthg like numpy, pandas

I don’t know pandas.


Its on top of numpy, lots of useful stuff


Right have to check that


It seems data-table does have documentation, but it doesn’t appear on http://docs.racket-lang.org\|docs.racket-lang.org . I don’t know why.

@pknb.dev has joined the channel

I have not tried it, but the toplevel frame or dialog capture the return key, so the widgets might never see it…

The reasons sound like they’d be fascinating. Anyway, thanks for confirming that I’m not overlooking some way to do this. :) It’s not something urgent to me, just something I probably would have explored building things on if it existed.