Loading ...
Sorry, an error occurred while loading the content.

Fwd: inquiry regarding vim patch to support python3 interface

Expand Messages
  • Roland Puntaier
    Hello Bram, about a month ago I sent the below message to the vimdev mailing list. I was wondering whether you consider integrating python3 support in the vim
    Message 1 of 8 , Jul 15, 2009
    • 0 Attachment
      Hello Bram,

      about a month ago I sent the below message to the vimdev mailing list.

      I was wondering whether you consider integrating python3 support in the
      vim mainline, in this or some other way.

      Personally I would like such a support in the mainline
      and there is a good chance that other vim + python users would like so,
      too.
      The reasons are:
      - there is more effort to merge with other patches if not in
      mainline
      - less manual work, because it would come along with AAP patching
      - no backward compatibility problem, because code and
      configuration is parallel to python 2.x
      i.e. one can configure for python 2.x and 3.x, the former being
      the default of course

      Any thoughts, plans or non-plans?

      Regards, Roland


      Roland Puntaier/Graz/AT/B&R schrieb am 03.06.2009 17:27:14:

      > Hello,
      >
      > I have reworked python3 support.
      > The attached patch is against 7.2.192.
      > But 7.2.193 to 7.2.195 do not change any involved files, so it is
      > fine for those, too.
      >
      > fixes in if_python3.c:
      >
      > - ``:pyfile`` did not work
      > - indexing via slices did not work
      > - crash in exit() after Py_Finalize() in windows (mentioned in my
      > previous mail)
      >
      > build process:
      >
      > The previous solution was rather improvised.
      > This one I think could be added to vim main line.
      > It does not compromise python2x support.
      >
      > - Makefile, config.mk.in and configure.in are patched
      > (also auto/configure, since that is part of the vim source
      distribution,
      > although it can also be made via ``make autoconf``)
      >
      > The changes are such that python3 is considered an additional
      interpreter.
      >
      > In order to build you must edit the Makefile and uncomment --
      > enable-python3interp
      > or provide it as CONF_OPT_PYTHON in the command line, like ::
      >
      > CONF_OPT_PYTHON=--enable-python3interp make
      >
      > Note: The system must provide python3 ::
      >
      > ln -s python3 python3.1
      >
      > - patched make files for non-linux:
      > - Make_mvc.mak
      > To compile do this in the windows console::
      >
      > cd src
      > msvc2008.bat
      > nmake -f Make_mvc.mak GUI=yes PYTHON_VER=30 PYTHON=C:\Python30
      >
      > - Make_bc5.mak (changed, but not tested)
      > - Make_cyg.mak
      > - Make_ming.mak
      > To compile do this in msys bash::
      >
      > PYTHON=C:/Python30 PYTHON_VER=30 GUI=yes make -f Make_ming.mak
      >
      > I have not touched Make_vms.mak and those ``*.mak`` files that do
      > not have ``python``.
      >
      > PS: I have done this patch, because I use vim as python frontend and
      > I wanted to start using python3.
      > I would gladly maintain this python3 support. So if any problems
      > turn up, please contact me.


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Bram Moolenaar
      ... I m not in a great hurry to support Python 3.x. It should be included, but we need to make sure that it works well. Also note that Python 3.x is not
      Message 2 of 8 , Jul 15, 2009
      • 0 Attachment
        Roland Puntaier wrote:

        > about a month ago I sent the below message to the vimdev mailing list.
        >
        > I was wondering whether you consider integrating python3 support in the
        > vim mainline, in this or some other way.
        >
        > Personally I would like such a support in the mainline
        > and there is a good chance that other vim + python users would like so,
        > too.
        > The reasons are:
        > - there is more effort to merge with other patches if not in
        > mainline
        > - less manual work, because it would come along with AAP patching
        > - no backward compatibility problem, because code and
        > configuration is parallel to python 2.x
        > i.e. one can configure for python 2.x and 3.x, the former being
        > the default of course
        >
        > Any thoughts, plans or non-plans?

        I'm not in a great hurry to support Python 3.x. It should be included,
        but we need to make sure that it works well.

        Also note that Python 3.x is not compatible with 2.x, so Vim scripts
        that include Python might break. That's a hassle. We should at least
        have a way to check which one Vim is supporting. "has('python3')"
        probably.

        It would be even better if we can support python 2.x and 3.x at the same
        time and select the interpreter for every python command. Is this even
        possible? I would not be surprised if the Python libraries conflict.


        --
        From "know your smileys":
        *<|:-) Santa Claus (Ho Ho Ho)

        /// Bram Moolenaar -- Bram@... -- 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
        -~----------~----~----~----~------~----~------~--~---
      • Roland Puntaier
        Hello Bram, 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
        Message 3 of 8 , Aug 25, 2009
        • 0 Attachment
          Hello Bram,

          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.

          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.

          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.
          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.

          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('<').

          Roland

          PS
          the patch is at:

          http://groups.google.com/group/vim_dev/attach/d1ac2a1b471becb7/vim-7.2.192-python3.patch?part=2

          pythoncomplete.vim is part of the vim sources, but not yet adapted to
          python 3 in the above patch.
          This is:


          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.

          - 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.

          PSSS
          Bram@... 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.


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Bram Moolenaar
          ... 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
          Message 4 of 8 , Aug 27, 2009
          • 0 Attachment
            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
            > Bram@... 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 -- Bram@... -- 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
            -~----------~----~----~----~------~----~------~--~---
          • Roland Puntaier
            Hi Bram, ... 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
            Message 5 of 8 , Aug 27, 2009
            • 0 Attachment
              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


              Bram@... 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
              > > Bram@... 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 -- Bram@... -- 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
              -~----------~----~----~----~------~----~------~--~---
            • Bram Moolenaar
              ... Hmm, annoying. We should have required white space after the command. We could require that now. That still has the problem that this is valid: :python3
              Message 6 of 8 , Sep 3, 2009
              • 0 Attachment
                Roland Puntaier wrote:

                > 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.

                Hmm, annoying. We should have required white space after the command.
                We could require that now. That still has the problem that this is
                valid: ":python3 +X"
                And would be interpreted in current Vim as ":python 3 +X"
                But do we really care?

                I actually can't think of a useful Python command that starts with 3.
                You can have a valid command like ":py3+4", but it has no effect, so it
                should not actually be used. Is there anything else than an expression
                that starts with the number 3?

                To be as backwards compatible as possible, we would require white space
                after ":python3", but ":pythonXXX" would still be accepted. XXX would
                need to start with a non-letter, but not a 3. To stay on the safe side
                we should not accept any number.

                > 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)

                Upper case letters are reserved for user commands. Breaking this
                convention makes things too complicated and confusing.

                An alternative would be ":pythonthree". But that looks ugly.
                ":pythree" is not nice either.

                Perhaps we should use ":py3", with the requirement that white space
                follows. It's not perfect, but probably the best compromise.
                Is ":py_3" better? Looks strange.

                - When Vim was compiled with Python 2.x ":py3" gives an error
                - When Vim was compiled with Python 3.x ":python" gives an error
                - When Vim was compiled with both 2.x and 3.x both commands work


                --
                hundred-and-one symptoms of being an internet addict:
                179. You wonder why your household garbage can doesn't have an
                "empty recycle bin" button.

                /// Bram Moolenaar -- Bram@... -- 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
                -~----------~----~----~----~------~----~------~--~---
              • Roland Puntaier
                Hi Bram, ... or put differently: if (command starts with :py) - following digits are interpreted as part of the command and an error results if the command is
                Message 7 of 8 , Sep 3, 2009
                • 0 Attachment
                  Hi Bram,

                  > - When Vim was compiled with Python 2.x ":py3" gives an error
                  > - When Vim was compiled with Python 3.x ":python" gives an error
                  > - When Vim was compiled with both 2.x and 3.x both commands work

                  or put differently:

                  if (command starts with :py)
                  - following digits are interpreted as part of the command
                  and an error results if the command is not available
                  - this entails that a :pyxxx command must end in non-letter and
                  non-digit (but still allows '.',',','+',...)

                  And we accept the potential problems mentioned earlier.

                  If that's fine for you, it's fine for me, too.
                  I will do the changes and send a patch to vim_dev.

                  Roland


                  Bram@... schrieb am 03.09.2009 13:13:27:
                  >
                  > Roland Puntaier wrote:
                  >
                  > > 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.
                  >
                  > Hmm, annoying. We should have required white space after the command.
                  > We could require that now. That still has the problem that this is
                  > valid: ":python3 +X"
                  > And would be interpreted in current Vim as ":python 3 +X"
                  > But do we really care?
                  >
                  > I actually can't think of a useful Python command that starts with 3.
                  > You can have a valid command like ":py3+4", but it has no effect, so it
                  > should not actually be used. Is there anything else than an expression
                  > that starts with the number 3?
                  >
                  > To be as backwards compatible as possible, we would require white space
                  > after ":python3", but ":pythonXXX" would still be accepted. XXX would
                  > need to start with a non-letter, but not a 3. To stay on the safe side
                  > we should not accept any number.
                  >
                  > > 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)
                  >
                  > Upper case letters are reserved for user commands. Breaking this
                  > convention makes things too complicated and confusing.
                  >
                  > An alternative would be ":pythonthree". But that looks ugly.
                  > ":pythree" is not nice either.
                  >
                  > Perhaps we should use ":py3", with the requirement that white space
                  > follows. It's not perfect, but probably the best compromise.
                  > Is ":py_3" better? Looks strange.
                  >
                  > - When Vim was compiled with Python 2.x ":py3" gives an error
                  > - When Vim was compiled with Python 3.x ":python" gives an error
                  > - When Vim was compiled with both 2.x and 3.x both commands work
                  >
                  >
                  > --
                  > hundred-and-one symptoms of being an internet addict:
                  > 179. You wonder why your household garbage can doesn't have an
                  > "empty recycle bin" button.
                  >
                  > /// Bram Moolenaar -- Bram@... -- 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
                  -~----------~----~----~----~------~----~------~--~---
                • Matt Wozniski
                  ... +1 for :py3 being the best compromise. ~Matt --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_dev maillist.
                  Message 8 of 8 , Sep 5, 2009
                  • 0 Attachment
                    On Thu, Sep 3, 2009 at 7:13 AM, Bram Moolenaar wrote:
                    >
                    > Perhaps we should use ":py3", with the requirement that white space
                    > follows.  It's not perfect, but probably the best compromise.
                    > Is ":py_3" better?  Looks strange.
                    >
                    > - When Vim was compiled with Python 2.x ":py3" gives an error
                    > - When Vim was compiled with Python 3.x ":python" gives an error
                    > - When Vim was compiled with both 2.x and 3.x both commands work

                    +1 for ":py3" being the best compromise.

                    ~Matt

                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_dev" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  Your message has been successfully submitted and would be delivered to recipients shortly.