help-octave
[Top][All Lists]
Advanced

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

Using DEFUN_TEXT instead of DEFUN_DLD


From: John W. Eaton
Subject: Using DEFUN_TEXT instead of DEFUN_DLD
Date: Mon, 10 Mar 1997 03:22:40 -0600

On  9-Mar-1997, Craig Earls <address@hidden> wrote:

| Is it possible to write dynamically loadable funcitons using DEFUN_TEXT
| vice DEFUN_DLD? I would like to add a few file handilg functions whose
| syntax should be similar to help or which.  I am not sure if the errors
| I am seeing 
| 
| parse error:
| 
| >>>myfunc anotherfunc
|                     ^
| 
| are due to a problem in my code or that octave cannot dynamically load
| functions like this.

You can't do this with a dynamically linked function.

To handle `commands' or `text-style functions' (a really bad name,
sorry), Octave's parser has to know that they are commands.  If the
function hasn't been loaded yet, it doesn't know that, so it can't
decide to parse

  myfunc -opt

as a function taking an option (two tokens: ID WORD) so it parses it
as a binary expression (three tokens: ID MINUS ID).

Yes, I know that Matlab 4.2 allows you to define `commands' in
M-files, but it also knows that all functions are defined in M-files
so it can look up an identifier and find out if it is a function
(causes some trouble for eval though) and it apparently uses some
weird rules (undocumented, as far as I can tell) for deciding when to
call a function with all the arguments as strings.  For example, both
`cputime -t' and `cputime - t' fail, but `cputime-t' works.

If someone can come up with a consistent and useful set of rules for
deciding when to parse the above statement as ID WORD instead of ID
MINUS ID, without having to load the function first (or even know that
the first ID is a function -- this is the hard part, I think), and
without having to completely err on the side of commands, then I'll
implement this capability in Octave.

Good luck!

jwe


reply via email to

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