comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Does this make sense? (scalar objects)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Does this make sense? (scalar objects) [message #37264 is a reply to message #37183] Wed, 03 December 2003 14:25 Go to previous messageGo to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Wed, 03 Dec 2003 07:33:20 -0700, Marc Schellens wrote:

> check this out:
>
> file tt.pro:
> pro o::test
>
> help,self[[0]]
> help,(self[[0]])
>
> print,self[[0]].a
> print,(self[[0]]).a ;; ???
> end
>
> pro tt
>
> s={o,a:0}
>
> print,s[[0]].a
> print,(s[[0]]).a
>
> obj=obj_new('o')
>
> obj->test
> end
>
>
> IDL> tt
> % Compiled module: TT.
> 0
> 0
> <Expression> OBJREF = Array[1]
> <Expression> OBJREF = Array[1]
> 0
> % Object reference must be scalar in this context: <OBJREF Array[1]>
> % Execution halted at: O::TEST 7 /home/marc/idl/tt.pro %
> TT 19 /home/marc/idl/tt.pro %
> $MAIN$
>
>
> Doesn't make sense, does it?

Well, given that self is always a scalar, your attempts to index it are
confusing. In any case, the notation a[[b]] creates a single element
vector:

IDL> a=1
IDL> print,size(a[[0]],/DIMENSIONS)
1

You cannot do anything to more than one object at a time (e.g. no objarr
method calls or instance variable dereference). Hence the error. The
reason why self[[0]].a works, is that there is probably special code to
handle instance variable derefence for a single element vector, which
does not or cannot operate with (self[[0]]).a. Method calls don't like
a vector no matter what: try

obj[[0]]->test

Confusing issues like this have lead at least one RSI programmer to long
for the abolishment of the scalar as a separate type from a single
element vector. Sadly, the chance to do this without breaking lots of
code has long passed.

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Error when running ICONTOUR
Next Topic: Re: ActiveContours

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:36:36 PDT 2025

Total time taken to generate the page: 0.00363 seconds