From help-octave-request at bevo dot che dot wisc dot edu Wed Jan 21 14:40:50 2004 Subject: Re: matlab nargin() function alternative in octave? From: taltman at lbl dot gov To: Sharene Deanne Bungay cc: help-octave at bevo dot che dot wisc dot edu Date: Wed, 21 Jan 2004 20:30:09 +0000 (UTC) On Jan 21, 2004 at 12:05am, Sharene Deanne Bungay wrote: sbunga >Hi Tomer, sbunga >Excellent point, and a very clean solution....if I had control sbunga >of the functional definitions so that I could call myfunc selectively Wait, you don't have control over the Matlab M-files? Are they read-only? You can always copy them... sbunga >as myfunc1 and myfunc2. Unfortunately, my situation involves sbunga >a bunch of matlab code, where the existing third-party code is what sbunga >defines myfunc to be any one of several very different functions, sbunga >depending on what "module" is selected by the user. The rest of the code Well, I guess the user has to select the module sometime, so why not use that in a message-passing function? sbunga >then uses whatever function is defined in whichever one of these sbunga >modules, under a single name "myfunc". Thus, most of the code has sbunga >no idea a priori what "myfunc" actually looks like, but it knows sbunga >what to do given the number of arguments that myfunc() takes. If this entire module is in your path, and the multiple copies (lets say around 25) of "myfunc" are in that module, then how does your program differentiate between them? Though this is not your fault, this sounds like extremely bad coding practice (i.e. meaningless function names ). If the appropriate version of "myfunc" is automagically selected based on the user module selection, then you have an a priori mapping between a 'message' (the chosen module), and the function inputs. No fancy-smancy specialty function necessary. --- Okay, I've read your post a second time, and I think that I understand it more. But can you clarify the following? 1. You're writing a module/library, which will call the Matlab modules/libraries, and will be used by a third-party? 2. You're writing a script yourself which calls the Matlab libraries/modules? If I've misunderstood what you've written, please correct me. Thanks, ~Tomer ------------------------------------------------------------- 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 -------------------------------------------------------------