Number parameter restriction example

If you're having trouble using Context Free or don't understand the language, ask for help here.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
User avatar
pakin
Posts: 40
Joined: Sat Apr 21, 2007 8:59 pm
Location: United States
Contact:

Number parameter restriction example

Post 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

User avatar
MtnViewJohn
Site Admin
Posts: 875
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Re: Number parameter restriction example

Post 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.

Post Reply