Re: [racket] Best practices for classes

2014-10-06 Thread Vincent St-Amour
At Sat, 4 Oct 2014 10:13:14 -0500, Robby Findler wrote: > That said, I do think that our integration of generic operations and > our standard library deserves some more care and perhaps redesign to > make things hang together better. As it stands, we have some > conveniences, but they are limited b

Re: [racket] Best practices for classes

2014-10-04 Thread Matthew Butterick
Actually it's probably better, as it prevents ambiguity about which predicates 'class-instance' should meet. Unlike 'class-instance', the expression '(class-instance)' starts with no predicates, so making '(list? (class-instance))' true won't disrupt anything else. Thus, you can be explicit about w

Re: [racket] Best practices for classes

2014-10-04 Thread Matthew Butterick
I see your point. As a workaround, I suppose it's just as good to combine these ideas and use `prop:procedure` to hook into the `get-list` method. Then, instead of using 'class-instance' as a list, I can use '(class-instance)', and things like (member val (class-instance)) and (map proc (class-inst

Re: [racket] Best practices for classes

2014-10-04 Thread Robby Findler
There is no prop:list like that. Adding more prop:* features (like prop:list) has implications for code that you cooperate with. In particular, when you get something that answers #t to list?, then you can rest assured that calling 'car' or it is a very simple operation (doesn't invoke unknown cod

Re: [racket] Best practices for classes

2014-10-04 Thread Matthew Butterick
Thank you. The `prop:procedure` works as hoped, in that the class instance becomes usable in any form that takes a procedure (including things like map). The `prop:sequence` also works, but … what it seems I really want is `prop:list`, which AFAICT doesn't exist (?) The class I'm making is basica

Re: [racket] Best practices for classes

2014-10-02 Thread Alexander D. Knauth
I don’t know if you can do it with generic interfaces (as in racket/generic), but you can make classes whose instances have struct-type properties such as prop:procedure and prop:sequence (using interfaces as in racket/class, not racket/generic) #lang racket (define proc<%> (interface* ()

[racket] Best practices for classes

2014-10-02 Thread Matthew Butterick
What's the best approach to: + defining a class whose instances can be used as procedures? (define ci (new proc-class%)) (ci arg arg2 ... ) + ... whose instances can be used as lists (or at least support direct iteration?) (define li (new listish-class%)) (for-each displayln li) (map ci li) M