Re: Euphoria Object Oriented Programming
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Jan 04, 2007
- 1088 views
Pete Lomax wrote: > > CChris wrote: > > > Matt wrote a few posts about it this month as he was replying to Tapani. > > Could you comment on his posted code examples, > > I have no real problem with that, then again as Matt implied, it was not > really a great example. Personally I'd prefer multiple constructors to > be replaced with optional parameters, eg: > }}} <eucode> > procedure new(object s1, integer s2=0, s3=0, s4=0) > if sequence(s1) then s4=s1[4] s3=s1[3] s2=s1[2] s1=s1[1] end if > ... > end procedure > </eucode> {{{ > so new({1,2,3,4}) and new(1,2,3,4) work the same and avoid any code > duplication > whatsoever. > I agree with and like the fact there is no destructor in ooeu. > Putting a * for pass by reference needs some thought. If you are going to > have an implicit "this", why not just always pass it by reference? I think a lot of this goes to the origin of ooeu. I started with the eu.ex version that Rob released, and my hope was to be able to generate IL code that could be run by the RDS backend, so I could only do things that didn't need alterations to the backend. Since Rob didn't like the idea of allowing this, I changed course to preprocess ooeu code into RDS eu code (where feasible). Pass by reference definitely requires backend modifications. It had never really occurred to me to make pbr the default on method calls, although it definitely makes a lot of sense. The only problem is that it varies from the Euphoria norm, which is, I guess, why I required it to be explicit. I think that default parameters could have been done, although it would have made it more difficult to match routine signatures. Matt