Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!news.cs.indiana.edu!news.nd.edu!mentor.cc.purdue.edu!purdue!haven!umbc3!umbc4.umbc.edu!alex From: alex@umbc4.umbc.edu (Alex S. Crain) Newsgroups: comp.lang.scheme Subject: modularization of scheme code Message-ID: <5241@umbc3.UMBC.EDU> Date: 3 Mar 91 20:26:43 GMT Sender: newspost@umbc3.UMBC.EDU Reply-To: alex@umbc4.umbc.edu.UUCP (Alex S. Crain) Organization: University of Maryland Baltimore County Lines: 59 I'm laying out a rather large project (an operation system) in scheme and I'm looking for a way to restrict the scope of some objects. In C++ or CLOS, I would use objects and methods, in vinnilla CL I would use packages. I can't find a good way to do this in scheme. For example: suppose I was writing window system, and I had written a module for screen management. I would have some local data objects (like the screen data and backing store data (after securing the appropriate patent licence from AT&T, of course). I would also have some local functions and finally, I would have some exported functionality (create-window, etc). I would rather not make my locally used functions and data structures public if I don't have to, both to avoid cluttering the namespace and just for general neatness. Scheme doesn't provide a way (that I know of) of hiding anything except by nesting itside a function, and even if I wrapped the entire module inside of letrec body I don't know how to make the date structures permentent, and I only get one entry point (yuk). Or should I build everything dynamically and export a series of continuations to use as entry points, ala: (define (init-screen non-local-exit) (letrec ((screen-data (make-vector ...)) (entry-points '(())) ... ) ;; ;; define the new entry points ;; (let ((x (call/cc (lambda (k) (cons 'init k))))) (case (car x) ((init) (set-car! entry-points (cdr x))) ((create-window) ...) ((delete-window) ...) ...)) (non-local-exit entry-points))) (define (go) (let ((screen-calls (call/cc (lambda (k) (init-screen k))))) ... (screen-calls 'create-window) ... (screen-calls 'delete-window))) So, pray tell, whats to scoop? I'm working out of R3.99rs, so if this is crystal clear in 4.0, just say so. ################################# :alex. #Disclaimer: Anyone who agrees # Systems Programmer #with me deserves what they get.# University of Maryland Baltimore County ################################# alex@umbc3.umbc.edu