# Using syntax/loc with ellipsis

**URL:** <https://racket.discourse.group/t/using-syntax-loc-with-ellipsis/3935>\
**Category:** Questions & Answers\
**Created:** [September 7, 2025, 4:19am UTC](https://racket.discourse.group/t/using-syntax-loc-with-ellipsis/3935 "2025-09-07T04:19:49Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![sora22](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/sora22/32/2622_2.png) [@sora22](https://racket.discourse.group/u/sora22)\
**Post date:** [September 11, 2025, 7:40am UTC](https://racket.discourse.group/t/using-syntax-loc-with-ellipsis/3935/7 "2025-09-11T07:40:08Z")

</div>

> [@LiberalArtist](#):
>
> If, instead, you are manipulating the actual values at runtime, you should take a look at [1.2.6 Contracts on Macro Sub-expressions](https://docs.racket-lang.org/syntax/exprc.html).

I am, however I am working with a colleague who has already created contracts which I would have to essentially decompose and reapply to the various arguments (its easier to just redirect the syntax highlighting in this particular case). I tried this since it seems to be one proper way to achieve the granular highlighting I'm looking for, but I appear to still be running into similar issues [I've had previously in regard to syntax highlighting](https://racket.discourse.group/t/expr-c-and-wrap-expr-c-not-error-highlighting-what-contract-states-it-is-blaming/3369).

> [@ryanc](#):
>
> One solution is to use a helper macro that takes the original syntax as an argument:
> 
> ```scheme
> (define-syntax (example stx)
> (syntax-parse stx
> [(_ val:expr ...)
> #`(begin
> (process/loc val #,stx)
> ...)]))
> 
> (define-syntax (process/loc stx)
> (syntax-parse stx
> [(_ val:expr orig-stx)
> (syntax/loc #'orig-stx
> (process val))]))
> 
> ```

I did get this to work when using "stx" as the location expression, but as expected it highlights the entire expression rather than the specific subexpression. I was hopeful that using the values of the ellipsis as the location expression would work, however when using them as the location expression I seemed to be causing some inordinate amount of work somewhere (I've never waited longer than 30 seconds to a minute before killing the program, so maybe it will terminate but it's still excessive).

The final thing I've tried since is using with-handlers to re-raise the exception with a srcloc. This appears like it would work if I could differentiate which contract raised the exception with the predicate. I haven't looked too deeply into this yet, so maybe I'm just not aware of how to differentiate them.

For the time being I think I'll use the helper macro suggested by @ryanc but I am still looking for a way to highlight specific expressions. If I can't figure out a way to differentiate which contract raised the exception I'll probably attempt to combine expr/c with with-handlers next? Not the most elegant solutions unfortunately...

By the way, thank you all for your help in trying to figure this out, its very appreciated

---

_[View the full topic](https://racket.discourse.group/t/using-syntax-loc-with-ellipsis/3935)._
