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

*To*: Michael Sperber <sperber@xxxxxxxxxxxxxxxxxxxxxxxxxxx>*Subject*: Re: Problems with field initialization: Proposal*From*: Andre van Tonder <andre@xxxxxxxxxxxxxxxxx>*Date*: Thu, 15 Sep 2005 16:41:04 -0400 (EDT)*Cc*: srfi-76@xxxxxxxxxxxxxxxxx*Delivered-to*: srfi-76@xxxxxxxxxxxxxxxxx*In-reply-to*: <y9lr7bq8ag1.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>*References*: <200509151634.j8FGYlec024397@xxxxxxxxxxxxxxxxxxx> <y9lr7bq8ag1.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>

On Thu, 15 Sep 2005, Michael Sperber wrote:

Andre van Tonder <andre@xxxxxxxxxxxxxxxxxxx> writes:As an example, the hash-table example could be expressed: (define-type hash-table (constructor (k) (lambda (pred hasher size) (k pred hasher (make-vector (nearest-prime size)) 0))) (fields (pred immutable) (hasher immutable) (data mutable) (count mutable)))) (define-type eq-hash-table (parent hash-table) (constructor (k) (lambda (pred hasher size) (k pred hasher size 0))) (fields (gc-count mutable)))I'm confused about the K argument in the EQ-HASH-TABLE example. Does it call the primitive constructor of the underlying record type, or the construction procedure of the supertype? If the former, there's one argument missing. (And I'd ask how I could reuse the construction procedure of the supertype.) If the latter, what's it's return value, and how do I transform it into an instance of the subtype?

Here is an alternative suggestion: (define-type hash-table (constructor (lambda (pred hasher size) (values pred hasher (make-vector (nearest-prime size)) 0)) (fields (pred immutable) (hasher immutable) (data mutable) (count mutable)))) (define-type eq-hash-table (parent hash-table) (constructor (lambda (pred hasher size) (values pred hasher size 0))) (fields (gc-count mutable)))

supertype instances.

Cheers Andre

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

**References**:**Re: Problems with field initialization: Proposal***From:*Andre van Tonder

**Re: Problems with field initialization: Proposal***From:*Michael Sperber

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