[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: srfi-76@xxxxxxxxxxxxxxxxx*Subject*: Re: Problems with field initialization: Proposal*From*: Andre van Tonder <andre@xxxxxxxxxxxxxxxxxxx>*Date*: Fri, 16 Sep 2005 14:16:59 -0400 (EDT)*Delivered-to*: srfi-76@xxxxxxxxxxxxxxxxx*Reply-to*: Andre van Tonder <andre@xxxxxxxxxxxxxxxxxxx>

Mike Sperber wrote: > the association between construction > procedure arguments and fields is by name rather than by position. This is indeed a weakness of my suggestion. I think it can be fixed but let me think about it. > - Add a LET clause that introduces a binding into the constructor like > so: > > (define-type rational (x y) > (let ((common (gcd x y)))) > (fields > (num (rational-num) (/ x common)) > (denom (rational-denom) (/ y common)))) Hmm. This is interesting. The body of the type definition is starting to look like a lambda body, which is actually not too far from my suggestion. But how would you express this? (define-type rational (constructor (lambda (x y) (if (= y 0) (values 1 0) ; my representation of infinity (let ((common (gcd x y))) (values (/ x common) (/ y common)))))) (fields num denom)) Cheers Andre ------------- End Forwarded Message -------------

- Prev by Date:
**Re: Problems with field initialization: Proposal** - Next by Date:
**Re: Problems with field initialization: Proposal** - Previous by thread:
**Re: Problems with field initialization: Proposal** - Next by thread:
**Re: Problems with field initialization: Proposal** - Index(es):