Re: A question about certain language features
- Posted by Kat <gertie at PELL.NET> Feb 16, 2002
- 590 views
On 16 Feb 2002, at 16:52, rforno at tutopia.com wrote: > > Well, I think it is worse to encounter a variable containing an arbitrary > default value instead of one you forgot to assign. > In the second case, you´ll get an execution error just at the point. In the > first one, you probably will get a difficult to trace error many sentences > after. This would be fine, if the interpreter caught it at compile time, and not after a heavily edited file was open and about to be nuked because of the error. If the unassigned var was default s={} and i=0,, hmm, a=? 0? ' '? ''? Ok, i got it !, make the last include file scan the var list, and assign whatever you want to them! Oh wait, no var list,, well, drat. Hey Rob, giving a varlist function would bypass this pre-assignment request.. s = varlist() -- nested sequence ?s[1] -- first var declared {"junk",'a',12} procedure AssignDefaultVals() for each 'a' in s[2] do if equal(s[each][1],SpecialCaseValue) then s[each][3] = 1 else s[each][3] = MyAtomDefaultValue end if end for end procedure Or somesuch. Passing the ref would help here, so a new copy isn't made of a 200meg database of sequences. Better yet, make it a class? I dunno, it was a thought. Kat ----- Original Message ----- From: "David Cuny" <dcuny at LANSET.COM> To: > "EUforum" <EUforum at topica.com> Sent: Friday, February 15, 2002 5:32 AM > Subject: > Re: A question about certain language features > > > Robert wrote: > > > In situations where it really doesn't matter how > > something is written, I think there are advantages to > > reducing the number of choices. > > But in this case, it's not a matter of cosmetics. It actually *does* matter > how > (and where) something is written. By splitting the declaration from the > assignment: > > integer foo > ... > foo = 123 -- default value > > you increase the chances that the code will encounter an uninitialized > variable. And when that happens, the Euphoria interpreter stops, and > anything > the user was doing is permanantly lost. > > That's been my experience with Euphoria. > > Isn't the end goal to provide users with robust applications? > > -- David Cuny > > > >