octave-maintainers
[Top][All Lists]
Advanced

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

Re: mapper functions vs. cell arrays


From: John W. Eaton
Subject: Re: mapper functions vs. cell arrays
Date: Tue, 5 Sep 2006 16:46:29 -0400

On  3-Sep-2006, David Bateman wrote:

| David Bateman wrote:
| 
| > Ok, then what about something like the attached patch. The only thing I
| > don't like about this is the use of feval. This shouldn't be needed as
| > we can assume that all elements are 1x1. However, we need to treat
| > arbitrary array return types and so its not evident how exact to replace it.
| > 
| > Note I also had to export the Vlast_error_message and Vlast_error_id
| > from error.cc, to allow the erorr handler to be implemented correctly.
| > It appears to be matlab compatible with the tests I added.
| 
| Ok, I think I prefer the attached version instead that removes the
| feval. Unfortunately I have to do everything with subsasgn on the
| octave_value to allow arbitrary types to be treated. I can't even be
| sure that the function will return the same type for the same arguments.
| God this is a horrible choice on the part of mathworks to allow
| "UniformOutput" to be true !!!
| 
| This version of the patch also removes the special case for the
| UniformOutput outside the inner loop and so the UniformOutput false case
| should be as faster as it always was.

Sorry for the delay.  Here are some comments.

  * I think it would be (slightly) better to use

      feval (fcn_ptr, args, nargout);

    instead of

      fcn_ptr->do_multi_index_op (nargout, args);


  * Instead of setting the value of buffer_error_message, I think you
    should increment/decrement it and any changes to its value should
    be protected inside an unwind_protect block.as in
    src/pt-except.cc.

  * Instead of exposing Vlast_error_message and Vlast_error_id, I
    think I would prefer to use the lasterr function.  I don't see a
    problem in calling it with feval.

  * Is this

| !                       std::string fname = "function y = ";
| !                       fname.append (fcn_name);
| !                       fname.append ("(x) y = ");
| !                       ErrorHandler = extract_function (args(i), "cellfun", 
| !                                                        err_name, fname,
| !                                                        "; endfunction");

    really the right thing here?  Is

      function y = FCN (x) y = BODY; endfunction

    the right form always?  If not, then maybe we should do something
    else here to extract the function from the argument.  Or, do we
    even need to handle the case of the error handler being a
    character string?  Can we just require that it is a function
    handle?

jwe


reply via email to

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