nadako / Ash-Haxe

Port of Ash entity framework to Haxe
Other
131 stars 37 forks source link

Burp extends Node<Burp> #22

Open scriptorum opened 9 years ago

scriptorum commented 9 years ago

I love this library, but I dislike how nodes are defined: by extending a Node with a class parameter type of itself. This notation makes my head swirl. :) Without getting into the discussion of node macros, this legal Haxe trick makes it confusing write methods that accept a node as a parameter, which generally look like Engine.getNodeList:

public function getNodeList<TNode:Node<TNode>>(nodeClass:Class<TNode>):NodeList<TNode>

Since Node is an autobuilding macro, couldn't the macro generate the next and previous fields dynamically, so that all nodes just extend Node and we can eliminate the type parameters?

nadako commented 9 years ago

Yeah that doesn't look too good. That's because ash was the first project I ported when I started learning Haxe. It should be completely reviewed and cleaned up from boilerplate, but I don't think I'll have time/motivation for that soon.

I should however recommend Edge library by @fponticelli (https://github.com/fponticelli/edge) that provides pretty much the same functionality as Ash, but it's much more haxey and straightforward.

scriptorum commented 9 years ago

I do like how Edge seems to eliminate nodes for systems, reducing some boilerplate, but I haven't looked deep into the implementation. For the most part your port of Ash is really rather clean and elegant. I hesitate to replace it. :)