Re: Major Bug in Interpreter [Attn: Robert Craig]

new topic     » goto parent     » topic index » view thread      » older message » newer message

Alexander Toresson wrote:
> 
> Robert Craig wrote:
> > 
> > Kat wrote:
> > > On 13 Feb 2005, at 12:14, Mario Steele wrote:
> > > > But anyways, I got it figured out now.  It lends nothing to readability,
> > > > just confusion, and making recursive calls to modify sequences utterly
> > > > useless.
> > > 
> > > Deja vu all over again. I stopped using Turbo Pascal because of variable-
> > > recursion problems like this.
> > 
> > There are no known problems with recursion in Euphoria.
> 
> Only disagreements of how it should work, and the current way is a problem
> in the eyes of many.
> 
> > The fact that his example uses recursion is a "red herring".
> > The incompatibility that we discussed has *nothing* to do with recursion.
> 
> Though it *does* affect recursion.
> 
> > It has to do with modifying a variable in two different ways
> > in the same statement, and expecting it to work a certain way,
> > even though the manual is silent on the issue. In 2.5 this rare
> > and weird case now works differently when multiple subscripts
> > are used on the lhs. The change was needed to efficiently support 
> > the new $ feature.
> 
> Maybe it's rare, but not weird. I myself think it's obvious that the rhs is
> evaluated before the lhs is evaluated and assigned the value of the rhs.
> Because that's what the code says. Evaluate the rhs, then assign it to the
> lhs.
> 
> I don't understand the reason changing that.
> 

>From the disassembly Matt posted, it appears that Eu does no constant folding 
usually. What RC is telling us is that $ uses some constant folding.
When computing s[1][length(s[1])], the interpreter doesn't remember that 
there's a temporary var holding s[1] at the time it parses the second index; 
even worse, the temp was possibly destroyed, so that remembering it wouldn't
help.
Thus, s[1] is fetched once again, which is a waste of CPU cycles.
s[1][$] does remember that s[1] is being subscripted, so that no extra 
time is spent looking twice for s[1] or its length. I remembered an old post
2-3 years ago about about Eu 2.3 not using constant folding as an optimisation 
tool, and found that would explain the story neatly.


CChris

> Regards, Alexander Toresson
> 
> Assembly. Push 'till you pop.
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu