1. recursing quirk

-- euphoria version 1.5

-- there's a little quirk with recursing in euphoria, examine the
-- logic in i_am_a_bug() and i_am_not_a_bug(), it appears the same
-- yet executes differently

-- easy to work-around, but interesting to know

procedure debug(object parameter1, object parameter2)
   puts(1, "Parameter 1 is ")
   if atom(parameter1) then
      puts(1, "an atom.")
   else
      puts(1, "a sequence.")
   end if
   puts(1, "  Parameter 2 is ")
   if atom(parameter2) then
      puts(1, "an atom.")
   else
      puts(1, "a sequence.")
   end if
   puts(1, "\n")
end procedure

procedure i_am_a_bug(object tom, object jerry)
   debug(tom, jerry)
   if atom(tom) and sequence(jerry) then
      i_am_a_bug(jerry, tom)  --lets swap and recurse
   end if
end procedure

procedure i_am_not_a_bug(object tom, object jerry)
   object tom2, jerry2
   debug(tom, jerry)
   if atom(tom) and sequence(jerry) then
      tom2 = tom
      jerry2 = jerry
      i_am_not_a_bug(jerry2, tom2)  --lets use private variables instead
   end if
end procedure

i_am_not_a_bug(1, {1})
puts(1, "looks ok to me, parameters have swapped\n")

i_am_a_bug(1, {1})
puts(1, "my my, I now have two copies of parameter2\n")


Matthew McNamara                          _
mat at iconz.co.nz                         o( )
The Internet Company of New Zealand    /  /\

new topic     » topic index » view message » categorize

2. Re: recursing quirk

Matthew McNamara wrote:
>there's a little quirk with recursing in euphoria, examine the
>logic in i_am_a_bug() and i_am_not_a_bug(), it appears the same
>yet executes differently
recursion was nevah my strong point
(show me someone who says their
strong point is recursion and i'll
show you someone who has
STACKS=9e1000,256e10000
in their config.sys)
but i ran your program and got the following output:
----begin paste
Parameter 1 is an atom.  Parameter 2 is a sequence.
Parameter 1 is a sequence.  Parameter 2 is an atom.
looks ok to me, parameters have swapped
Parameter 1 is an atom.  Parameter 2 is a sequence.
Parameter 1 is a sequence.  Parameter 2 is an atom.
my my, I now have two copies of parameter2
----end paste
now this was run with euph 2.0 and i dont see a problem?!?!
it's very much granted that i may not know what i'm looking
at here... also it may have been fixed in 2.0???

--eagerly awaiting enlightenment
--Hawke'

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

3. Re: recursing quirk

On Tue, 25 Aug 1998, Hawke wrote:

> Matthew McNamara wrote:
> >there's a little quirk with recursing in euphoria, examine the
> >logic in i_am_a_bug() and i_am_not_a_bug(), it appears the same
> >yet executes differently
> but i ran your program and got the following output:
> ----begin paste
> Parameter 1 is an atom.  Parameter 2 is a sequence.
> Parameter 1 is a sequence.  Parameter 2 is an atom.
> looks ok to me, parameters have swapped
> Parameter 1 is an atom.  Parameter 2 is a sequence.
> Parameter 1 is a sequence.  Parameter 2 is an atom.
> my my, I now have two copies of parameter2
> ----end paste
> now this was run with euph 2.0 and i dont see a problem?!?!
> it's very much granted that i may not know what i'm looking
> at here... also it may have been fixed in 2.0???

Looks like the problem does not occur in version 2.0, in version
1.5 the second to last line reads...
Parameter 1 is a sequence.  Parameter 2 is a sequence.

Matthew McNamara                          _
mat at iconz.co.nz                         o( )
The Internet Company of New Zealand    /  /\

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

4. Re: recursing quirk

Matthew McNamara wrote:
> Looks like the problem does not occur in version 2.0, in version
> 1.5 the second to last line reads...
> Parameter 1 is a sequence.  Parameter 2 is a sequence.
AH! now that output would be rapidly approaching the
"errrrr that's not quite right" category...
i must admit i was confused after reading your code
and seeing the output given to me after running it...
heh... couldnt see the problem, but now i do :)
it wasnt creating another set of local variables!
my brain can rest easy now :)

tnx for pointing this out matthew...

--Hawke'

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

5. Re: recursing quirk

The quirk reported today by Matthew McNamara
was first reported by Jacques Deschenes a year ago.
 1.5a and earlier contain the bug. 2.0 is ok.
See doc\relnotes.doc

Regards,
     Rob Craig
     Rapid Deployment Software
     http://members.aol.com/FilesEu/

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

Search



Quick Links

User menu

Not signed in.

Misc Menu