# Evaluating an ExprListSyntax

**URL:** <https://forums.swift.org/t/evaluating-an-exprlistsyntax/63681>\
**Category:** Using Swift\
**Created:** [March 13, 2023, 9:56pm UTC](https://forums.swift.org/t/evaluating-an-exprlistsyntax/63681 "2023-03-13T21:56:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdemarest](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rdemarest/32/3057_2.png) [@rdemarest](https://forums.swift.org/u/rdemarest)\
**Post date:** [March 13, 2023, 9:56pm UTC](https://forums.swift.org/t/evaluating-an-exprlistsyntax/63681/1 "2023-03-13T21:56:40Z")

</div>

Hello,

I'm playing around with the new OptionSet [pitch](https://forums.swift.org/t/pitch-optionset-macro/63547) to add some functionalities.

I'm trying to figure out if it's possible to evaluate expressions inside the macro generation code. For example, I'm trying to add an @attribute that takes a range, e.g. `10..<12` as one of its argument and evaluate this in the macro context. I could read each component manually and just make this a requirement, but I was wondering if it was possible to just evaluate the expression and get a Range object out of it.

Does SwiftSyntax allow you to do that?

---

<div class="post-metadata">

**Author:** ![harlanhaskins](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/harlanhaskins/32/333_2.png) [@harlanhaskins](https://forums.swift.org/u/harlanhaskins)\
**Post date:** [March 13, 2023, 11:13pm UTC](https://forums.swift.org/t/evaluating-an-exprlistsyntax/63681/2 "2023-03-13T23:13:06Z")

</div>

SwiftSyntax doesn't have any evaluation built in, nor does it perform any typechecking.

You can, in your macro, read out the lower bound and upper bound as literals and emit a diagnostic if they aren't literals, then build your Range manually.

Alternatively you could syntactically expand the function to store the range to a unique local variable and use `thatVariable.lowerBound` and `thatVariable.upperBound` in the expanded macro contents.

---

<div class="post-metadata">

**Author:** ![rdemarest](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/rdemarest/32/3057_2.png) [@rdemarest](https://forums.swift.org/u/rdemarest)\
**Post date:** [March 13, 2023, 11:27pm UTC](https://forums.swift.org/t/evaluating-an-exprlistsyntax/63681/3 "2023-03-13T23:27:08Z")

</div>

Yeah I suspected as much, and no, I need the values in my macro so I'll do the manual parsing. Thank you!
