# Notation for field access in Algorithm

While writing array index in an algorithm $a[i]\gets v$ is conventionally used. Is the notation $a_{i}\gets v$ also used ?

If the algorithm uses struct or equivalent, some notation is required for property access. In some occasions $p(s)$ is used where $p$ is the property. Using $s \rightarrow p$ messes up with the assignment arrow. Using $s_{p}$ looks like $p$ is an index and $p\in \mathbb{Z}^{+}$. Should $s["p"]$ be used ? What is the convention to denote property access in algorithm ?

Is there any reference where I can check different notations of these two scenarios ?

• Pseudocode is not a programming language. The exact notation doesn't matter as long as it's clear and concise. You might want to use dot notation for properties. – Reinstate Monica Mar 8 '18 at 16:31
• Yes I am asking about conventions and references. Writing something too unconventional makes things hard to read. – Neel Basu Mar 8 '18 at 16:33
• $a[i]$ and $a_i$ are commonly used. Dot notation is commonly used. C-style $s \rightarrow p$ is not, in my experience. – Reinstate Monica Mar 8 '18 at 16:33

• If $a$ is an array, $a[i]$ is typically used, but not $a_i$.
• If $(a_1,\dots,a_n)$ is a sequence, $a_i$ is typically used, but not $a[i]$. Usually sequences are not updateable.
• If $a$ is a string, you might see either $a[i]$ or $a_i$; both are common, in my experience.
• I have most commonly seen $s.p$ used for property access. Sometimes I have seen people use $p(s)$ used.