Mixins and Interfaces


#1

I want to share something I learned from programming in Googles Dart language. Every object is an interface, so when creating a mixin one can “tell” the mixin to expect certain data to be present. One simply treats all other objects that the mixin depends on as interfaces, even though they are not. So the mixin “knows” when its dependencies have not been met because there is no implementation present that satisfies it. All one has to do is mixin all the proper objects to make the compiler happy. I thought that this feature was really cool I have no idea if it is unique to Dart, it was probably an influence from small talk or some other language, but it is where I first was introduced to the idea. I thought I would share this since I read somewhere that the Skookum team has thought about adding mixins one day.

Of course, do not let this distract you guys from your current work, I am more excited about the events… I want to see how far I can go with decoupling everything!


#2

Thanks for the ideas on extending SkookumScript!

Yes, in the future we plan to extend SkookumScript with either mixins or traits.

You might have come across our mention of it in our FAQ or in this post:

There are several popular languages that use mixins:

Here is a description on traits if you are interested:


#3

Does Skookum use properties for fields/members/slots/attributes/properties/whatever-you-named-it? That is, are the members of the class accessed through getters/setter automatically? How do we override them with our own functionality if this is the case… thanks!

If this has been mentioned somewhere already, sorry I missed it.


#4

After reading about traits they sound very cool. I was “always” a fan of CLOS, traits sound like a great way for skookum to become more CLOS like!


#5

No, members - data members in particular - are automatically publicly accessible.

So a @hit_points data member is just accessed obj.@hit_points.

You can wrap a getter/setter around it for more abstraction. For example:

// hit_points().sk
() Real
  [
  @hit_points
  ]

Then you could write obj.hit_points

You can read more about SkookumScript data members in the online docs. This is a first pass at this doc page and it will be expanded even further though it is a good beginning.

Since SkookumScript is an embedded scripting language and not a general purpose near the metal language such as C++ the design of the language is to keep it simple for scripting.