comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: _Ref_Extra : BUG? (in Win2K 55b) corrected test file

Re: _Ref_Extra : BUG? (in Win2K 55b) corrected test file
type: item
description: Martin Downing wrote: > Glad you didnt look too carefully, as the test file I sent was wrong > nyway - thought I had sent it *before* I started changing things, woops :( > I noticed though that the Keyword had been converted to a string on your > version. > > The correct file is now on my web site, sorry - clearly not enough coffee > http://homepage.ntlworld.com/martin.downing/idl/test_ref_ext ra_bug.pro > code below: > http://homepage.ntlworld.com/martin.downing/idl/test_ref_ext ra_bug2.pro > the below test though is *maybe* easier to follow > > Martin AH, yes, the new code quite nicely destroys IDL 5.5 running on Linux RedHat 7. It seems to run just fine (i.e. does not crash) on IDL 5.4 on Win2000 however. Interesting.. -bob
creator: Robert Stockwell
date: 2001-11-01T13:29:23-00:00

Re: _Ref_Extra : BUG? (in Win2K 55b) corrected test file
type: item
description: Glad you didnt look too carefully, as the test file I sent was wrong nyway - thought I had sent it *before* I started changing things, woops :( I noticed though that the Keyword had been converted to a string on your version. The correct file is now on my web site, sorry - clearly not enough coffee http://homepage.ntlworld.com/martin.downing/idl/test_ref_ext ra_bug.pro code below: http://homepage.ntlworld.com/martin.downing/idl/test_ref_ext ra_bug2.pro the below test though is *maybe* easier to follow Martin ;===================================================== ; demonstrates _REF_EXTRA 's keyword argument passing anomalies ; main test procedure pro test_ref_extra_bug2, debug=debug ; set debug to give help output of passes extra parameters test_extra0, /key, debug=debug test_ref_extra2, /key, debug=debug ; THIS ONE MAY CRASH YOUR IDL SESSION test_ref_extra1, /key, debug=debug end pro test_extra0, debug=debug,_EXTRA=e print, "TEST_EXTRA0" if keyword_set(debug) then help,e,/st test_ref_extra1, debug=debug,_REF_EXTRA=e end pro test_ref_extra1, debug=debug,_REF_EXTRA=e print, "TEST_REF_EXTRA1" if keyword_set(debug) then help,e,/str; & if defined(e) then print, e test_ref_extra2,debug=debug, _REF_EXTRA=e end pro test_ref_extra2, debug=debug,_REF_EXTRA=e print, "TEST_REF_EXTRA2" if keyword_set(debug) then help,e,/st ;& if defined(e) then print, e test_extra1, _EXTRA=e end ; the final call pro test_extra1,key1=key1, debug=debug,_EXTRA=e print, "TEST_EXTRA1" if keyword_set(debug) then help,e,/st if keyword_set(KEY1) then print, "KEY1 set - good!" else Print, "KEY1 unset" end =============================== Martin > > I haven't looked closely at this, but here are my results > on linux idl v5.5: > > IDL> test_ref_extra_bug > { x86 linux unix linux 5.5 Aug 28 2001 32 32} > ;calling: test_extra, 3, /Key1 > TEST_EXTRA > ** Structure <827ebdc>, 1 tags, length=2, data length=2, refs=1: > KEY1 INT 1 > { 1} > ;calling: test_ref_extra, 2, /Key1 > pro test_ref_ex,call, _REF_EXTRA=e …
creator: Martin Downing
date: 2001-11-01T17:00:26-00:00

Re: _Ref_Extra : BUG? (in Win2K 55b) corrected test file
type: item
description: Martin Downing wrote: > > Glad you didnt look too carefully, as the test file I sent was wrong > nyway - thought I had sent it *before* I started changing things, woops :( > I noticed though that the Keyword had been converted to a string on your > version. > > The correct file is now on my web site, sorry - clearly not enough coffee > http://homepage.ntlworld.com/martin.downing/idl/test_ref_ext ra_bug.pro > code below: > http://homepage.ntlworld.com/martin.downing/idl/test_ref_ext ra_bug2.pro > the below test though is *maybe* easier to follow > It seems to me the point is being driven home that switching from _REF_EXTRA to _EXTRA in the middle of the game is verboten: a _REF_EXTRA stack should remain a _REF_EXTRA stack. Not sure I agree with the method of their point-making. Can you distill the problem to a simpler (and preferrably non-pair-recursive) example? JD P.S. If you only use "_EXTRA" in your routine calls (as opposed to routine *definitions*), this bug vanishes. I have always recommended saving "_REF_EXTRA" only for the relevant function definitions which would like to return values through their inherited keywords, and using the simpler "_EXTRA" everywhere else.
creator: John-David T. Smith
date: 2001-11-01T20:23:17-00:00

Re: _Ref_Extra : BUG? (in Win2K 55b) corrected test file
type: item
description: Well, I must confess that I haven't taken the time to work out what you guys are on about, because these keyword-inheritance things always confuse the hell out of me. But I think I can add something to the discussion by noting that there *has* been a change (presumably intended) in the way _REF_EXTRA works between 5.4 and 5.5. In 5.4, the rules for precedence of keywords passed by reference were different from the rules for keywords passed by value; in 5.5 they are the same. There was a thread on this subject entitled "Keyword precedence" in August 2000, in which JD & I confused the hell out of everyone else & each other (well me, anyway). I also communicated with RSI Tech Support at about that time and tried to convince them to change the behaviour. They seem to have done so. So, your bug may be my fault. --- Mark Hadfield m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research -- Posted from clam.niwa.cri.nz [202.36.29.1] via Mailgate.ORG Server - http://www.Mailgate.ORG
creator: Mark Hadfield
date: 2001-11-01T20:28:40-00:00

Re: _Ref_Extra : BUG? (in Win2K 55b) corrected test file
type: item
description: "JD Smith" <jdsmith@astro.cornell.edu> wrote in message news:3BE1AF35.26BD8C3C@astro.cornell.edu... > Martin Downing wrote: >> >> Glad you didnt look too carefully, as the test file I sent was wrong >> nyway - thought I had sent it *before* I started changing things, woops :( >> I noticed though that the Keyword had been converted to a string on your >> version. >> >> The correct file is now on my web site, sorry - clearly not enough coffee >> http://homepage.ntlworld.com/martin.downing/idl/test_ref_ext ra_bug.pro >> code below: >> http://homepage.ntlworld.com/martin.downing/idl/test_ref_ext ra_bug2.pro >> the below test though is *maybe* easier to follow >> > > It seems to me the point is being driven home that switching from > _REF_EXTRA to _EXTRA in the middle of the game is verboten: a _REF_EXTRA > stack should remain a _REF_EXTRA stack. Not sure I agree with the > method of their point-making. > > Can you distill the problem to a simpler (and preferrably > non-pair-recursive) example? Hi JD, The second example was not recursive, but I agree its confusing! Anyway I take the point to avoid switching from _ref_exta tp _extra > > JD > > P.S. If you only use "_EXTRA" in your routine calls (as opposed to > routine *definitions*), this bug vanishes. I have always recommended > saving "_REF_EXTRA" only for the relevant function definitions which > would like to return values through their inherited keywords, and using > the simpler "_EXTRA" everywhere else. You are right again, this also cures the problem - I did not realise this was a safe thing to do if it was defined as a _ref_extra routine. Thanks Martin ps: The code is free to anyone who enjoys zapping PC-based IDL. Id be interested to know if unix/mac is any more stable!
creator: Martin Downing
date: 2001-11-01T23:30:29-00:00

Re: _Ref_Extra : BUG? (in Win2K 55b) corrected test file
type: item
description: From: "Martin Downing" <martin.downing@ntlworld.com> > http://homepage.ntlworld.com/martin.downing/idl/test_ref_ext ra_bug2.pro So the routine that's crashing your machine (and mine) is as follows (shortened)... pro test_ref_extra1,_REF_EXTRA=e test_ref_extra2, _REF_EXTRA=e ; Here be dragons! end This isn't merely bad practice, it's wrong. The _REF_EXTRA keyword is only used in routine definitions. When *calling* a routine, the acceptable forms are "_EXTRA" and (as of 5.5) "_STRICT_EXTRA". Still, it shouldn't crash IDL. It should be detected as a syntax error. --- Mark Hadfield m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research -- Posted from clam.niwa.cri.nz [202.36.29.1] via Mailgate.ORG Server - http://www.Mailgate.ORG
creator: Mark Hadfield
date: 2001-11-02T00:18:15-00:00

Re: _Ref_Extra : BUG? (in Win2K 55b) corrected test file
type: item
description: ----- Original Message ----- From: "Mark Hadfield" <m.hadfield@niwa.cri.nz> > > So the routine that's crashing your machine (and mine) is as follows > (shortened)... > > pro test_ref_extra1,_REF_EXTRA=e > test_ref_extra2, _REF_EXTRA=e ; Here be dragons! > end > > This isn't merely bad practice, it's wrong. The _REF_EXTRA keyword is only > used in routine definitions. When *calling* a routine, the acceptable forms > are "_EXTRA" and (as of 5.5) "_STRICT_EXTRA". > > Still, it shouldn't crash IDL. It should be detected as a syntax error. > Hi Mark It seemed logical to me that if arguments have to be passed through many preprocessing routines to a later routine, that the best way would be by reference to avoid copying (as would be the case if the Keyword was specified), if the final routine insists on a local copy (by value) why should that matter? Well I guess I just didnt understand the manual (no change there!). Are you saying that this is determined purely by the definition, and that calling with _REF_EXTRA as below > test_ref_extra2, _REF_EXTRA=e ; Here be dragons! (indeed) is supposed to be a syntax error? That was just not clear to me from the help (and for that matter the programmer who wrote the syntax parser!!!) I am concerned as to which causes passing by reference/value, the definition or the call? This is almost as horrible as C++ inheritance simple in principle but boy can some strange things happen when things get complicated - for now I guess will have to stick to _extra which at least is easy to understand :( roll on coffee time! cheers Martin Help on Keyword Inheritance from 5.4 follows: "Choosing a Keyword Inheritance Mechanism The "pass by reference" (_REF_EXTRA) keyword inheritance mechanism was introduced in IDL version 5.1, and in many cases is a good choice even if values are not being passed back to the calling routine. Because the _REF_EXTRA mechanism does not create an IDL structure to hold the keyword/value pairs, overhead is slightly reduced…
creator: Martin Downing
date: 2001-11-02T09:59:58-00:00

Re: _Ref_Extra : BUG? (in Win2K 55b) corrected test file
type: item
description: Martin Downing wrote: > > ----- Original Message ----- > From: "Mark Hadfield" <m.hadfield@niwa.cri.nz> >> >> So the routine that's crashing your machine (and mine) is as follows >> (shortened)... >> >> pro test_ref_extra1,_REF_EXTRA=e >> test_ref_extra2, _REF_EXTRA=e ; Here be dragons! >> end >> >> This isn't merely bad practice, it's wrong. The _REF_EXTRA keyword is only >> used in routine definitions. When *calling* a routine, the acceptable > forms >> are "_EXTRA" and (as of 5.5) "_STRICT_EXTRA". >> >> Still, it shouldn't crash IDL. It should be detected as a syntax error. >> > Hi Mark > > It seemed logical to me that if arguments have to be passed through many > preprocessing routines to a later routine, that the best way would be by > reference to avoid copying (as would be the case if the Keyword was > specified), if the final routine insists on a local copy (by value) why > should that matter? > Well I guess I just didnt understand the manual (no change there!). Are you > saying that this is determined purely by the definition, and that calling > with _REF_EXTRA as below >> test_ref_extra2, _REF_EXTRA=e ; Here be dragons! (indeed) > is supposed to be a syntax error? That was just not clear to me from the > help (and for that matter the programmer who wrote the syntax parser!!!) > I am concerned as to which causes passing by reference/value, the definition > or the call? > This is almost as horrible as C++ inheritance simple in principle but boy > can some strange things happen when things get complicated - for now I guess > will have to stick to _extra which at least is easy to understand :( > > roll on coffee time! As someone unaturally familiar with the intimate details of _REF_EXTRA (having raised the complaint which led to its creation), let me give a bit of background in defense of this (admittedly confusing) behavior. I initially envisioned changing the _EXTRA mechanism to support natively the default passing behavior of arguments (normal or keyword), …
creator: John-David T. Smith
date: 2001-11-02T20:06:55-00:00

Re: _Ref_Extra : BUG? (in Win2K 55b) corrected test file
type: item
description: From: "Martin Downing" <martin.downing@ntlworld.com> > ...the best way would be byreference to avoid copying. ...Are > you saying that this is determined purely by the definition, > and that calling with _REF_EXTRA as below >> test_ref_extra2, _REF_EXTRA=e ; Here be dragons! (indeed) > is supposed to be a syntax error? Yes, that's exactly what I'm saying. Although it is actually legal (though uncommon) to have regular keywords beginning with underscores. So I guess strictly speaking it is legal to have a regular keyword called "_REF_EXTRA". Not a good idea though! > I am concerned as to which causes passing by reference/value, the > definition or the call? The definition! --- Mark Hadfield m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield National Institute for Water and Atmospheric Research -- Posted from clam.niwa.cri.nz [202.36.29.1] via Mailgate.ORG Server - http://www.Mailgate.ORG
creator: Mark Hadfield
date: 2001-11-04T20:54:29-00:00