[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: translators and scoping rules (was: Re: language translator help)
From: |
John W. Eaton |
Subject: |
Re: translators and scoping rules (was: Re: language translator help) |
Date: |
Sun, 28 Apr 2002 21:08:30 -0500 |
On 28-Apr-2002, Per Bothner <address@hidden> wrote:
| Am I right in guesing that Octave uses dynamic scoping, rather than
| lexical scoping?
Are those the only choices? :-)
The rules are essentially the same as for Fortran. Variables are
local to functions (subroutines). The only "global" variables are
declared global (common). There is no statement like (let ...).
Functions are all in one global scope. Functions (but not variables)
can be shadowed. If a function is shadowed by a variable, "clearing"
the variable restores the function. For example,
octave:1> which sin
sin is a builtin function
octave:2> sin (pi/2)
ans = 1
octave:3> sin = 0
sin = 0
octave:4> which sin
sin is a user-defined variable
octave:5> clear sin
octave:6> which sin
sin is a builtin function
octave:7> sin (pi/2)
ans = 1
Well, my excuse is that I didn't make this up, I inherited it from
Matlab.
jwe
translators and scoping rules (was: Re: language translator help), John W. Eaton, 2002/04/27
Re: translators and scoping rules (was: Re: language translator help), Per Bothner, 2002/04/28
Re: translators and scoping rules (was: Re: language translator help),
John W. Eaton <=
Re: translators and scoping rules (was: Re: language translator help), Per Bothner, 2002/04/29
Re: translators and scoping rules (was: Re: language translator help), John W. Eaton, 2002/04/29
Re: translators and scoping rules (was: Re: language translator help), Neil Jerram, 2002/04/28