mflatt
2018-7-10 12:30:08

@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
2018-7-10 13:38:59

@kennethdevel has joined the channel


samth
2018-7-10 13:59:33

greg
2018-7-10 15:11:17

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
2018-7-10 16:03:04

@larstvei has joined the channel


leif
2018-7-10 16:15:06

@mflatt Ah, okay.


leif
2018-7-10 16:15:37

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.


leif
2018-7-10 16:16:06

Like, If I have lib.rkt:

#lang racket

(define x 42)
(provide x)

leif
2018-7-10 16:16:29

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)))


leif
2018-7-10 16:16:29

?


leif
2018-7-10 16:21:21

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
2018-7-10 17:01:31

@mark.shead has joined the channel


mustafa.khattab
2018-7-10 17:02:01

@mustafa.khattab has joined the channel


rantonse
2018-7-10 17:15:36

@rantonse has joined the channel


pranav.gokhale.93
2018-7-10 18:07:51

@pranav.gokhale.93 has joined the channel


soegaard2
2018-7-10 18:26:06

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?


samth
2018-7-10 18:26:54

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


soegaard2
2018-7-10 18:27:08

ok


plotnus
2018-7-10 20:54:37

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.


samth
2018-7-10 20:55:00

@plotnus see functions like syntax-source


plotnus
2018-7-10 20:55:36

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


plotnus
2018-7-10 21:13:12

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?


plotnus
2018-7-10 21:13:49

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


soegaard2
2018-7-10 21:21:09

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


plotnus
2018-7-10 21:41:37

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


nick
2018-7-10 22:59:02

@nick has joined the channel


rumbletumjum
2018-7-10 23:04:13

@rumbletumjum has joined the channel


remywang
2018-7-11 02:52:17

@remywang has joined the channel


greg
2018-7-11 04:01:58

@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 expands 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”.


samth
2018-7-11 04:02:40

why didn’t the zo idea work?



greg
2018-7-11 04:06:44

> why didn’t the zo idea work? The srclocs in lams 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.


samth
2018-7-11 04:08:22

those macros should be fixed, I’d say


samth
2018-7-11 04:08:40

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


greg
2018-7-11 04:11:23

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) ?


greg
2018-7-11 04:12:36

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


greg
2018-7-11 04:16:25

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:


samth
2018-7-11 04:16:59

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


greg
2018-7-11 04:19:37

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.


greg
2018-7-11 04:21:49

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.


greg
2018-7-11 04:22:44

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


samth
2018-7-11 04:23:29

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)?


greg
2018-7-11 04:25:16

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.


greg
2018-7-11 04:26:47

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.


greg
2018-7-11 04:28:42

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


pocmatos
2018-7-11 06:58:30

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?


pocmatos
2018-7-11 06:58:47

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