[plt-scheme] Style question

From: Tomasz (tomasz.skutnik at gmail.com)
Date: Sat May 30 16:12:31 EDT 2009


I'm writing simple PostgreSQL connection pool (spgsql based). I've
little scheme experience and I have style question. I've defined pool
as structure (basically opaque type from user perspective):

(define-struct pool (max-size queue connection-producer connection-
closer custodian))

and i've written constructor-like function (provided from module):

(define (create-pool max-size connection-producer connection-closer)
  (let ((pool (make-pool max-size (make-queue max-size) connection-
producer connection-closer (make-custodian))))
    ;; some more initialization snipped for clarity

I was wondering if this is "proper" style. How is constructor-like-
function idiom typically implemented in Scheme? At first it seemed to
me that "make-pool" would be more appropriate (maybe with some magic
prop:constructor function property to initialize) but on the other
hand I'm not entirely sure that such overloading of standard make-
<type> meaning is apropriate...

Any comments?

Best regards


Posted on the users mailing list.