anthony.liot Posted September 26, 2013 Share Posted September 26, 2013 Hi, I have some request about missing possibility in the script,May be is not possible to do this, it's just a suggestion.1) Constructor with different type of parameter but the same number of parameter like class FOO { STS sts; FOO( string str) { sts = new STS(str); } FOO( STS obj) { sts = obj.clone(); } }; For the moment we add in the constructor an other foo parameter for the second constructor. 2) structure type and typedef, sometime is not really necessary to have an object just a structure like struct element { int a; int b; int c; }; For the moment in script we are just making class. Link to comment
ulf.schroeter Posted September 26, 2013 Share Posted September 26, 2013 1) UNIGINE script is untyped, so the script engine cannot distingush between same single-argument constructors. But I think it should be possible to have a constructor FOO( int value ) and within the constructor test for the actual type of value and act accordingly. 2) I don't think it's a good idea to copy all C++ language constructs as this increases language complexity. That was one reason why Java - designed based on bad C++ experiences - also dropped these constructs. Link to comment
anthony.liot Posted September 26, 2013 Author Share Posted September 26, 2013 Hi Ulf, 1) Yep true, about untyped script, i will try your proposal about pass int value and test the type of the parameter. 2) About struct, I understand the problem to increase script complexity, and how i say i use class, but I recently write a parser for pln file and i have so many little class, it's for that I talk about struct.Anyway, thanks, for your response, interesting as always :)Tony Link to comment
ulf.schroeter Posted September 26, 2013 Share Posted September 26, 2013 You're welcome, check typeid()/classid() as described in frustrum's script tips and tricks Link to comment
Recommended Posts