Page 1 of 1

Number parameter restriction example

Posted: Fri Sep 07, 2012 10:38 pm
by pakin
The Number Parameter Restrictions wiki entry presents examples of legal and illegal usage of number parameters. However, when I try compiling those examples, I get an error on one of the "Allowed" lines. Here's a demonstration of the problem:

Code: Select all

startshape begin

shape taper(number shrink) {
    SQUARE []
    taper(shrink) [size shrink]           // Allowed, shrink is a number parameter
}

shape begin {
  taper(0.9) [ ]
}
Alas,

Code: Select all

$ cfdg taper.cfdg
Error in taper.cfdg at line 5 - This expression does not satisfy the number parameter requirement
So who's right? The compiler or the documentation?

— Scott

Re: Number parameter restriction example

Posted: Sat Sep 08, 2012 3:30 pm
by MtnViewJohn
That code should work. The documentation is correct.

This will get you going for now:

Code: Select all

shape taper(number shrink) {
    SQUARE []
    taper(=) [size shrink]           // Allowed, shrink is a number parameter
}
In general, you should use = whenever you can with parameters. Otherwise you end up generating multiple identical parameter blocks on the heap.