Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nargout for class methods #50

Open
tsdev opened this issue Aug 15, 2017 · 1 comment
Open

Nargout for class methods #50

tsdev opened this issue Aug 15, 2017 · 1 comment

Comments

@tsdev
Copy link

tsdev commented Aug 15, 2017

08478bb: This fails when a class method name is identical to a function on the MATLAB search path. For example calling the method myclass.plot(), nargout will return the number of arguments of the MATLAB built-in plot function. That's why I added a bit more checking:

try
    [~, funType] = which(msg('name'));
    funType = strsplit(funType,' ');
    if numel(funType)==2 && strcmp(funType{2},'method')
        argTemp = msg('args');
        className = funType{1};
        if ~isempty(argTemp) && isa(argTemp{1},className)
            % the function name corresponds to the
            % class of the first argument
            resultsize = nargout(msg('name'));
        end
    end

    if isempty(resultsize)
        resultsize = nargout(fun);
    end
catch
    resultsize = -1;
end
@bastibe
Copy link
Owner

bastibe commented Aug 17, 2017

Right now, I don't have enough time to look into this. I'd be grateful for a pull request. Otherwise, I'll have a look in two weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants