Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2009-12

mixin feature

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bee Jay

Hi all,

I'm now studying Qooxdoo (JS framework) to make ExtPascal-like tool based on it. Qooxdoo's OO implementation has mixin feature (http://en.wikipedia.org/wiki/Mixin ). Since this feature is not provided by object pascal language, I have trouble writing the library wrapper. For the first step, maybe I just could skip the feature. But this would prevent custom widget creation of Qooxdoo from pascal. Somehow, I'm curious about it since QWT (qooxdoo for GWT) is able to provide mixin in Java which also doesn't support mixin. So I think there must be a way to implement it in Pascal as well.

Can someone tell me how to implement "fake" mixin feature in pascal? Or better, is it possible if FPC provides such language feature? I think it's good language feature (compare to sealed class, for example) and can be quite useful in some cases.

TIA.

-Bee- ...making buzzes at http://twitter.com/beezing ...writing stories at http://beeography.wordpress.com

Reply by email

Jonas Maebe
to Bee Jay
Bee Jay wrote
I'm now studying Qooxdoo (JS framework) to make ExtPascal-like tool based on it. Qooxdoo's OO implementation has mixin feature (http://en.wikipedia.org/wiki/Mixin). Since this feature is not provided by object pascal language, I have trouble writing the library wrapper. For the first step, maybe I just could skip the feature. But this would prevent custom widget creation of Qooxdoo from pascal. Somehow, I'm curious about it since QWT (qooxdoo for GWT) is able to provide mixin in Java which also doesn't support mixin. So I think there must be a way to implement it in Pascal as well.

From the wikipedia page you linked above: "Interfaces combined with aspect-oriented programming can produce full fledged mixins in languages that support such features, such as C# or Java."

I'm not aware of any existing AOP framework for Pascal.

Can someone tell me how to implement "fake" mixin feature in pascal?

I think the regular way to do this in Object Pascal is via implements-style delegation (which doesn't really fake mixins; I think it provides exactly the same functionality, just using a slightly different concept). I don't think that's already fully functional in FPC, but Florian and Sergei (Gorelkin) have recently improved it quite a bit.

Jonas

Reply by email

Bee Jay
to Jonas Maebe
I'm not aware of any existing AOP framework for Pascal.

I don't think neither GWT or QWT is implementing AOP. CMIIW.

Show quoted text 6 lines
I think the regular way to do this in Object Pascal is via implements-style delegation (which doesn't really fake mixins; I think it provides exactly the same functionality, just using a slightly different concept). I don't think that's already fully functional in FPC, but Florian and Sergei (Gorelkin) have recently improved it quite a bit.

Yes. I also think class helper feature may provide similar functionality. But AFAIK FPC doesn't yet support either feature. :(

-Bee- ...making buzzes at http://twitter.com/beezing ...writing stories at http://beeography.wordpress.com

Reply by email

Jonas Maebe
to Bee Jay
Bee Jay wrote
> I think the regular way to do this in Object Pascal is via implements-style delegation (which doesn't really fake mixins; I think it provides exactly the same functionality, just using a slightly different concept). I don't think that's already fully functional in FPC, but Florian and Sergei (Gorelkin) have recently improved it quite a bit. Yes. I also think class helper feature may provide similar functionality.

No, class helpers add a certain method to a particular class. They don't declare a generic implementation that can be added to multiple other classes (except if these other classes inherit from the class the method was added to).

But AFAIK FPC doesn't yet support either feature. :(

As I said, at least svn trunk already supports implements-style delegation to a certain extent (and even 2.4.0 partially supports it). And you can of course also use a regular delegation pattern, since mixins are basically a form of automated delegation (and once interface delegation fully works in the compiler, you can remove your manual wrappers).

Jonas

Reply by email

Marco van de Voort
to Jonas Maebe

In our previous episode, Jonas Maebe said:

Show quoted text 9 lines
>> I think the regular way to do this in Object Pascal is via implements-style delegation (which doesn't really fake mixins; I think it provides exactly the same functionality, just using a slightly different concept). I don't think that's already fully functional in FPC, but Florian and Sergei (Gorelkin) have recently improved it quite a bit. > > Yes. I also think class helper feature may provide similar functionality. No, class helpers add a certain method to a particular class. They don't declare a generic implementation that can be added to multiple other classes (except if these other classes inherit from the class the method was added to).

Not even that afaik. They make a static method appear as it is a member of a class namespace, and only if you import it correctly.

I don't think class helpers are a real language instrument. They are more a workaround for certain cases when other classes are set in stone.

Reply by email

Bee Jay
to Marco van de Voort
I don't think class helpers are a real language instrument. They are more a workaround for certain cases when other classes are set in stone.

I know, class helper is only a work around until pascal supports real mixin feature. But, with that I'm still able to see a workaround. I think I must stay with the first plan, simply ignore mixin and prevent custom widget creation. Until FPC support mixin or similar functionality.

Thanks.

-Bee- ...making buzzes at http://twitter.com/beezing ...writing stories at http://beeography.wordpress.com

Reply by email