Fetch



next up previous contents index
Next: & and Up: Expressions Previous: Prefix and Infix

Fetch

A special form is provided for fetching the element of an "array", "vector", or "sequence", or an abstract object with a method named ``fetch'':
<expr0> "[" <expr1> "]"
This form is just a shorthand for an invocation of a fetch method and is equivalent to
<expr0> "." "fetch" "(" <expr1> ")"
The expression is legal whenever the corresponding invocation is legal. In other words, the type of expr0 must define a procedure method named "fetch" with a single argument whose type is a supertype of expr1. For example, if "a" is an array of integers, "a[27]" is equivalent to the invocation "a.fetch(27)".

[usage761]



theta-questions@lcs.mit.edu