Euphoria Object Oriented Programming
- Posted by Tapani <tapani.talvitie at gmail.com> Jan 01, 2007
- 1101 views
Hi, Although variable types and scopes are superb in Eu, I still miss classes. Namespace identifiers solve only a part of the problem, since they only enable static instances. In my opinion, classes are quite necessary for large programs. I noticed that there's been a lot of debate over OOP in here, but what's the current status? Is RDS or the community planning to add some OOP characteristics to the interpreter in the near future? Here's my suggestion of requirements for the first EuOOP release:
-- static classes might be nice to have -- but I don't think that there's a burning need -- for them since you could have almost the same -- functionality by declaring instance -- in the same include file where you have the class class MyClass [static] -- scope for variables and constants declared here -- should be limited inside the class (private) -- This scope level is really handy for large projects, -- since you don't need to integer MyProperty -- I think that there shouldn't be more than one constructor, -- since using the superb variable type sequence does the trick -- where you would code multiple constructors in traditional -- programming languages. -- constructor should always be optional(?) and procedure procedure constructor(atom MyAttribute1, sequence MyAdditionalAttributes) -- do some stuff MyProperty = 0 end procedure -- destructor should always be optional(?) and procedure -- destructor should not have any parameters(?) procedure destructor() -- do some stuff end procedure procedure SetMyProperty(integer val) MyProperty = val end procedure function GetMyProperty() return MyProperty end function procedure MethodAddToMyProperty(integer val) MyProperty += val end procedure end class -- main: atom MyInstance1, MyInstance2 integer TempVal -- Instances could be declared this way... MyInstance1 = new MyClass(1.1, {}) MyInstance2 = new MyClass(1.1, {1, 2, 3}) -- ...or this way: MyInstance1 = instance(routine_id("MyClass"), {1.1, {}}) MyInstance2 = instance(routine_id("MyClass"), {1.1, {1, 2, 3}}) -- which way is better, I don't know. Opinions? -- To ease the readability and for keeping the similarity to -- other programming laguages, I'd really prefer to use dots: -- Rob, Is this possible? MyInstance1.SetMyProperty(12) TempVal = MyInstance1.GetMyProperty()
This should be too hard to code? In my opinion, inheriting is a bit over valuated, and to keep it simple shouldn't be supported in the first release(s) of EuOOP. Or what do you think? What other OOP stuff people would like to see in Eu? Best regards, -- Tapani Talvitie