[racket-users] Can Racket implement LockedMagicDoor example of MIXEDJAVA?

2020-08-09 Thread Siyuan Chen
Hi all, Recently I read the paper "Classes and Mixins" by Matthew Flatt, Shriram Krishnamurthi and Matthias Felleisen. In this paper, the authors presented MIXEDJAVA. In MIXEDJAVA, > A programmer implements mixins in exactly the same > way as a derived class, except that the programmer cannot >

Re: [racket-users] Can Racket implement LockedMagicDoor example of MIXEDJAVA?

2020-08-11 Thread Ryan Culpepper
I don't know of a way to solve that problem using the Racket class system alone, but here is a solution that uses traits instead, which allow you to rename the hook methods after the fact so they don't collide. ;; (require racket/trait) (define secure-trait (trait (inherit nee

Re: [racket-users] Can Racket implement LockedMagicDoor example of MIXEDJAVA?

2020-08-12 Thread Siyuan Chen
Dear Ryan, Thanks for your solution, it works nicely! But I still have some questions: For this particular problem of LockedMagicDoor, we can use `trait` to solve the `mixin` problem, but can we use the same method for more general problems? Since traits and mixins are essentially different, th

Re: [racket-users] Can Racket implement LockedMagicDoor example of MIXEDJAVA?

2020-08-12 Thread Ryan Culpepper
On Wed, Aug 12, 2020 at 7:19 PM Siyuan Chen wrote: > Dear Ryan, > > Thanks for your solution, it works nicely! > > But I still have some questions: > > For this particular problem of LockedMagicDoor, we can use `trait` to > solve the `mixin` problem, but can we use the same method for more genera

Re: [racket-users] Can Racket implement LockedMagicDoor example of MIXEDJAVA?

2020-08-13 Thread Siyuan Chen
Dear Ryan, No, traits can contain fields, which are mutable, so a trait can manage > state. > Thanks, I tested it. You are right, traits can manage states. Right, one trait cannot override another's definitions. One thing you > could do instead is use `trait-exclude` to remove the definition