Hi Bram,

> Having two Vim executables is a bad idea.  Next you have two versions of
> Perl, small and big features, etc.  You end up with many different Vim
> executables.  It's better to try and have one executable.

OK, let's have both python2.x and python3.x.

But let's get a common understanding first.
Then, if you feel comfortable to integrate that in the official sources,
I can do the changes needed.

> It's a lot easier if the Python script itself specifies what version of
> Python it is for.  E.g., by something in the first line.  Then one can
> use the ":python" command and get an error if the Python version doesn't
> match.  If it would be possible to build Vim with both Python 2.x and
> 3.x then it would always work.

Now I understand what you mean:
the vim python command gets dispatched to a C function that pre-scans to 
see
which python version to use 
and then calls the according ex_python() or ex_python3() C functions.

First thought: For single line statements one could use a simple "3" to 
decide.
But note: '3+X' is a valid python expression which could change X.
Lagacy ':python3+X' would then suddenly be forwarded to python3 as '+X',
which is also valid. This could all get undetected.

So 3 cannot be used to distinguish.

And anyway, there is no big difference from script solution to having two 
commands. 
(Please comment)


I suggest a new command for python 3.

My favourite currently
        :PYTHON
I know that this is contrary to the policy to use small letters for 
builtin ex commands,
but :py3 and :python3 would have problems like the one mentioned above.
(:_python possibly would do, too.) 
(please comment)


Roland


[email protected] schrieb am 27.08.2009 14:17:34:

> 
> Roland Puntaier wrote:
> 
> > to embed both python 2.x and python 3.x in vim is possible (See PSS)
> > 
> > But I am not really convinced that this is necessary.
> > With the current implementation one already has the possibility to
> > either compile the code with python 2.x or with python 3.x.
> > 
> > One can do the forking in the system by making two vim executables
> > and name one differently.
> > There is no need to duplicate the other vim files.
> 
> Having two Vim executables is a bad idea.  Next you have two versions of
> Perl, small and big features, etc.  You end up with many different Vim
> executables.  It's better to try and have one executable.
> 
> > In scripts one can do something like this (see also PSSS)
> > (from pythoncomplete.vim attached in this mail):
> > 
> >     py << PYTHONEOF
> >     import sys
> >     vim.command("silent let g:python_hexversion = %i" % 
sys.hexversion)
> >     PYTHONEOF
> > 
> >     function! s:DefPython()
> >         if g:python_hexversion < 0x03000000
> >     python << PYTHONEOF
> >     ...
> >     PYTHONEOF
> >         else
> >     python << PYTHONEOF
> >     ...
> >     PYTHONEOF
> >         endif
> >     endfunction
> > 
> > And normally it is not a big deal to convert the python code to 
python3.
> > The necessity to do something might speed up the convertion of 
existing 
> > scripts.
> 
> Don't underestimate how much effort it is to do the conversion for
> someone who doesn't know Python.  Very often scripts are abandoned by
> the original author and it's up to the user to make it work again.
> It's a lot simpler if old scripts still work.
> 
> > The executable versions would have python2.x embedded until the time 
has 
> > come to change that, too.
> > If somebody uses python with vim he probably will also be able to 
compile 
> > vim by himself.
> 
> Python is often used as part of extensions by people who don't know
> anything about Python.
> 
> > To include both in the sources allows those to do so more easily,
> > because vim sources change and the python3 patch might not be 
appliable 
> > any more in the future.
> 
> Unfortunately the embedding of Python in Vim has had its incompatibility
> problems.  But with a series of #ifdefs one can make it work.
> 
> > Up to now I did't have any problem with the python3 patch. It should 
be OK 
> > to include in the trunk.
> > The only difference I know about: vim.current.buffer.mark(b'<') intead 
of 
> > vim.current.buffer.mark('<').
> 
> [...]
> 
> > pythoncomplete.vim is part of the vim sources, but not yet adapted to 
> > python 3 in the above patch.
> 
> Hmm, so we need to maintain two versions of pythoncomplete.vim?
> At least for the Python part of it.
> 
> > PSS
> > to embed both python 2.x and python 3.x in vim:
> > 
> > - the if_python3.c compilation would need to be provided with include 
and 
> > library paths different
> >   from those for the if_python.c compilation.
> >   Currently all files are compiled with
> > 
> >     CCC = $(CC) -c -I$(srcdir) $(ALL_CFLAGS)
> > 
> >   The current python3 integration in the build system is already 
parallel 
> >   (PYTHON_xxx and PYTHON3_xxx), just not up to $(CCC) yet.
> 
> I don't understand this.
> 
> > - the functions used thoughout the vim sources when FEAT_PYTHON
> >   would need to get different names and could be included like this
> > 
> >     #ifndef FEAT_PYTHON
> >     # define ex_python          ex_script_ni
> >     # define ex_pyfile          ex_ni
> >     #endif
> >     #ifndef FEAT_PYTHON3
> >     # define ex_python3         ex_script_ni
> >     # define ex_pyfile3         ex_ni
> >     #endif
> > 
> >     EX(CMD_python,              "python",       ex_python,
> >                 RANGE|EXTRA|NEEDARG|CMDWIN),
> >     EX(CMD_python,              "pyTHON",       ex_python3,
> >                 RANGE|EXTRA|NEEDARG|CMDWIN),
> >     EX(CMD_pyfile,              "pyfile",       ex_pyfile,
> >                 RANGE|FILE1|NEEDARG|CMDWIN),
> >     EX(CMD_py3file,             "pyFILE",       ex_pyfile3,
> >                 RANGE|FILE1|NEEDARG|CMDWIN),
> > 
> >   If one preferred a name like py3 there would need to be 
> >   an adaptation in find_command() and possibly set_one_cmd_context(),
> >   because only chars up to a number are considered. 
> >   But I think the above names should be OK.
> 
> It's a lot easier if the Python script itself specifies what version of
> Python it is for.  E.g., by something in the first line.  Then one can
> use the ":python" command and get an error if the Python version doesn't
> match.  If it would be possible to build Vim with both Python 2.x and
> 3.x then it would always work.
> 
> > PSSS
> > [email protected] schrieb am 17.07.2009 21:57:23:
> > > 
> > > Best would be if the script itself specifies it runs with Python 3.
> > > That's much easier than a setting or a different command.
> > > 
> > > It's not possible for a single Python command though.
> > 
> > I'm not sure what you meant here. I interpret it as this:
> > The vim script calls the python script via
> > 
> > py << EOF
> > ...
> > EOF
> > 
> > that script is parsed by python and since python 3 has different 
syntax 
> > one cannot do 
> > 
> > if sys.hexversion < 0x03000000:
> >         ... (syntax error for python 2.x code if python 3)
> > else:
> >         ... (syntax error for python 3.x code if python 2)
> > 
> > But the solution is mentioned above.
> 
> The ":python" command will only work for either Python 2.x or 3.x, since
> one can't tell which version the Python commands were written for.
> So a ":python3" command would be required.
> 
> The ":pyfile" is different, since that loads a separate file, where the
> Python version can be specified.
> 
> I wish Python 3 would have been written in a way that Python 2.x
> commands can still be executed.  That would have avoided lots and lots
> of problems at a small price.
> 
> -- 
> If Microsoft would build a car...
> ... You'd have to press the "Start" button to turn the engine off.
> 
>  /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net 
\\\
> ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ 
\\\
> \\\        download, build and distribute -- http://www.A-A-P.org ///
>  \\\            help me help AIDS victims -- http://ICCF-Holland.org ///


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui