From octave-maintainers-request at bevo dot che dot wisc dot edu Tue Feb 24 12:43:53 1998 Subject: Functions in if (0) ... loops From: "John W. Eaton" To: Michal Kaukic Cc: octave-maintainers at bevo dot che dot wisc dot edu Date: Tue, 24 Feb 1998 12:44:41 -0600 On 24-Feb-1998, Michal Kaukic wrote: | Functions, contained in | | if (0) | ... | endif | | blocks in script file get compiled after running that file. Yes, the code is parsed and converted to Octave's internal syntax tree representation. | E.g. let facfun.m be the file: | | ------------ | NOT_FUNCTIONAL_FILE=1; | | if (0) | function y=facina(x) | y=x.^3; | endfunction | | B=2; | | endif | ------------ | | Running facfun causes the compilation of function facina, but variable B | is not created. | Is this the expected behaviour of Octave? When the syntax tree is created, the function `facina' is defined and the symbol `B' is entered into the symbol table. Octave does not know yet whether it is a variable or a function. When the syntax tree is evaluated, the code inside the `if (0) ... endif' block is skipped, so it is never assigned. What behavior did you expect, and why? jwe