help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave inputParser


From: Carnë Draug
Subject: Re: Octave inputParser
Date: Thu, 19 Apr 2012 15:47:51 +0100

On 19 April 2012 13:44, Aki Vehtari <address@hidden> wrote:
> Hi,
>
> Our research group has made a Matlab toolbox GPstuff (GPL3 license), which
> is using inputParser. We are interested in testing whether we can make it
> work with Octave, too. I found your Octave implementation of inputParser and
> some email list discussion related to that. It's great that someone is
> working on this. If I understood correctly, the current implementation of
> classes in Octave does not allow same syntax as in Matlab? Do you have
> information about whether it is in the near future possible to have the same
> syntax in Octave as in Matlab? We have more than 100 files using
> inputParser, so we are willing to wait a little more instead of having two
> versions of the input parsing code.
>
> Best regards,
>
> Aki Vehtari

Hi Aki

if you're sending me an e-mail about octave, please always CC the
octave-forge or octave core mailing list. Someone there may also be
able to help you better or it gets registered for other people who may
come across the same problem.

The code you're asking for is in the general package release (1.3.0
released less than 1 month ago). Octave core hasn't implemented
classdef yet so we can't have exactly the same API than matlab but the
difference is minimal. Since we can't pass arguments by reference, in
octave you'll need to reassign the output of the function back to the
object, see the examples:

# octave API
obj = obj.method (args)

# matlab api
obj.method (args)

If you read the source of @inputParser/subsref.m there's an hack there
that is commented (lines 27-28). Basically the idea is to use
inputname and then assignin on the caller to change the object. This
would allow the octave API to be compatible (although using an ugly
hack). The reason I'm not using is this bug in core
https://savannah.gnu.org/bugs/?34478 . If you are by any chance able
to fix this bug, then we could have the same API.

If you wish your code to work on both systems, I see the following as
your options:

  1) fix octave-core bug #34478 so octave's inputParser can implement
the same API as matlab
  2) implement classdef in octave (so that an inputParser with same
API can be implemented in octave)
  3) use private functions in your package that check if using matlab
or octave (this should be really really easy. Using varargin, you can
pass the arguments very easily with just a couple of changes).
  4) since your code is also released under GPL you can add octave's
implementation of inputParser to your package so that even if it's
used in matlab, it will be using the octave code

I think option 3 is the one that will take you less work though I'd
obviously prefer you'd implement classdef.

Carnë


reply via email to

[Prev in Thread] Current Thread [Next in Thread]