Friday, January 6, 2017

Re: perl vs python bindings for vim and tab page object access

It would be reasonable if vim passed arrays to perl as anonymous references and perl had to pass arrays to vim as references. After all passing multiple arrays or hashes to subroutines already requires references in perl, as does nested data structures.

fre 6 jan. 2017 kl. 13:21 skrev LCD 47 <lcd047@gmail.com>:
On 6 January 2017, Nikolay Aleksandrovich Pavlov <zyx.vim@gmail.com>

wrote:

> 2017-01-06 5:56 GMT+03:00 Arif Khokar <arif.i.khokar@gmail.com>:

> > [I sent this to the vim_dev list earlier, but didn't get a response]

> >

> > After looking through the documentation for if_perl and if_pyth,

> > I noticed that the python bindings had the ability to query and

> > manipulate tab page objects, while the perl bindings did not.

> >

> > Is there a technical reason for the difference (i.e., a limitation

> > for the perl C bindings?), or is it something that was never

> > implemented?

>

> Perl is not so popular nowadays, so there are less authors willing

> to contribute to if_perl.xs. I do not think there are any technical

> reasons (I do not know XS, but I am the person who initially wrote

> Python tab page objects and can say that there should not be any

> problems on the Vim side and given that there are objects like $curbuf

> I do not see why there could not be something like $tabpages).



    On a side note: if_perl doesn't allow variable bindings the way

if_pyth does.  For this reason passing non-trivial data structures

back and forth between Vim and Perl is often more complicated than the

rest of the code combined.  A while ago I looked into backporting that

feature from if_pyth, and I quickly realised that the main problem in

doing it is the explicit difference Perl makes between lists, arrays,

and references to said objects, which has no equivalent in Vim.  And

even when no references are involved, the semantic is still somewhat

different.  For example, in Perl you can do things like this:



        $ perl -MData::Dumper -e '@a = ((1, 2), (3, 4)); print Dumper(\@a)'

        $VAR1 = [

                  1,

                  2,

                  3,

                  4

                ];



which, among many other things, allows map() to change the number of

elements of its input:



        $ perl -MData::Dumper -e '@a = map { (0, $_) } (1, 2); print Dumper(\@a)'

        $VAR1 = [

                  0,

                  1,

                  0,

                  2

                ];



Doing the same in Vim is a lot more convoluted.  Just FWIW.



    /lcd



--

--

You received this message from the "vim_use" 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_use" group.

To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: