# installAssignmentMethod -- install methods assignment to the value of an operator

## Synopsis

• Usage:
installAssignmentMethod(op,X,Y,f)
• Inputs:
• op, , the symbol for a binary operator
• X, a type, the type of the left-hand operand
• Y, a type, the type of the right-hand operand
• f, , the method function that will perform the assignment
• Consequences:
• If the operator to be used is **, say, then op should be symbol **. After installing the assignment method, assignments of the form x**y=v will be handled by evaluating f(x,y,v).

## Description

If the operator is a unary operator, just omit X and its comma.

We illustrate this function by defining a type of mutable list whose elements can be both extracted and replaced using the operator _. We also install a method for net so objects of the class can be printed.

 i1 : M = new Type of MutableList o1 = M o1 : Type i2 : net M := m -> peek m o2 = -*Function[stdio:2:12-2:20]*- o2 : FunctionClosure i3 : M _ ZZ := (x,i) -> x#i o3 = -*Function[stdio:3:17-3:22]*- o3 : FunctionClosure i4 : installAssignmentMethod(symbol _, M, ZZ, (x,i,v) -> x#i = v); i5 : y = new M from (a..z) o5 = M{a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z} o5 : M i6 : y_12 o6 = m o6 : Symbol i7 : y_12 = foo o7 = foo o7 : Symbol i8 : y o8 = M{a, b, c, d, e, f, g, h, i, j, k, l, foo, n, o, p, q, r, s, t, u, v, w, x, y, z} o8 : M i9 : y_12 o9 = foo o9 : Symbol
For sample applications of this facility, see Symbol _ Thing = Thing and MutableMatrix _ Sequence = Thing.

## Caveat

The syntax involved here is not pleasant, so we may change it to something briefer, something involving yet another assignment operator, distinct from = and :=.