1. Maybe slightly interesting, perhaps

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

new topic     » topic index » view message » categorize

2. Re: Maybe slightly interesting, perhaps

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 ]

new topic     » goto parent     » topic index » view message » categorize

3. Re: Maybe slightly interesting, perhaps

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 ]

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu