Natural Number Parameters

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

Moderators: chris, MtnViewMark, MtnViewJohn

Post Reply
ColorMeImpressed
Posts: 7
Joined: Tue May 05, 2009 5:07 pm

Natural Number Parameters

Post by ColorMeImpressed » Tue Mar 12, 2013 1:35 pm

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

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

Re: Natural Number Parameters

Post by MtnViewJohn » Tue Mar 12, 2013 2:19 pm

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest