middleclass & extras: middleclass 3.0 is out!

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: middleclass & middleclass-extras: Object Orientation for

Post 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.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: middleclass & middleclass-extras: Object Orientation for

Post 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.
When I write def I mean function.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: middleclass & middleclass-extras: Object Orientation for

Post by Jasoco »

Yeah, I miss being able to use variable++.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: middleclass & middleclass-extras: Object Orientation for

Post 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.
When I write def I mean function.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: middleclass & middleclass-extras: Object Orientation for

Post 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.
When I write def I mean function.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: middleclass & middleclass-extras: Object Orientation for

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: middleclass & middleclass-extras: Object Orientation for

Post 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.
Help us help you: attach a .love.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: middleclass & middleclass-extras: Object Orientation for

Post 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.
When I write def I mean function.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: middleclass & middleclass-extras: Object Orientation for

Post 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.
Help us help you: attach a .love.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: middleclass & middleclass-extras: Object Orientation for

Post 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?
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests