From: Josep i T. <jm...@pu...> - 2004-08-24 23:40:47
|
Hi Paul! Your answer is full of good advice... This should remind me to ask questions more often... On dt, 2004-08-24 at 23:32, pki...@co... wrote: > It doesn't matter what field you use. Off hand I would suggest=20 > overriding Octave's 'class' function so that if it is given a struct=20 > as the first argument, it checks for a secret field name=20 > (e.g., __class) and prints that, or prints 'struct' if no secret > field exists. If given two arguments, then set s.__class to > the second argument, which should be the class name. That > will make the interface similar, even if the underlying > implementation does not yet support automatic dispatching > into the @class directory. You could implement that too > if you were so inclined using find_in_loadpath([class,'.m']) to > find the directory, then creating a dispatch off struct for every > m-file and oct-file in that directory. Thinking about "making an interface as similar as possible", What I don't want to do is to waste time making a "struct" interface similar, time that perhaps would be invested in just implementing classes in Octave. But it seems easy enough to be worth trying... although it would be great classes are implemented in Octave. >=20 > Octave supports structure arrays, at laeast in recent versions. > What syntax are you using to index and assign them? >=20 mmm... I was using the wrong syntax... I've found out the correct way to do it. Whis is what i was doing (lines 4 to 6)... I still have a lot to learn about Octave octave:1> s1.field=3D'value'; octave:2> s2.field=3D'value'; octave:3> a(1)=3Ds1 a =3D { field =3D value } octave:4> b=3D[s1,s2] error: octave_base_value::array_value(): wrong type argument `struct' error: evaluating assignment expression near line 4, column 2 octave:4> b=3D[] b =3D [](0x0) octave:5> b(1)=3Ds1 error: operator =3D: no conversion for assignment of `struct' to indexed `matrix' error: assignment failed, or no method for `matrix =3D struct' error: evaluating assignment expression near line 5, column 5 > - Paul >=20 Thanks for the info --=20 Josep Mon=E9s i Teixidor Clau GnuPG: gpg --recv-keys 80E85CC4 |