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

Home » Public Forums » archive » When Ptr_New doesn't work
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
When Ptr_New doesn't work [message #28954] Tue, 22 January 2002 03:42 Go to next message
badenes is currently offline  badenes
Messages: 5
Registered: January 2002
Junior Member
I have the following problem:

rCoefficients=PtrArr(nElems)
FOR i=0, nElems-1 DO BEGIN
rCoefficients[i]=Ptr_New(PtrArr(elems[i]))
ENDFOR

since elems is a vector of integers, each element i of
rCoefficients is a pointer to an array of elems[i] pointers.
But, for some reason,

((*rCoefficients[j])[k]) = Ptr_New(FltArr(2), /NO_COPY)

doesn't work. k and j are within the allowed range, of course, and
((*rCoefficients[j])[k]) is a null pointer, as expected from the
initialization above. Ptr_New is supposed to allocate memory for the
specified pointer to store an array of 2 floats, but I get the message

Expression must be named variable in this context: <POINTER
(<NullPointer>)>.

I must be doing something wrong. Can you help?

Thanks,
Carles
Re: When Ptr_New doesn't work [message #29016 is a reply to message #28954] Wed, 23 January 2002 11:13 Go to previous message
John-David T. Smith is currently offline  John-David T. Smith
Messages: 384
Registered: January 2000
Senior Member
"Pavel A. Romashkin" wrote:
>
> I think the key here is, anything in parenthesis gets *evaluated* and as
> such is an expression. And it is not really surprising that one is not
> allowed to assign a value to an expression. This is the strength of IDL
> - it creates temporary variables as expressions, and allows to use them
> just like named variables. Unlike, say, IGOR Pro that requres you to
> define a named variable to even plot it.
>

Right. Another example of parentheses forming an expression is:

IDL> a=(b=1)

which is the only way to do chained assignments.

But as for the necessity of this, compare Perl, where things like:

($first, $second, @rest)=make_list();

are allowed. But heh, it's IDL.

JD
Re: When Ptr_New doesn't work [message #29017 is a reply to message #28954] Wed, 23 January 2002 10:07 Go to previous message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
I think the key here is, anything in parenthesis gets *evaluated* and as
such is an expression. And it is not really surprising that one is not
allowed to assign a value to an expression. This is the strength of IDL
- it creates temporary variables as expressions, and allows to use them
just like named variables. Unlike, say, IGOR Pro that requres you to
define a named variable to even plot it.

Pavel

Richard Younger wrote:
>
> This seems very strange to me. I think of parenthesis as not modifying
> their arguments at all, since they should (in my own little idl, er,
> ideal world) change only precedence and not value.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: When Ptr_New doesn't work
Next Topic: Re: Does anybody know an 'undocumented IDL feature' that does this

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

Current Time: Wed Oct 08 17:10:07 PDT 2025

Total time taken to generate the page: 0.00546 seconds