Re: Call for Opinions
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> May 23, 2005
- 432 views
Pete Lomax wrote: > > On Sat, 21 May 2005 20:09:30 -0700, Mario Steele > <guest at RapidEuphoria.com> wrote: > > >Problem is Pete, yes, struct in that example is declared as MyStruct. > >HOWEVER, > >what about type-casting? > Afaik, Eu does not have, need, or want type-casting. Correct, standard, RDS Eu does not. However, type-casting can become important in an OOP setting. Mario brings up the case of sub-classing, but I think a better example would be when you want to treat some arbitrary piece of data as an object of some class that you've defined. In OOEU, you can declare variables as a class' type. The interpreter then knows some things about it, and knows that there are certain functions that go with it. But what if you have a regular sequence or something, and want to use it as a class object? Then you need to be able to cast it as such. > >Example of Type Casting: > <snip> > > >If we went the way you suggest, then this would become obsolete, as > >sub-classing > >couldn't be controled. > I don't understand, did you mean:. > }}} <eucode> > if platform() = 3 then > MyClassA MyNewVar > MyNewVar@new({1,2,3}) > else > MyClassB MyNewVar > MyNewVar@new({1,2,3,4}) > end if > </eucode> {{{ </font> > Why would @ be better than = ? I think he's talking about having MyClassA, which derives from MyClassB. There could be a case where you'd want to call some routine from MyClassB that was overridden in MyClassA. The point of the '@' is to give ooeu a pseudo PBR type ability. The point is that you're constructing the object, so it has no value. You can't pass it to the function, and the function is going to give it it's value, so there's not really any point in passing something else as a proxy, so let the interpreter pass some default, dummy value. Matt Lewis