On Sat, May 14, 2011 at 7:06 AM, Reiner Pope <reiner.p...@gmail.com> wrote:
I was distracted while answering your message... Let me try again to reply in more specific terms :) > Is there a policy for strictness of datatypes in Yi, and what is it? > Specifically: > > When I write a datatype, which fields should I make strict? For instance, > all fields in Editor are strict, and all fields except 'height' and > 'winRegion' in Window are strict. Is there some reasoning underlying this? I suppose this is harmless (eg. the window height will be forced every time). There is no reason to have it lazy though, so we could have as a policy to make all fields in the Window record strict. > What should I do to ensure strictness of lazy datatypes like [a]? For > instance, the 'bufAccessList :: ![BufferRef]' field of 'Window' is marked > strict, but is a list. Is it the client's duty to ensure that this list is > fully evaluated? I am not sure what you mean with "client" there. The bufAccessList is forced only once in a while (when switching buffers), so it must be strict to avoid accumulation of thunks. A-priori this list should not be huge, but when I debugged space leaks I had to iron them all out; it's hard to see the difference between big leaks and small leaks on small examples. > Would there be any objections to using the 'deepseq' package to ensure > evaluation? The 'NFData' class is supported by Derive, so it might be > possible to generate many instances automatically. You do not want to have an operation that will take O(n) time at every keystroke, where n = total size of buffers. Also I believe that the Rope datastructure we use for buffers takes advantage of laziness, so it might be unwise to deepseq it. Cheers, JP. -- Yi development mailing list yi-devel@googlegroups.com http://groups.google.com/group/yi-devel