() Mike Gran <spk...@yahoo.com> () Wed, 3 Apr 2013 07:04:43 -0700 (PDT)
Do you have a personal philosophy on how much you try to minimize the scope of procedures? I figure out the data structures first, then use procedures w/o overmuch regard to inner/outer. However, i... If you were writing a tutorial, what would you say? ...do try to keep to a minimum the number of arguments that are passed from a procedure's caller to procedures it calls. For example, in SGF Utils 0.6 src/render.scm, the procedure ‘make-screen-1’ is almost 700 lines long w/ 90 internal procedures, the deepest being 6 levels (at least, depending on what you count, precisely) from top. This particular proc, i.e., ‘make-screen-1 ray! one! poly-vecs two-side normal’: (define (two-sides actually) (define (normal direction) (make-polar radius (+ a (* (/ PI 2) direction)))) (let-values (((mx my) (actually (normal -1))) ((px py) (actually (normal 1)))) (values mx my px py))) is not actually as tight as it could be: (define (two-sides actually) (define (normal direction) (actually (make-polar radius (+ a (* (/ PI 2) direction))))) (let-values (((mx my) (normal -1)) ((px py) (normal 1))) (values mx my px py))) but hey, that's a code enhancement opportunity to mull over while posting, what luck! The point is, the usual alternative to this structuring would be to define a "graphics and board context, both fundamental and elaborated" object to pass around. Shudder. I'd rather have that monster out in the open and fixed (lexically), than roaming hidden behind getters / setters and All That Rot (er, entropy :-D). (It helps, too, to live in Emacs, froth froth.) OK, time to calm down. Scheme is dangerously invigorating... -- Thien-Thi Nguyen GPG key: 4C807502
pgpL25uLHOWoi.pgp
Description: PGP signature