J
Joseph Lenton
I'm currently building a Ruby-like language, heavily influenced by Ruby.
One things I'm planning to add soon is modules, mainly for mixins (and
this will only be how it'll be used at first).
But as it's Ruby-like not Ruby I'm also trying to think of improvements
I can make, things I can add which are better.
What I'm currently thinking of is adding a 'before' and 'after' keyword
for methods in modules, like:
module Foo
after bar()
// do something
end
end
If the module is included to a class that contains the method 'bar',
then the modules 'bar' method is called after the classes bar method.
I'm pretty
certain it's possible to build stuff like this in Ruby, but I'm thinking
of baking this into my language to make it easier to do more aspect-like
programming.
My language is for games development, and so one good example of this is
that you could build the different parts of the AI as separate modules
which each run after a generic 'update' method stub. Such as modules for
DamagePlayer, MoveToPlayer, MoveRandomly, and so on. Game classes can
then include all the different modules to that make them.
What I'm after is some feedback on this idea. An alternative would be to
keep modules as modules and build this as a separate aspect components
that cut into those classes. Do people think my suggestion would do this
better or worse then that?
If you were also trying to build a better module system then Ruby's
(which I already think is better then those in most languages) what
would you want to be able to do?
Another idea I was thinking of moving towards would be if you could
compose whole objects solely from mixing modules together. Like an
asteroid could be a Drawable( asteroid_image ) + MoveRandomly +
DamagePlayer.
What are peoples thoughts?
One things I'm planning to add soon is modules, mainly for mixins (and
this will only be how it'll be used at first).
But as it's Ruby-like not Ruby I'm also trying to think of improvements
I can make, things I can add which are better.
What I'm currently thinking of is adding a 'before' and 'after' keyword
for methods in modules, like:
module Foo
after bar()
// do something
end
end
If the module is included to a class that contains the method 'bar',
then the modules 'bar' method is called after the classes bar method.
I'm pretty
certain it's possible to build stuff like this in Ruby, but I'm thinking
of baking this into my language to make it easier to do more aspect-like
programming.
My language is for games development, and so one good example of this is
that you could build the different parts of the AI as separate modules
which each run after a generic 'update' method stub. Such as modules for
DamagePlayer, MoveToPlayer, MoveRandomly, and so on. Game classes can
then include all the different modules to that make them.
What I'm after is some feedback on this idea. An alternative would be to
keep modules as modules and build this as a separate aspect components
that cut into those classes. Do people think my suggestion would do this
better or worse then that?
If you were also trying to build a better module system then Ruby's
(which I already think is better then those in most languages) what
would you want to be able to do?
Another idea I was thinking of moving towards would be if you could
compose whole objects solely from mixing modules together. Like an
asteroid could be a Drawable( asteroid_image ) + MoveRandomly +
DamagePlayer.
What are peoples thoughts?