Re: New Language
- Posted by Derek Parnell <ddparnell at bigpond.com> Sep 27, 2006
- 583 views
Mike Nelson wrote: > I consider it a new Euphoric language. There will be no attempt at backward > compatibiltity with Eu itself or even the Method Eu library. What I am > envisioning > is a language which is OOP from the ground up but has much of the essential > power and flavor of Eu. I fully encourage you with this idea Mike. However, being the intrusive bastard that I am, I have a couple of suggestions for you Have you considered making all members (data and methods) 'private' by default? This makes objects a lot more robust as access from outside the class must be explicitly granted by the class designer. Have you considered implementing 'class properties'? These behave to the outside as if they are data members but are actually implemented as member functions. Each property can have multiple 'setter' and 'getter' functions. For example: class Quad integer h integer l integer a procedure ctor() h = 0 l = 0 a = 0 end procedure procedure ctor(integer pH, integer pL) h = pH l = pL a = h * l end procedure procedure ctor(integer pA) h = floor(power(pA, 0.5)) l = h a = h * l end procedure property height function get() return h end function function get(sequence) return sprintf("%d", h) end function function set(integer pH) if pH > 0 then h = pH a = h * l -- recalc area else throw exception("Height must be +ve") end if end function end property property length function get() return l end function function get(sequence) return sprintf("%d", l) end function function set(integer pL) if pL > 0 then l = pL a = h * l -- recalc area else throw exception("Length must be +ve") end if end function end property property area function get() return a end function function get(sequence) return sprintf("%d", a) end function end property end class and used thus ... object f f = Quad(7,8) ? f.area -- displays 56 f.length = 5 ? f.area -- displays 35 f.length += 1 ? f.area -- displays 42 ? f.height -- displays 7 ? f.length -- displays 6 ? f.h -- Not accessible error. f.area = 36 -- Member is read-only Properties add more robust abstraction without making coding onerous. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell