Re: Maybe slightly interesting, perhaps
- Posted by "Carl R. White" <euphoria at cyreksoft.yorks.com> Dec 04, 2003
- 539 views
Pete Lomax wrote: > No, it doesn't matter, but someone may be mildly curious (Rob?): > > type integer(integer i) > return 1 > end type > > The interpreter goes into an infinite loop. I think I can guess why. The redefinition of integer occurs before it can be used for the parameter to the redefined type, so yes, the new type calls itself. The standard Euphoria idiom is (used to be?) this kind of construct: type eu_integer(integer i) return 1 end type without warning type integer(eu_integer i) return 1 end type with warning The above works because Euphoria doesn't do mutual recursion (by default). <soapbox> Then again, I favour the following method of type definintion as it makes them less likely to crash the interpreter with a type-check error (Oh, the irony...): type eu_integer(object i) if integer(i) then return 1 end if return 0 end type without warning type integer(eu_integer i) if eu_integer(i) then return 1 end if return 0 end type with warning </soapbox> Carl -- [ Carl R White == aka () = The Domain of Cyrek = ] [ Cyrek the Illogical /\ www.cyreksoft.yorks.com ]