Page 1 of 1

Natural Number Parameters

Posted: Tue Mar 12, 2013 1:35 pm
by ColorMeImpressed
So, I have the following code in something I'm working on.

Code: Select all

shape A(natural n){
	base(n)[b 1 sat 1]
	A(n+INSERT_NATURAL_NUMBER_HERE)[s .99 y 2 r 15]
}
When I set INSERT_NATURAL_NUMBER_HERE to 0, 1 or 2, it works.
It doesn't work for anything above 3: "Error - Expression does not evaluate to a legal natural number"

Also, I tried using a static random integer there too by the form of floor(rand_static(0,8)), and that didn't work either.
I'm using Context Free 3.0.5 (v34) 64-bit for Windows

Re: Natural Number Parameters

Posted: Tue Mar 12, 2013 2:19 pm
by MtnViewJohn
There is an upper limit to the legal natural numbers. The default limit is 1000. Once you add past the limit, Context Free stops with an error. Put

Code: Select all

CF::MaxNatural = 1000000
in your code and the issue will go away. If you are adding to a natural number then you either need to set a high limit or check how close you are getting to the limit. I think that perhaps there should be a '++' operator that adds natural numbers and saturates to CF::MaxNatural, like '--' saturates to zero.