> On May 14, 2018, at 12:42 AM, Colin Fleming <colin.mailingl...@gmail.com> 
> wrote:
> 
> Hi all,
> 
> I work on Cursive <https://cursive-ide.com/>, which is an IDE for Clojure 
> code based on IntelliJ. I've spoken to several of you at various conferences 
> over the years.
> 
> I'm interested in understanding better how the macroexpansion to support 
> editor functionality in DrRacket works. By contrast, Cursive doesn't expand 
> macros during editing and relies on an extension API to teach it about macro 
> semantics. It's not ideal, but it does have some advantages - it's safe and 
> it's fast, and you can add support for some really crazy things that macros 
> do. However currently it requires me to add support for popular macros, 
> although I do have plans to open source that part so that users will be able 
> to add support for either third-party macros that they use, or macros that 
> they've developed themselves.
> 
> My understanding is that using macroexpansion in the way that DrRacket does 
> requires a fairly deep integration between the macroexpander, the macros 
> themselves and the IDE - is that a fair statement?
> 
> I guess that things like source location for forms which are carried from the 
> unexpanded source to the macroexpansion are more or less automatic. How does 
> this work for synthesised forms which are either composed from forms in the 
> original source, or don't exist in the original source at all? For example, 
> playing around with DrRacket I can see that after (struct node ([left : Tree] 
> [right : Tree])), hovering over node-left or node-right will indicate that 
> the node part comes from the struct definition, and the left/right part will 
> come from the fields. Are there annotations specifying partial ranges within 
> symbols to allow this?

Since `struct` creates a new name that wasn't in the source, but built from 
parts of the source, it uses the syntax property `'sub-range-binders` to 
communicate this to DrRacket [1].

However, if a macro doesn't "make up" names like struct does, it doesn't need 
to worry about this.

> I know there are features for tagging forms with information that will appear 
> in tooltips and the like, e.g. Typed Racket showing type information in the 
> editor. Are there other facilities for communicating with the user?

These tooltips are controlled by the syntax property `'mouse-over-tooltips` [1].

> How well does all this work for macros which aren't written with DrRacket in 
> mind?

It depends on whether they make up or introduce names that weren't originally 
there in the source. If a macro only produces definitions or expressions using 
identifiers it was given as an input, the macro generally doesn't need to be 
written with DrRacket in mind.

> And finally, of course - is there some documentation about all this I could 
> look at? Is this all implemented with syntax object properties 
> <https://docs.racket-lang.org/reference/stxprops.html>?

Yes, the advanced features that work for macros that make up names or display 
tooltips are communicated to DrRacket through syntax properties like 
`'sub-range-binders` and `'mouse-over-tooltips`. These properties are 
documented here:

  [1]: 
https://docs.racket-lang.org/tools/Check_Syntax.html#(part._.Syntax_.Properties_that_.Check_.Syntax_.Looks_.For)

> Thanks for any and all help!
> 
> Cheers,
> Colin

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-dev+unsubscr...@googlegroups.com.
To post to this group, send email to racket-dev@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-dev/87D736B0-C013-48CD-9222-0AA2B41C1420%40knauth.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to