# Why shouldn't I use tag() in an expression

**URL:** <https://forum.inductiveautomation.com/t/why-shouldnt-i-use-tag-in-an-expression/94349>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [August 8, 2024, 2:30pm UTC](https://forum.inductiveautomation.com/t/why-shouldnt-i-use-tag-in-an-expression/94349 "2024-08-08T14:30:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [August 8, 2024, 2:30pm UTC](https://forum.inductiveautomation.com/t/why-shouldnt-i-use-tag-in-an-expression/94349/1 "2024-08-08T14:30:13Z")

</div>

Why shouldn't I use tag() in an expression

---

<div class="post-metadata">

**Author:** ![Felipe\_CRM](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Felipe\_CRM](https://forum.inductiveautomation.com/u/Felipe_CRM)\
**Post date:** [August 8, 2024, 2:42pm UTC](https://forum.inductiveautomation.com/t/why-shouldnt-i-use-tag-in-an-expression/94349/2 "2024-08-08T14:42:34Z")

</div>

> [@Help with Tag Expression](https://forum.inductiveautomation.com/t/help-with-tag-expression/93326/12):
>
> Expression bindings are synchronous. They must return a value when executed. The tag() expression function stalls when first called, waiting for a reply to its subscription request. If you scatter tag() expression functions through a bunch of bindings in a commonly-used view, you will have stalls on those views that are the sum of all the stalls in the bindings. Tag bindings don't stall. They simply don't produce any property assignment at all until the subscription answers, and only produc…

> [@Indirect tag in an expression binding?](https://forum.inductiveautomation.com/t/indirect-tag-in-an-expression-binding/92560/7):
>
> There are many other posts like this

Just to get you started down the rabbit hole.

EDIT: Another good reason:

> [@Nesting Not Allowed while using Properties in a Template to turn on a Light](https://forum.inductiveautomation.com/t/nesting-not-allowed-while-using-properties-in-a-template-to-turn-on-a-light/33609/16):
>
> Yes, there is. If the items that comprise your tagpath are updated, even if yielding the same result path, the entire expression containing the tag() function will have to execute. With indirect binding, this doesn't happen. The strings themselves have to be reconstructed every time, even if not changing, slowing down the final expression execution. There are a few cases with computed gateway tags where the tag() expression is the only good way to do indirection, and the dynamic stuff above…

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [August 8, 2024, 3:17pm UTC](https://forum.inductiveautomation.com/t/why-shouldnt-i-use-tag-in-an-expression/94349/3 "2024-08-08T15:17:42Z")

</div>

I thought I read it somewhere but I couldn't find it. Thank you very much.

Ugh Configuring Indirect Tag Binding takes forever. Is there anyway to create them without going through the interface

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 8, 2024, 3:21pm UTC](https://forum.inductiveautomation.com/t/why-shouldnt-i-use-tag-in-an-expression/94349/4 "2024-08-08T15:21:15Z")

</div>

I tend to use "Copy Binding" then "Paste Binding" then edit.

If your indirect binding always looks like:

```python
{1}/SomeName

```

or

```python
{1}/SomeName.SomeProperty

```

with `{1}` always pointing at `{view.params.tagpath}`, then making many of these is fairly easy.

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [August 9, 2024, 11:44am UTC](https://forum.inductiveautomation.com/t/why-shouldnt-i-use-tag-in-an-expression/94349/5 "2024-08-09T11:44:14Z")

</div>

So if tag() is so much trouble why is it even available as an option?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 9, 2024, 11:46am UTC](https://forum.inductiveautomation.com/t/why-shouldnt-i-use-tag-in-an-expression/94349/6 "2024-08-09T11:46:25Z")

</div>

It is the only way to do indirection within **expression tags** , and the expression function registration system doesn't make a distinction about **where** the function could be used.

I would be in favor of `tag()` throwing a config error if used anywhere else.

A long, long time ago ( ~~in a galaxy far, far away~~ ) indirect tag bindings didn't exist, and `tag()` was the only method. It limps along for backwards compatibility reasons.

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [August 9, 2024, 1:14pm UTC](https://forum.inductiveautomation.com/t/why-shouldnt-i-use-tag-in-an-expression/94349/7 "2024-08-09T13:14:54Z")

</div>

I would also be in favor of an error. I used it everywhere...Damnit

---

<div class="post-metadata">

**Author:** ![msteele](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/msteele/32/77889_2.png) [@msteele](https://forum.inductiveautomation.com/u/msteele)\
**Post date:** [August 9, 2024, 3:33pm UTC](https://forum.inductiveautomation.com/t/why-shouldnt-i-use-tag-in-an-expression/94349/8 "2024-08-09T15:33:41Z")

</div>

Or at least it could be helpful to have some more warnings/caveats in the docs. I used to use `tag()` everywhere all the time until @pturmel set me straight.  
For example, add more warnings here:

> **[tag | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/expression-functions/advanced/tag)**
>
> Returns an object representing the value of the Tag at the path specified.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 9, 2024, 4:08pm UTC](https://forum.inductiveautomation.com/t/why-shouldnt-i-use-tag-in-an-expression/94349/9 "2024-08-09T16:08:16Z")

</div>

Don't tell us! Tell [docs@inductiveautomation.com](mailto:docs@inductiveautomation.com).
