Re: object(x) rethink

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

Shawn Pringle wrote:
> 
> There is absolutely no need to change the behavior of object().
> And for having a routine that does what is being proposed 
> dummy data can do that same thing.
> 
> CChris wrote:
> > 
> > The practice of using special values to mark routine error status, not
> > properly
> > initialised yet variables and other equivalent situations is a source of
> > countless
> > bugs, because a value is hardly ever special enough. 
> > 
> 
> LOL.  "Not special enough"?  You should be able to assign it to something 
> legal that will work as a starting case anyway.  If I got an uninitialized
> variable in my code I hope the compiler or interpreter will tell me
> before test execution.  I don't want to test for that while its executing.
> 
> 
> Shawn

You really don't?
There are tasks to be performed by a routine only the first time it is called;
frequently, it involves setting some variables, possibly asking something to user
or OS. When doing so would be a problem, either bothering the user, making costly
checks or otherwise, it would be simpler to test for an unassigned value and make
a decision on that base.
Currently, one has to initialise a dedicated flag and test whether it is set,
and if not set then set it and perform whatever. That's one extra unneeded
variable, and an extra cause of bugs when upgrading the code because it might be
set in different places, and there might be a number of flags. You may say it
hardly matters in a "hello world" sized program; I'll grant you that. Now back to
talking about useful programs.

So yes, I wish I could test for assignment at run time without a run time error.
Note that regularly reading an uninitialised var should keep crashing somehow.
Perhaps hadn't you got this specific point.

CChris

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

Search



Quick Links

User menu

Not signed in.

Misc Menu