octave-maintainers
[Top][All Lists]
Advanced

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

Re: Crash with inline


From: David Bateman
Subject: Re: Crash with inline
Date: Thu, 16 Sep 2004 16:54:52 +0200
User-agent: Mutt/1.4.1i

> Also, I'm wondering about the difference between inline functions and user
> defined functions defined on the command line with the function keyword.

An inline function deosn't appear in the fbi_sym_tab. Apart from that 
not much different. A function handle however has a subtle difference,
for example

octave:1> fcn = @not
octave:2> function y = not (x), y = x; endfunction
octave:3> fcn(1), not(1)
ans = 0
ans = 1

This happens due to the fact that the function handle saves the 
octave_function in the original symbol table before it was replaced..
However, this is not true for inline functions, for example

octave:1> fcn = inline('not(x)')
fcn =

f(x) = not(x)

octave:2> not = inline('x')
not =

f(x) = x

octave:3> fcn(1), not(1)
ans = 0
ans = 0

Err, in fact this seems to be a compatiability problem with matlab,
as it seems matlab save a copy of the current symbol table for inline
functions, since in matlab the above example gives 

>> fcn = inline('not(x)')

fcn =

     Inline function:
     fcn(x) = not(x)

>> not = inline('x')

not =

     Inline function:
     not(x) = x

>> fcn(1), not(1)

ans =

     0


ans =

     1

This probably also points to a deeper compatiability issue with function
handles as functions called by the original function might also change
in the current symbol table...

> Inline functions are listed as variables in the who output and can be saved
> at least in the octave binary format. Are there any deeper differences? Is
> there any way of saving functions defined by the function keyword?

You are upto date, that was only in the CVS a couple of days ago... Function
handles and inline functions can be saved in hdf5, octave binary and ascii
formats. I don't think it makes sense to save user functions, since when
saving all variables you'd effective resave all of your script files. 
Perhaps functions that were entered interactively should be flagged and 
saved in this case.

Regards
D.

-- 
David Bateman                                address@hidden
Motorola CRM                                 +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 1 69 35 77 01 (Fax) 
91193 Gif-Sur-Yvette FRANCE

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



reply via email to

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