Sunday, September 18, 2011

Re: Using :let to view a wildcard of variables

In reply to ``Re: Using :let to view a wildcard of variables''
sent 18 September 2011, Sunday by Spiros Bousbouras

> Why are you using a dictionary ? Why not simply write
> ...
1. let val=function('tr')
2. let val=0
let val=[]
3. function Val()
endfunction
let Val=function('tr')
There is no way to safely handle function references without putting it into a
dictionary. You have a point though: I should have used `s:d', not `d' here.

> Is it because you want to avoid unlet ? But with the dictionary
> I get some error message that it can't be displayed because the
> nesting is too deep.
It should not happen unless you wrote `string()'.

Original text:
> On Sep 18, 10:25 am, ZyX <zyx.vim@gmail.com> wrote:
> > In reply to ``Using :let to view a wildcard of variables''
> > sent 17 September 2011, Saturday by David Fishburn
> >
> > > Will display all variables currently defined in Vim.
> > >
> > > One thing I have always wanted to do is:
> > > :let my_prefix.*
> > > :
> > let d={}
> > for [var, d.val] in filter(items(g:),
> > 'v:val[0]=~#"\\v^my_prefix"')
> >
> > echo var."\t" d.val
> >
> > endfor
>
> Why are you using a dictionary ? Why not simply write
>
> for [var, var2] in filter(items(g:), 'v:val[0]=~#"\\v^my_prefix"')
> echo var."\t" var2
> unlet var2
> endfor
>
> Is it because you want to avoid unlet ? But with the dictionary
> I get some error message that it can't be displayed because the
> nesting is too deep.

No comments:

Post a Comment