[Contents] · [Home] · [Mail]

** Type:**

_EQ: obj_1 x obj_2 -> boolean

** Call syntax:**

_EQ(*x*,
*y*)

*x* =
*y*

** Description:**

The binary infix operator "=" realises the equality
relation on arbitrary object types. Equality testing
can only be done for objects of compatible types,
i.e., *obj_1* and
*obj_2* have to have either identical types or
must be one of the following combinations:

*integer* and
*real*
*sequence* and
*segment*
*function*,
*macro*,
*block*,
and *internal function*

The truth value returned by the equality expression is
TRUE if *obj_1* and
*obj_2* are equal, FALSE otherwise.
On boolean, and integer objects, equality is defined as
usual; on real objects one has to be careful: because
of internal inaccuracies inherent to real arithmetics,
sometimes real expressions which should be equal, are
reported to be not equal using "=".
String objects are equal if the have the same length and
all corresponding characters are identical.

Sequences are equal if they have the same length and each pair of corresponding notes have same duration (normalised), pitch-class, register, and alteration. (Note, that secondary parameters like instrument, intensity, and tempo are ignored when comparing sequences). Segments are equal if they have the same number of voices and the corresponding voices are equal.

List objects are equal if they have the same length and all corresponding elements are equal. Functions are equal if they have the same number of parameters and syntactically exactly identical function bodies; the same applies to macros. Internal function objects are equal if the dereference the same built-in function. Functions and macros are never equal, neither are functions and internal functions or internal functions and macros. With respect to equality, blocks are treated like parameterless macros: they are only equal, if they are syntactically exactly identical.

In expressions, "=" binds stronger than the boolean operators, but weeker than the arithmetic, length, or list access operators.

** Error conditions:**

Applied to operands *obj_1* and
*obj_2* of incompatible types,
the equality operator causes an error condition to occur.

** Example:**

> 2=2
*Result= TRUE*

> TRUE=FALSE
*Result= FALSE*

> 1.0=1
*Result= TRUE*

> 0.01=0.01012
*Result= FALSE*

> "abc"="abcd"
*Result= FALSE*

> ("a","bc","d")=("a","bc")+LIST("d")
*Result= TRUE*

> [c1/4 d2/2]=[c1/4 d2/4]
*Result= FALSE*

> [c1/4 d2/4.]=[c1/4 d2*3/8]
*Result= TRUE*

> {[c1/4 e/2],[c0/2.]}={[c0/2.],[c1/4 e/2]}
*Result= FALSE*

> FUNC(0,`return(1)') = FUNC(0, `return(1)')
*Result= TRUE*

> FUNC(0,`return(1)') = FUNC(1, `return(1)')
*Result= FALSE*

> FUNC(0,`return(1)') = FUNC(0, `return(0+1)')
*Result= FALSE*

> FUNC(0,`return(1)') = MACRO(0, `return(1)')
*Result= FALSE*

> write = read
*Result= FALSE*

> length = IFUNC("length")
*Result= TRUE*

> `a:=1' = `a:=2-1'
*Result= FALSE*

> `a:=1' = `a := 1'
*Result= FALSE*

** See also:**
Operator "!=" (_UNEQ),
Operators and Expressions.

[Contents] · [Home] · [Mail]