help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: foo_cs = foo{:} - feature or bug ? (octave-3.4.2); also, sizeof(foo{


From: Ben Abbott
Subject: Re: foo_cs = foo{:} - feature or bug ? (octave-3.4.2); also, sizeof(foo{:})
Date: Mon, 08 Aug 2011 14:12:54 -0400

On Aug 8, 2011, at 1:32 PM, Sergei Steshenko wrote:

> And I am trying to tell the following:
> 
> in
> 
> "
> octave:4> foo_cs = foo{:}
> foo_cs = a
> "
> 
> one can see, that that "not object" is somehow converted into 'foo_cs',
> using whatever implicit rules.
> 

>> foo = {"a","b";[1 2],[]};
>> c = foo{:}
c = a

This is very similar to typing ..

>> c = "a", "b", [1 2], []
c = a
ans = b
ans =

   1   2

ans = [](0x0)

The result is that what you called foo_cs and I called c is a char object set 
equal to "a".

What I can't explain is why "c=foo{:}" isn't followed by the three "ans = ..."

> Likewise, in
> 
> "
> octave:6> sizeof(1 + 2)
> ans =  8
> "
> 
> the "1 + 2", which is an _expression_, is first converted (apparently) into
> a _single_ double value, and the size of that double value is (apparently)
> displayed.
> 
> So, the inconsistency, as I see it, is:
> 
> arithmetic expressions are _by_ _default_ converted into a _single_
> memory location holding their value, and that memory location size in
> bytes is dispalyed;
> 
> _opposed_ _to_ _that_
> 
> comma separated list is _not_ converted when 'sizeof' is called, but
> some _deafault_ conversion is called in case of
> 
> "
> octave:4> foo_cs = foo{:}
> foo_cs = a
> ".
> 
> I.e. why for arithmetic expressions in case of "sizeof(1 + 2)" I see
> something like:
> 
> invisible_result = 1 + 2; sizeof(invisible_result)
> 
> , but for comma-separated list in case of "sizeof(foo{:})" I do _not_ see
> 
> invisible_result = foo{:}; sizeof(invisible_result)

The command sizeof(foo{:}) is equivalent to ...

        sizeof ("a", [1, 2], "b", [])

Which produces an error.

>> sizeof(foo{:})
error: Invalid call to sizeof.  Correct usage is:

 -- Built-in Function:  sizeof (VAL)

>> sizeof("a", [1 2], "b", [])
error: Invalid call to sizeof.  Correct usage is:

 -- Built-in Function:  sizeof (VAL)

Ben







reply via email to

[Prev in Thread] Current Thread [Next in Thread]