1. Maybe slightly interesting, perhaps
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Dec 04, 2003
- 536 views
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. I was trying to redefine integer to be 0..33, to track down a bug, I had about 15 variables, and once one went, domino effect, (long before it actually crashed), but a global search/replace did the trick so no worries. Regards, Pete http://palacebuilders.pwp.blueyonder.co.uk/euphoria.html
2. Re: Maybe slightly interesting, perhaps
- Posted by "Carl R. White" <euphoria at cyreksoft.yorks.com> Dec 04, 2003
- 540 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 ]
3. Re: Maybe slightly interesting, perhaps
- Posted by "Carl R. White" <euphoria at cyreksoft.yorks.com> Dec 04, 2003
- 542 views
Carl W. wrote: > without warning > type integer(eu_integer i) if eu_integer(i) then Oops. That should read: without warning type integer(object i) if eu_integer(i) then Sorry about that. Carl -- [ Carl R White == aka () = The Domain of Cyrek = ] [ Cyrek the Illogical /\ www.cyreksoft.yorks.com ]