Page 7 of 25

Re: middleclass & middleclass-extras: Object Orientation for

Posted: Tue Oct 19, 2010 4:11 pm
by bartbes
kikito wrote:[...]in Lua too much syntactic sugar can make your code "too fat".
Oh but that isn't just lua. Don't forget, lua itself is very small, but that also prevents it from having the sugary goodness that is += and friends.

Re: middleclass & middleclass-extras: Object Orientation for

Posted: Tue Oct 19, 2010 8:45 pm
by kikito
Well, ruby lets you do syntactic sugary things easily, elegantly, with little code and no noticeable performance impact.

... the trick being that "no noticeable performance impact" means that it will just run as slow as always, and consume more or less the same outrageous amount of memory. Which is why games aren't coded in ruby (yet).

In other news, I've decided to make (yet again) another change on the Callbacks module. It is getting smaller and better at the same time.

EDIT: and... it is up. I now how to fix the Apply module though.

EDIT2: Apply is modified, only some tests are outstanding. I'll start integrating with PÄSSION (finally)!

I'm still thinking about transforming MindState into a module. The name would have to be changed to something a bit less catchy. Probably 'Stateful': Actor:implements(Stateful) has a ring that I like. In any case, I will make the initialization to be done 'on demand' instead of 'forcefully on initialization' so people don't have the same problem TechnoCat had.

But, for now, it is time to go to bed.

Re: middleclass & middleclass-extras: Object Orientation for

Posted: Wed Oct 20, 2010 4:31 am
by Jasoco
Yeah, I miss being able to use variable++.

Re: middleclass & middleclass-extras: Object Orientation for

Posted: Fri Oct 22, 2010 6:19 pm
by kikito
Small update: finished implementing the Apply specs and everything works as expected.

I've been able to remove a big dependency from middleclass and middleclass-extras: rake. Previously it was needed in order to run the tests, but now just Lua and telescope are required.

This weekend I'll see if I can transform StatefulObject into a Mixin (Stateful). I'm still not sure about it, but it feels right. It is really really the last thing I'll do before starting integration with PÄSSION.

Re: middleclass & middleclass-extras: Object Orientation for

Posted: Sat Oct 23, 2010 6:26 pm
by kikito
Big update!

I've done significant changes in MindState. I've even changed its name:

MindState is now called Stateful.

Not only that, StatefulObject has been transformed into a Mixin, so it behaves as the rest of the pack in middleclass-extra.

Previous version (with MindState):

Code: Select all

Goblin = class('Goblin', StatefulObject)
New version (with Stateful):

Code: Select all

Goblin = class('Goblin'):include(Stateful)
--also valid:
Goblin = class('Goblin')
Goblin:include(Stateful)
The main advantage is that now you can inherit from other classes; the Statefulness doesn't 'force' you to use StatefulObject as a superclass. Like so, you can use a non-stateful class as a parent of a stateful class. For example, Enemy could be Goblin's superclass:

Code: Select all

Goblin = class('Goblin', Enemy):include(Stateful)
I've also cleaned up some old, unused code and conditions. Stateful should be slighly more efficient than StatefulObject.

Tomorrow I'll be updating the wiki and docs.

By the way - what is the equivalent of making a 'folder' on the wiki? I'd like to include documentation of all middleclass-extras, but having everything on one single wiki page would make it very long.

Re: middleclass & middleclass-extras: Object Orientation for

Posted: Sat Oct 23, 2010 7:48 pm
by TechnoCat
kikito wrote:The main advantage is that now you can inherit from other classes; the Statefulness doesn't 'force' you to use StatefulObject as a superclass. Like so, you can use a non-stateful class as a parent of a stateful class. For example, Enemy could be Goblin's superclass:

Code: Select all

Goblin = class('Goblin', Enemy):include(Stateful)
I look forward to updating my git repo.
kikito wrote:By the way - what is the equivalent of making a 'folder' on the wiki? I'd like to include documentation of all middleclass-extras, but having everything on one single wiki page would make it very long.
Either internal wiki links with [[keyword]] or a long page with a toc, table of contents, at the top.
For the internal links, you can just start linking to pages that don't exist yet. And then click on them and edit the target blank page later.

Re: middleclass & middleclass-extras: Object Orientation for

Posted: Sat Oct 23, 2010 8:24 pm
by Robin
Aw, you do this just after I start my first project with MindState? :(

And no more robin = Enemy() on the wiki! :x

As for subpages, I'm not sure if it works in the default namespace as well, but you sometimes see page names like Main/Sub used on Wikipedia and other Mediawiki sites.

Re: middleclass & middleclass-extras: Object Orientation for

Posted: Sat Oct 23, 2010 11:37 pm
by kikito
Robin wrote:Aw, you do this just after I start my first project with MindState? :(
I tried to warn in advance. I'll try to make them more visible in the future.

In any case, the only lines you would only have to change are the ones dealing with class creation. The rest should remain the same.
Robin wrote:And no more robin = Enemy() on the wiki! :x
Ah, come on. If I remove that now, won't you be a little sad? :)
Robin wrote:As for subpages, I'm not sure if it works in the default namespace as well, but you sometimes see page names like Main/Sub used on Wikipedia and other Mediawiki sites.
Oh ok. I thought I had seen sub-folders somewhere. I'll just do regular pages with names preceded by middleclass-extras.

Re: middleclass & middleclass-extras: Object Orientation for

Posted: Sat Oct 23, 2010 11:42 pm
by Robin
kikito wrote:I tried to warn in advance. I'll try to make them more visible in the future.
That was me, not having paid attention. :roll:
kikito wrote:In any case, the only lines you would only have to change are the ones dealing with class creation. The rest should remain the same.
Oh, good.
kikito wrote:Ah, come on. If I remove that now, won't you be a little sad? :)
Yes.

Re: middleclass & middleclass-extras: Object Orientation for

Posted: Sun Oct 24, 2010 9:31 pm
by Robin
With the most recent GitHub version, :include() returns nil.

EDIT: also, there doesn't seem to be a :getCurrentState() function or the like, but I want use states for callbacks. Is there a non-hackish solution for this?