Next  |  Prev  |  Up  |  Top  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

Formal Parameter Exception

The pattern-matching facility is not applied to ordinary formal function parameters [5]. In other words, f(x,y,z)=expression is treated as a function having three formal parameters that are expected to appear literally in expression (e.g., an expression such as x*y+z). This interpretation is in contrast to a function whose input is three parallel block diagrams of arbitrary generality. As a result of this exception, the mere number of formal parameters does not contribute to the uniqueness of a pattern. For example, the following program generates a compile-time error:

  f(x,y) = f(x) + f(y);  // (x,y) => f(x),f(y):+
  f(x) = 2*x;            // (x) => 2,x:*
  process = f(3,5);
The compiler-error triggered is ``inconsistent number of parameters in pattern-matching rule: (x) => 2,x:*; previous rule was (x,y) => f(x),f(y):+''. On the other hand, the following program outputs the constant signal 16:
  f((x,y)) = f(x) + f(y);
  f(x) = 2*x;
  process = f((3,5));
The extra parentheses distinguish the pattern (x,y) from formal parameters x,y in this case.

Next  |  Prev  |  Up  |  Top  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

Download aspf.pdf
[Comment on this page via email]

``Audio Signal Processing in Faust'', by Julius O. Smith III
Copyright © 2024-05-01 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University