Nikolay Pavlov wrote:

> On Mar 23, 2014 12:19 AM, "Bram Moolenaar" <[email protected]> wrote:
> >
> >
> > ZyX wrote:
> >
> > > > The docs are wrong, using "if" is allowed.  The other two are not.
> > >
> > > Why? It makes parsing impossible. E.g. like indicated by @Yukihiro
> > > Nakadaira, there is absolutely nothing you can do with this error
> > > unless you add hacks for some specific cases (e.g. if `execute` is
> > > followed by a string literal starting with `if`).
> >
> > The code is full of exceptions.  There is a lot of history, some dating
> > back to the days of Ex.  The language wasn't designed to make life for
> > parser writers easier.  Some parts of the language weren't designed at
> > all, they just happened.  Not breaking existing Vim scripts is the main
> > goal, thus making changes in the language to simplify the implementation
> > will cause headeaches for users.
> 
> The problem is that you have a parser (I mean what vim does when skipping)
> there and it is not correct and may not be correct with this rule in
> effect. This statement in the help file exists since the first version
> recorded in mercurial repository and was also found in a 6.0 version
> archive: ":exe 'if'" was never correct. I just ask to make it not only
> officially incorrect, but also not working.

The problem with skipping is that it should not evaluate ":execute"
statements, since that may have side effects.  But then the matching
"endif" could be missed.  And a nested "if-endif" is not seen. Sounds
like a catch 22.

Let me update the help text to this:

                        Note: The executed string may be any command-line, but
                        starting or ending "if", "while" and "for" does not
                        always work, because when commands are skipped the
                        ":execute" is not evaluated and Vim loses track of
                        where blocks start and end.  Also "break" and
                        "continue" should not be inside ":execute".
                        This does not work, because the ":execute" is not
                        evaluated and Vim does not see the "while", and gives
                        an error for finding an ":endwhile": >
                :if 0
                : execute 'while i > 5'
                :  echo "test"
                : endwhile
                :endif

Generally, it should not be necessary to put "if", "while" and "for"
inside an execute, since these commands evaluate an expression
themselves.

Should we turn these "don't do this" instructions into an error?

> Though it worked in 6.0 as well (not when skipping, of course).

How about writing tests for these cases?  If you are writing a new
parser you must have a way to verify it does the right thing.

-- 
Friends?  I have lots of friends!  In fact, I have all episodes ever made.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui