help-octave
[Top][All Lists]
Advanced

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

Re: equivalent for C-style init: structname varname[] = {...} ?


From: Dimitri Maziuk
Subject: Re: equivalent for C-style init: structname varname[] = {...} ?
Date: Mon, 19 Nov 2012 12:35:16 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.10) Gecko/20121030 Thunderbird/10.0.10

On 11/19/2012 12:06 PM, Jordi Gutiérrez Hermoso wrote:

> Okay, that gives me enough information to diagnose the problem. It's
> unrelated to structs, as I guessed.
> 
> The problem is that (1) Octave arrays are of homogenous type (2)
> strings are arrays of char type. So when you're doing
> 
>     row = [1, 2, 3, 4];
>     r(2) = "lol",
> 
> you're attempting to assign an array of size 3 to a single location in
> row, the 2nd entry.

The way I see it I am trying to assign 4.410 to row(5) previously
initialized to -100.0.

I'm storing 4.410 in a struct next to "HE", a struct is actually a map,
and map values are indeed of homogenous type. Hence "4.410" interpreted
as ['4', '.', '4', '1', '0'].

If it's any consolation, it's a generally undecidable problem inherent
in all typeless languages: what should 'if( "42" == 42 )' evaluate to
and should 'if( "42" == (42) )' evaluate to the same thing. Octave's not
alone there (though it's the worst I've seen so far).

-- 
Dimitri Maziuk
Programmer/sysadmin
BioMagResBank, UW-Madison -- http://www.bmrb.wisc.edu

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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