From bug-request at octave dot org Thu Jun 16 15:16:38 2005 Subject: Re: Precedence of compiled functions From: "John W. Eaton" To: Keith Goodman Cc: bug at octave dot org Date: Thu, 16 Jun 2005 16:13:12 -0400 On 16-Jun-2005, John W. Eaton wrote: | On 16-Jun-2005, Keith Goodman wrote: | | | And here's my original problem: | | | | >> clear all | | >> LOADPATH = ["~/tmp/d2:"]; | | >> f | | this is d2/f, x = 1 | | >> f | | this is d2/f, x = 2 | | >> LOADPATH = ["~/tmpd1:~/tmp/d2:"]; | | >> f | | this is d2/f, x = 3 ## My problem only occurs when both d1 and d2 are in path | | Odd, I can't seem to duplicate this problem. Here is what I see, both | with 2.1.69 and the current CVS sources: | | >> clear all | >> LOADPATH = "~/d2:" | LOADPATH = ~/d2: | >> f | this is d2/f, x = 1 | >> f | this is d2/f, x = 2 | >> LOADPATH = "~/d1:~/d2:" | LOADPATH = ~/d1:~/d2: | >> f | this is d1/f | >> LOADPATH = "~/d2:~/d1:" | LOADPATH = ~/d2:~/d1: | >> f | this is d2/f, x = 1 | | So for me it appears that looking up functions according to the | current LOADPATH is working correctly. | | Did you mean to type ~/tmp/d1 instead of ~/tmpd1 above? Or, did you run this test (or the code that prompted the original bug report) in a script or function file? If so, then I think the following patch should help. It won't solve the persistent variable problem, but it should make Octave find the right function after changes to LOADPATH. jwe src/ChangeLog: 2005-06-16 John W. Eaton * defaults.cc (loadpath): Don't do anything if value is unchanged. If loadpath changes, also update Vlast_prompt_time. Index: src/defaults.cc =================================================================== RCS file: /cvs/octave/src/defaults.cc,v retrieving revision 1.48 diff -u -r1.48 defaults.cc --- src/defaults.cc 2 May 2005 18:15:21 -0000 1.48 +++ src/defaults.cc 16 Jun 2005 20:12:47 -0000 at @ -48,6 +48,7 @@ #include "file-ops.h" #include "gripes.h" #include "help.h" +#include "input.h" #include "oct-obj.h" #include "ov.h" #include "parse.h" at @ -572,7 +573,7 @@ gripe_invalid_value_specified ("LOADPATH"); status = -1; } - else + else if (Vload_path != s) { // I'm not sure whether this causes more problems that it // solves... at @ -582,6 +583,16 @@ Vload_path = s; + // By resetting the last prompt time variable, we will force + // checks for out of date symbols even if the change to LOADPATH + // and subsequent function calls happen between prompts. + + // XXX FIXME XXX -- maybe we should rename + // Vlast_prompt_time_stamp since the new usage doesn't really + // fit with the current name? + + Vlast_prompt_time.stamp (); + update_load_path_dir_path (); } ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------