[racket] Fwd: Re[2]: Racket/class, inherit-field all
OK. I understood about common case.
But may I at least look in compile time what fields the class have?
(define a (class object% (super-new) (field f1 f2 f3)))
In runtime I can do (field-names (new a)). But in syntax `a' has no value. Even for struct one can have compile-time information fo accessors, but how to make it with classes?.
Tue, 1 Apr 2014 11:10:09 -0400 от Matthias Felleisen <matthias at ccs.neu.edu>:
>
>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
>
--
Roman Klochkov
----------------------------------------------------------------------
--
Roman Klochkov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140401/bab3ad8a/attachment.html>