| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| The message below is being cross-posted from the LogoForum. Please reply here at comp.lang.logo and it will be cross-posted back to the LogoForum. The original author of this message is taobert@yahoo.nospam.fr. Hello Logo World, Just a question for Andreas (or for aUCBLogo users): Why the lexical scoping of aUCBLogo behaves differently between interactive mode and program mode ? Here are examples: --- Direct mode (copy of my aUCBLogo console) ; Welcome to aUCBLogo version 4.7 x = 1 be f * output x end be g x * output f end f 1* ;-) g 0 0* ;-)* logically it should be 1 --- Program mode be f *** output x end be g x *** output f end to test_scope *** x = 1 *** print f *** print g 0 end 1 1 ;-)* results are correct Regards, Bertrand __._,_.___ LogoForum messages are archived at: http://groups.yahoo.com/group/LogoForum |
|
#2
| |||
| |||
| The message below is being cross-posted from the LogoForum. Please reply here at comp.lang.logo and it will be cross-posted back to the LogoForum. The original author of this message is Andreas.Micheler@gmx.nospam.de. Hallo Bertrand! > Why the lexical scoping of aUCBLogo behaves differently between > interactive mode and program mode ? Because it's a bug. I have not noticed it before, sorry. I really should extend the /checks/ to cover more primitives. > Here are examples: > > --- Direct mode (copy of my aUCBLogo console) > ; Welcome to aUCBLogo version 4.7 > > x = 1 > > be f > output x > end > > be g x > output f > end > > f > 1 ;-) > g 0 > 0 ;-) logically it should be 1 Yes. But I can explain why it is misbehaving, see below. :-) > --- Program mode > be f > output x > end > > be g x > output f > end > > to test_scope > x = 1 > print f > print g 0 > end > > 1 > 1 > ;-) results are correct The trouble is, in the parsing of the line "be g x", if there's already a global variable ::x, then it will be parsed as "be g ::x", however if there's no global x, it will be parsed as "be g g::x". It *should* be parsed as "be g g::x" in any case, so it's a bug. The bug is also in aUCBLogo-4.8-debug so far, but I will correct it in the next debug build of 4.8. I just had to add a few lines to Parse.cpp: + ObjectP olexufun=th->lexufun; + if (dynFlag) + th->lexufun=0; + else + th->lexufun=name->intern(); NodeP formals=parser_iterate(inln, inlimit, inhead, semi, _T('\n'), name, inparen, col, tcol, lineStart, lines); + th->lexufun=olexufun; But I still have to run the /checks/ to ensure it wont break something else. See also: <http://www.physik.uni-augsburg.de/~micheler/aUCBLogo-4.7_scope_bug.png> <http://www.physik.uni-augsburg.de/~m...cope_bug_corre cted.png> Thanks for the bug report! Andreas __._,_.___ LogoForum messages are archived at: http://groups.yahoo.com/group/LogoForum taobert@yahoo.nospam.fr wrote: > The message below is being cross-posted from the LogoForum. Please > reply here at comp.lang.logo and it will be cross-posted back to the > LogoForum. The original author of this message is > taobert@yahoo.nospam.fr. > > > > Hello Logo World, > > Just a question for Andreas (or for aUCBLogo users): > > Why the lexical scoping of aUCBLogo behaves differently between > interactive mode and program mode ? > > Here are examples: > > --- Direct mode (copy of my aUCBLogo console) > ; Welcome to aUCBLogo version 4.7 > > x = 1 > > be f > * output x > end > > be g x > * output f > end > > f > 1* ;-) > g 0 > 0* ;-)* logically it should be 1 > > --- Program mode > be f > *** output x > end > > be g x > *** output f > end > > to test_scope > *** x = 1 > *** print f > *** print g 0 > end > > 1 > 1 > ;-)* results are correct > > Regards, > Bertrand > > > __._,_.___ > LogoForum messages are archived at: > http://groups.yahoo.com/group/LogoForum |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.