Nikolai Weibull wrote:
> On 9/16/07, Bram Moolenaar <[EMAIL PROTECTED]> wrote:
>
>> Nikolai Weibull wrote:
>
> [Request to allow referencing namespace#variable inside functions
> without g: prefix]
>
>> I don't see a good reason to make an exception. Requiring the use of g:
>> or s: makes it consistent. Otherwise there would be a list of
>> situations when you don't need to add g: before a variable name.
>
> Which would be a good thing, as the whole variable prefixing is one big
> crutch.
>
> Ranting aside, the prefix of number above is now#. I mean, have I
> gone to the trouble to declare what "namespace" the variable is in,
> shouldn't that be enough? And
>
> let s:bug#number = 1
>
> results in a
>
> E461: Illegal variable name: s:bug#number
>
> anyway, so there's no conflict in what you mean when you say bug#number.
>
> nikolai
s:number is not visible outside the script. It can never cause a sourcing of
the script.
g:bug#number (or bug#number outside a function) is defined in the script but
visible everywhere. If you use it outside the script and it is undefined, does
the script get loaded? Or is # just a lambda 'iskeyword' character when it
applies to a variable?
l:number ( or number, used inside a function) is not visible outside that
function. What about l:bug#number? I suppose it should be handled like
s:bug#number (both valid or both throwing an error).
There are other scopes: w:value, s:value and t:value are visible outside the
script, but not everywhere. I suppose w:bug#number, b:bug#number and
t:bug#number should also be valid.
Scoping has its rules, and in a programming language such as vimscript, they
better be well-defined rather than fuzzy. The current scoping rules for Vim are:
- name (with omitted scope) defaults to l:name if in a function, otherwise to
g:name
- all other scopes, where valid (including g:name within a function) must be
specified explicitly:
g:globalvar
b:bufvar
w:winvar
t:tabvar
s:scriptvar
&option
&t_xx
$ENVVAR
v:version (and other built-in variables and constants)
By adding more exceptions, you make the rule more complicated, not simpler.
Best regards,
Tony.
--
Art is either plagiarism or revolution.
-- Paul Gauguin
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---