Not logged inOpenClonk Forum
Up Topic Development / Developer's Corner / Shorter syntac for proplist inheritance
- - By Günther [de] Date 2010-12-08 20:11
Consider an actmap:
local ActMap = {
  Walk = {
    Prototype = Action;
    Length = 10;
    InLiquidAction = Swim;
    ...
  },
  Run = {
    Prototype = Action;
    Length = 15;
    InLiquidAction = Swim;
    ...
  }
};

To reduce duplication, the Run action should inherit from the Walk action. At the moment, that's not easily possible, but that I think can be solved by changing name lookup a little so that one could write "Prototype = Walk". But that is still a lot to type, and I'd like to improve this. We could replace Prototype with Parent, but that's only a slight improvement probably not worth the cost of changing all scripts. Other possibilities:
Run = Walk {
  Length = 15;
  ...
};
Run = Walk <- {
  Length = 15;
  ...
};
Run = {
  Walk;
  Length = 15;
  ...
};
Run = Walk: {
  Length = 15;
  ...
};

And so forth. The possibilities are vast, especially if we also consider those which use a new keyword like "inherit" or "extend" in there somewhere. Normally, I'd just look what other languages do and copy something I like, which improves the odds of getting something good a lot. But the language we got the proplist literal syntax from, Javascript, has absolutely horrible syntax for this involving a function definition. Other prototype-based object oriented programming languages weren't yet a convincing inspiration either, if they had a object/proplist literal syntax at all. So I need help choosing a syntax.
Reply
Parent - By Newton [de] Date 2010-12-09 04:46
I'm not really sure if actmap inheritance is actually worth the implementation work. I'm not sure whether this feature would be used at all because (I think) the space a scripter would safe by inheriting actions would be minimal.
Up Topic Development / Developer's Corner / Shorter syntac for proplist inheritance

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill