Re: Are functional objects (functors/closures) possible?
In a message to the help-octave mailing list on 22-Nov-2002,
Paul Kienzle <[hidden email]> wrote:
| This is a little cleaner if curry were a text function:
| f = curry x y "g(x,y,$a,$b)"
| but right now you cannot tag a function as a text function
| unless it is a built-in.
How about the following patch, relative to the current CVS? With it,
Octave behaves like this:
octave:1> mark_as_text_function doit
octave:2> function doit (a, b, c) printf ("%s:%s:%s\n", a, b, c); end
octave:3> doit foo bar baz
octave:4> unmark_text_function doit
octave:5> doit foo bar baz
>>> doit foo bar baz
octave:5> doit ("foo", "bar", "baz")
octave:6> mark_as_text_function doit
octave:7> doit ("foo", "bar", "baz")
So you could set up a collection of text functions either in a script
file or just by marking them in your ~/.octaverc file. I think this
is all that is required, but perhaps I'm missing something? If you
already submitted a patch like this and I'm reinventing something,
then I apologize for that. I didn't try to locate it because it
seemed simple enough to implement.
Note that these changes require the STL std::set<std::string>
template, which works best with g++ 3.2, at least for me (see my
* variables.cc (text_function_set): New static data.
Funmark_text_function): New functions.
(is_text_function_name): Handle functions marked as text functions
in special list, not just those marked in the symbol record.
* symtab.h (symbol_record::mark_as_text_function,
symbol_record::symbol_def::unmark_text_function): New functions.