[racket] Racket/class, inherit-field all

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Apr 1 11:10:09 EDT 2014

There can't be: 

(define c-without-fields (class object% (super-new)))
(define c-with-a-field (class object% (super-new) (field [a 0])))

(define d (class (if (tuesday?) c-without-fields c-with-a-field) (super-new) ... a ...))

It is impossible to determine whether this module is closed i.e. a valid program. 



On Apr 1, 2014, at 11:06 AM, Asumu Takikawa <asumu at ccs.neu.edu> wrote:

> On 2014-04-01 13:43:55 +0400, Roman Klochkov wrote:
>>   Is there a way to inherit all fields ?
>> 
>>   For example
>> 
>>   (define a (class object% (super-new) (field f1 f2 f3)))
>> 
>>   (define b (class a (super-new) (field f4 f5 f6)))
>> 
>>   (define c (class b (super-new) (inherit-field f1 f2 f3 f4 f5 f6)))
>> 
>>   How to avoid manual enumeration of all f1 ... f6?
> 
> I don't think there is, because you don't always know what what fields
> your superclass will have. The `inherit-field` form gives you meaningful
> errors if your superclass turns out not to have the field to inherit,
> but it's not clear what to do for "all fields".
> 
> Cheers,
> Asumu
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.