[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Aliasing (?) built-in functions
From: |
Ted Harding |
Subject: |
Aliasing (?) built-in functions |
Date: |
Wed, 17 Jan 1996 09:32:08 +0000 (GMT) |
Hi Folks,
A report on a "feature" of octave which could set a trap for the unwary.
The following is artificial, to highlight the process.
Take an octave built-in function, such as "lgamma".
Write a function m-file, say "temp.m":
temp.m
------
function y = lgamma(x)
y=1;
endfunction
In octave, invoke it:--
octave:1> exp(temp(5))
warning: function name `lgamma' does not agree with function file name `temp.m'
error: can't redefine read-only function `temp'
error: `temp' undefined near line 1 column 5
error: evaluating index expression near line 1, column 5
error: evaluating argument list element number 0
error: evaluating index expression near line 1, column 1
octave:2>
So far so good. Now do it again:--
octave:4> exp(temp(5))
ans = 24.000
octave:5>
What seems to have happened is that "lgamma" has now been renamed "temp";
it seems "lgamma" can no longer be found:--
octave:5> exp(lgamma(5))
error: `lgamma' undefined near line 5 column 5
error: evaluating index expression near line 5, column 5
error: evaluating argument list element number 0
error: evaluating index expression near line 5, column 1
octave:6>
and this situation persists until you "quit" octave.
(For the curious: this was found when one of my student's wrote a program
called "lgamma" for matlab -- which doesn't have lgamma built in -- which
in fact computed the log-factorial, in a file which he finally renamed to
"lfact.m" without changing the contents of the file. When I ran his
program in octave the above was observed.)
Best wishes to all,
Ted. (address@hidden)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Aliasing (?) built-in functions,
Ted Harding <=