Re: Rob: Eu 2.6 (maye 2.5?), object(), and un-initialized variables

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

Derek Parnell wrote:

> Greg Haberek wrote:
>>
>> Under the description of object, The Euphoria 2.4 Reference Manual states:
>>
>> "object() is included just for completeness. It always returns 1. "
>>
>> I believe we can use this to our advantage. Couldn't object() return 0
>> for an un-initialized variable? People have complained about this
>> before, since we don't know when variables are un-initialized.
>> Technically, an un-initialized variable is not an object, since it
>> holds no data, and is only a name. So *technically* this would work:
>>
>> }}}
<eucode>
>> atom euver
>>
>>     if not object(euver) then
>>         euver = 2.5
>>     end if
>> </eucode>
{{{

>>
>> I really don't see how it would be hard to implement, since Euphoria
>> is 70% Euphoria now anyways.
>>
>> Just my $0.02,
>
> This idea is worth a lot more than two cents. It's a great idea.

I like it, too. However, I would prefer a built-in NIL value. That is
more versatile, because it cannot only be used for comparison ...

atom euver

if euver = NIL then
   euver = 2.5
end if


... but also for assignment (e.g. as a universal value for indicating an
error):

function foo (atom bar)
   if bar >= 0 then
      ...
   else
      return NIL
   end if
end function


Regards,
   Juergen

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

Search



Quick Links

User menu

Not signed in.

Misc Menu