[PEAK] recursion limit

P.J. Eby pje at telecommunity.com
Fri Jul 15 18:04:37 EDT 2011


At 09:02 PM 7/15/2011 +0200, nicky van foreest wrote:
>For me this works too, but if you change the range from 30 to 3000,
>say, I suspect you will get an error. In fact, at my machine I already
>get an error when the range is 100.

Ok, confirmed at 100, and switching the 'compute' attrs to 'maintain' 
attrs makes it go away, even up to 10000.


>Ok. I get this. So the trick is to prevent this, like you propose with
>using trellis.maintain.

Yes.  Lazy computation is for things that you may or may not need to 
compute.  If you know you are going to need it from the start, then 
you should use maintain.


>I have some more theoretical questions about trellis. If you don't
>have time, please skip them.  First, if I were to start something like
>trellis, I think I would use some topological sort on a graph. I
>cannot find this in the trellis code.

Cell objects have a level attribute that's used to indicate their 
distance from a dependency graph root; is that what you're asking about?


>  Second, I would like to have a
>program/parser that figures out by itself the dependency graph of the
>attributes and functions. Now I have to make explicit the
>trellis.attrs and the trellis.compute.attrs/trellis.maintain.attrs,
>which I would prefer not to do by hand, but let the computer figure it
>out. Why is this is not implemented in trellis? (I must admit that I
>don't quite know how to do this; it is just a question out of
>interest.)

I don't understand what feature you're asking for here.  The 
distinction between compute, maintain, and attrs is part of the 
design of your program, not something that a parser can figure 
out.  By stating that something is a maintained value, it means that 
it may have side-effects and also that it should be able to access 
the previously computed value.  By saying it's computed, you are 
saying there are no side-effects to the computation and that it 
should only be calculated as needed.  Otherwise, it is just an 
observable variable.

There is no way in a language like Python to determine by mere 
code-parsing whether something has side-effects, so that distinction 
at least *cannot* be implemented in an automatic way, no matter how 
good a programmer you are.  ;-)

In any case, the declarations of your attributes and functions serve 
not only as implementation instructions for the Trellis, but also as 
documentation of your intentions to the reader of your code.


>Nicky

P.S. When replying to a message that's on a mailing list like this, 
it's best to use "Reply To All" so that the mailing list is 
included.  (i.e., your message went only to me, and not to the list.)



More information about the PEAK mailing list