
@leif I guess I’m not clear on what you’re trying to do. Using a module path index with dynamic-require
should generally do the right thing, including when you build up relative module path indices using module-path-index-join

@kennethdevel has joined the channel

@mflatt It looks like some commit in this range https://github.com/racket/racket/compare/5bb837661c12a9752c6a99f952c0e1b267645b33...5b8aa67e broke the AppVeyor windows tests: https://ci.appveyor.com/project/plt/racket/build/1.0.3410

Does the equivalent of zo-for?
already exist somewhere (before I try to write it some bad ad hoc way)? (define (zo-for? zo-path path) ;(-> path-string? path-string? boolean?)
???)
(check-true (zo-for? "/path/to/compiled/file_rkt.zo" "/path/to/file.rkt"))



@larstvei has joined the channel

@mflatt Ah, okay.

So you can leave it as a relative module path index and dynamic-require somehow manages to resolve it with respect to the given module.

Like, If I have lib.rkt
:
#lang racket
(define x 42)
(provide x)

And then I use it in use.rkt
, in the same directory: #lang scratch
(begin-for-syntax
(displayln (dynamic-require
(module-path-index-join "lib.rkt" #f) 'x)))

?

Ah, okay, ya it does do the right thing:
(begin-for-syntax
(writeln (resolve-module-path-index (module-path-index-join "me.rkt" #f))))
Thanks.

@mark.shead has joined the channel

@mustafa.khattab has joined the channel

@rantonse has joined the channel

@pranav.gokhale.93 has joined the channel

The functions first, rest etc raise an error when not used on lists. Do we have a cons that raise an error when the second argument isn’t a list?

@soegaard2 if you get cons
from one of the student languages it does that

ok

I’m playing with syntax object. In DrRacket I can see information on the syntax object like Source, Line, Column, Span, and more. How do I access this information given a syntax object? Say for example, I want to print the position, line, and column number of the calling site of a define-syntax expression.

@plotnus see functions like syntax-source

@samth Yes!!! that is exactly what I needed! Thank you!

So lets say i have (define-syntax (foo a b) …) I want foo to retrieve the syntax information for the callsite, not for just a or b. Is there a way, within the define-syntax for foo, to get that information?

Put another way, inside foo I want #’(foo a b).

If you have (define-syntax (foo stx) …) then stx contains a syntax object representing the call (foo a b).

@soegaard2 Ok that’s great. Thank you so much

@nick has joined the channel

@rumbletumjum has joined the channel

@remywang has joined the channel

@samth Although plan B (getting srclocs from zos) didn’t really pan out as hoped, plan A is working out well so far — a current-eval
handler that expand
s and caches. Plus, if the file being run is using a zo
— so the eval-handler
won’t be expanding — then delay/thread
an expansion into the cache (the cache retrieve does a force
). That way it is likely to be ready by the time a user does the first find-definition, and if it is ready, it will feel “instant”.

why didn’t the zo idea work?


> why didn’t the zo idea work? The srclocs in lam
s aren’t great — e.g. for “definer macros”. The srclocs in the bindings-hashtable are awesome … but the table exists only for the file module not submodules.

those macros should be fixed, I’d say

and aren’t the main modules what we mostly care about?

How would you fix this example that failed (define-syntax-rule (plain-definer name)
(begin
(define (name x) x)
(provide name)))
(plain-definer plain-by-macro)
?

Anyway racket-mode has to have a non-zo
way to do this when zo
s don’t exist.

You gave me both plan A and plan B. I may have been unclear above, but I meant to say “thanks for two great plans, and one of them is working!” :slightly_smiling_face:

I think the fix for that macro is to use syntax/loc

Well I often use find-definition to explore “legacy” code and/or Racket distribution code. :slightly_smiling_face: I would like it to work even if it still uses syntax-rules
.

Also racket-mode still supports Racket version back to 6.0 There are a few features where it dynamic-requires
some new lib, and has a fallback. But most of it still works. I’d like it to still work across bytecode structure changes, and even if syntax-rules
is still used somewhere. Unlike DrRacket I can’t assume the current version of Racket.

define-values
and define-syntaxes
has been pretty stable.

although, thinking about it more, I probably want the answer that the zo source location gives for your macro (or maybe I want both locations)?

I think the best answer to “where is plain-by-macro
defined?” to go to that line where it is actually defined (last line in my example). After all, I can always move to the left over plain-definer
, and hit visit-def to go there, next.

Also maybe I’m crazy but IME define-syntax-rule
usually behaves right in this regard — automatically does the right thing. It’s syntax-{case parse}
where you need to use syntax/loc
. Right? Maybe I’m remembering wrong.

Oh carp, just noticed the time. Sorry I have to Zzz soon. Cheers!

Hi is there a way to find valid completions to an identifier in a file? I assume that it would somehow be possible to call on some function to give all available functions and identifiers for the current file (taking into consideration require’s) and then filter them given a prefix?

@greg have you thought about this at all? ^^^ writing a company-mode backend?