[racket] Can impersonator be a cache?
> Why not just define a new version of object-a that does that?
(set! object-a
(let ([old object-a])
(lambda (x)
(if (reference? x)
(ref-get old x)
(old x)))))
Like that for every accessor? + prop:impersonator-of... Maybe shall work.
Fri, 15 Aug 2014 08:45:59 -0400 от "Alexander D. Knauth" <alexander at knauth.org>:
>
>Why not just define a new version of object-a that does that?
>You probably have a good reason, but what is it?
>Is it to change the result of struct->vector, allow (object a b c) as a match pattern to match ref, or what?
>
>On Aug 15, 2014, at 6:42 AM, Roman Klochkov < kalimehtar at mail.ru > wrote:
>
>> I have
>> (struct object (a b c))
>> (struct reference (id data))
>>
>> Let `ref' -- an instance of `reference'.
>>
>> I want, that (object-a ref) call my own (ref-get object-a ref)
>>
>> (define (ref-get accessor ref)
>> (unless (weak-box-value (ref-data ref))
>> (set-ref-data! ref (make-weak-box (load-data (ref-id ref)))))
>> (accessor (weak-box-value (ref-data ref))))
>>
>> Is it possible?
>> I found `impersonate-struct', but it is not struct itself (no `id' field).
>> I can add `prop:impersonator-of',. but how to redirect accessors?
>>
>> --
>> Roman Klochkov
>> ____________________
>> Racket Users list:
>> http://lists.racket-lang.org/users
>
--
Roman Klochkov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140815/34a988b3/attachment.html>