RE: Uninitialized Variables

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

Sorry Bernie you misunderstood. This is a way AROUND that limitation. 
The best that I can think of.

 The circumstances are fairly limited to when it would be useful to know 
if a variable has been initialized yet. In those cases, I'm suggesting 
that you could just initialize it to -INF for atoms and integers, and 
INF for sequences and objects. Yes, there are cases where this wouldn't 
work, but they would be extremely rare.

Your program would then consider variables that contain -INF or INF are 
uninitialized.

I know it's not the optimal solution but it's better than none.

It would be next to optimal if NAN had a unique value. Then we could 
have a unique identifier for each uninitialized variable. I don't know 
the nature of NAN though, so I assume it's supposed to be equal to 
everything.


Chris


Bernie Ryan wrote:
> 
> Chris Bensler wrote:
> > I have thought of a way that we can determine if a variable is 
> > uninitialized or not. We can also set it back to being uninitialized.
> > 
> > constant INF = (1e300*1e300),
> > 
> > integer  i   i = -INF
> > atom     a   a = -INF
> > sequence s   s =  INF
> > object   o   o =  INF
> > 
> > I tried to use NAN as well, but everything is equal to NAN!?
> > NAN=1
> > NAN=-NAN
> > NAN=INF
> > NAN=-5039487
> > 
> > Is that proper behaviour?
> > 
> 
> Chris:
>    I don't think you understand what a uninitialized variable is.
>    When a compiler or interpreter allocates a storage location
>    to contain a variable. There is know way to know what that
>    memory location contains. The variable is therefore
>    called a unintialized variable. If the compiler or interpreter
>    assigns a known value at creation time, then the variable
>    is called a initialized variable. What you are doing above
>    is assigning a known value to a uninitialized variable.
> Bernie
> 
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu