[racket] Macro for code organisation

From: Eli Barzilay (eli at barzilay.org)
Date: Mon Jun 4 21:10:56 EDT 2012

Two hours ago, Harry Spier wrote:
> 
> This works fine, but I was wondering if for readability macros could
> be use to set up a kind of "internal require" of the helper
> functions so I could have the main loop before the internal
> definitions of the helper functions it refers to.

You don't need macros for that:

  (define (blobify pixel-graph)
    (define (main-loop)
      (for ([current-strip pixel-graph])
        (blobify-connected-nodes current-strip)))
   
   ;; Helper functions
   (define (blobify-connected-nodes node-number)
     ...refers to pixel-graph and
     the other helper functions...)
   
   (define (get-node node-number)
     ..refers to pixel-graph...)
   
   (define (set-node-blob-number! node)
     ...refers to pixel-graph)
   
   (define (compare-node-numbers node1 node2)
     ...refers to pixel-graph...)
   
   (main-loop))

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.