Re: object(x) rethink
Robert Craig wrote:
> All types in Euphoria, whether they are
> built-in, like integer(), or user_defined,
> can be used to either declare a variable,
> or test if a value belongs to that type.
> e.g.
> }}}
<eucode>
> atom a
> sequence s
> my_special_type month
>
> if atom(9.9) then ...
> if sequence(x) then ...
> if my_special_type(11) then ...
> </eucode>
{{{
>
> So, just for completeness, if you can
> declare something as:
> object y
> it seems reasonable that you should
> be able to say:
> if object(z) then ...
> even if that is rather pointless.
Ok, thanks Rob, now I can more precisely express
my additional thoughts about this subject.
Really, sequence(s), atom(a) and integer(i) types
test not only if a *value* belongs to that type, but
also automatically test if a *variable* was declared
with that type.
We can say:
if sequence(s) then -- tests the type of a variable
-- on declaration (via value, maybe)
and
if sequence(s[i]) then -- tests the value of an element (object)
Same about atom() and integer().
But the object() type doesn't test for *declaration*,
and "tests", so to say, just for *value*, which
(any one) is an object on definition -- all data in
Euphoria are objects, and there is *nothing* to test
at all.
So the obiect() type only lacks (in comparison with
sequence(), atom() and integer() ones) the ability to
test for *declaration* as any *value* is an object
without any testing, just on convention.
Just my $.02, I can live with it as it is and am
ready to leave it alone, but it may be some subject
for some confusion anyway, I think.
[snip]
Regards,
Igor Kachan
kinz at peterlink.ru
|
Not Categorized, Please Help
|
|