# Macro switch pattern $p{ a }

**URL:** <https://community.haxe.org/t/macro-switch-pattern-p-a/2342>\
**Category:** Haxe\
**Created:** [April 8, 2020, 10:40am UTC](https://community.haxe.org/t/macro-switch-pattern-p-a/2342 "2020-04-08T10:40:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [April 8, 2020, 10:40am UTC](https://community.haxe.org/t/macro-switch-pattern-p-a/2342/1 "2020-04-08T10:40:03Z")

</div>

Hej,

While this one works fine : `case macro $i{ s }`  
Why this doesn’t please : `case macro $p{ a }` ?

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [April 8, 2020, 10:41am UTC](https://community.haxe.org/t/macro-switch-pattern-p-a/2342/2 "2020-04-08T10:41:52Z")

</div>

Because of the unknown array length right ?  
If so, is there another way to achieve what I want please ?

---

<div class="post-metadata">

**Author:** ![RealyUniqueName](https://community.haxe.org/user_avatar/community.haxe.org/realyuniquename/32/10_2.png) [@RealyUniqueName](https://community.haxe.org/u/RealyUniqueName)\
**Post date:** [April 8, 2020, 11:23am UTC](https://community.haxe.org/t/macro-switch-pattern-p-a/2342/3 "2020-04-08T11:23:15Z")

</div>

So… What do you want to achieve? )

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [April 8, 2020, 11:37am UTC](https://community.haxe.org/t/macro-switch-pattern-p-a/2342/4 "2020-04-08T11:37:49Z")

</div>

Well, if I try to use `macro $p{ a }`, then I want to catch a field access, something like field, or my.field, or my.sub.field

---

<div class="post-metadata">

**Author:** ![RealyUniqueName](https://community.haxe.org/user_avatar/community.haxe.org/realyuniquename/32/10_2.png) [@RealyUniqueName](https://community.haxe.org/u/RealyUniqueName)\
**Post date:** [April 8, 2020, 12:49pm UTC](https://community.haxe.org/t/macro-switch-pattern-p-a/2342/5 "2020-04-08T12:49:40Z")

</div>

you can catch it with `case { expr: EField(e, field) }:`

---

<div class="post-metadata">

**Author:** ![filt3rek](https://community.haxe.org/user_avatar/community.haxe.org/filt3rek/32/2613_2.png) [@filt3rek](https://community.haxe.org/u/filt3rek)\
**Post date:** [April 8, 2020, 12:55pm UTC](https://community.haxe.org/t/macro-switch-pattern-p-a/2342/6 "2020-04-08T12:55:06Z")

</div>

Yes I know, I just thought I could use reification here as for $i.  
Thanks Aleksandr
