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

This page is part of the web mail archives of SRFI 76 from before July 7th, 2015. The new archives for SRFI 76 contain all messages, not just those from before July 7th, 2015.

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

Mike Sperber wrote: > - 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)))) Would you perhaps consider a slight variation of this: (define-type rational (x y) (let ((common (gcd x y))) (field-values (num (/ x common)) (denom (/ y common)))) (fields (num (rational-num)) (denom (rational-denom)))) It is only slightly more verbose, but now it can handle this: (define-type rational (x y) (if (= y 0) (field-values (num 1) (denom 0)) (let ((common (gcd x y))) (field-values (num (/ x common)) (denom (/ y common))))) (fields (num (rational-num)) (denom (rational-denom)))) Andre

**Follow-Ups**:**Re: Problems with field initialization: Proposal***From:*Michael Sperber

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