perl vs python bindings for vim and tab page object access

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

perl vs python bindings for vim and tab page object access

Arif Khokar
[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?

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Nikolay Aleksandrovich Pavlov
2017-01-06 5:56 GMT+03:00 Arif Khokar <[hidden email]>:
> [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).

>
> --
> --
> 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 [hidden email].
> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

LCD 47
On 6 January 2017, Nikolay Aleksandrovich Pavlov <[hidden email]>
wrote:

> 2017-01-06 5:56 GMT+03:00 Arif Khokar <[hidden email]>:
> > [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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
BPJ
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

BPJ
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 <[hidden email]>:
On 6 January 2017, Nikolay Aleksandrovich Pavlov <[hidden email]>

wrote:

> 2017-01-06 5:56 GMT+03:00 Arif Khokar <[hidden email]>:

> > [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 [hidden email].

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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Arif Khokar
In reply to this post by LCD 47
On 01/06/2017 07:20 AM, LCD 47 wrote:

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

I'm still reading through the perl documentation for XS files and the
perl API in order to get a better understanding of if_perl.xs.  But,
based on what I've read in the code so far, both buffer and window
objects appear to have the provision to return values in either the
scalar or list context.

That is, the use newBUFrv and newWINrv respectively to push the object
onto the stack for the return value.

The function definitions for newBUFrv and newWINrv appear to be nearly
identical and they make use of macros defined in globals.h for looping
through buffers or windows.  There are macros for looping through tab
pages as well.

Given that, could the approach used for accessing buffer or window
objects be re-used for tab page objects?

I most likely am missing something in terms of how a tab page object
differs from a buffer object and a window object in terms of being able
to translate it and pass it to perl from Vim though.

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

Granted, though I don't think doing something like this is supported for
the existing buffer and window bindings that exist in the VIM perl package.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Arif Khokar
In reply to this post by BPJ
On 01/06/2017 02:56 PM, BPJ wrote:
> 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.

It appears that the existing window and buffer bindings allow for
returning the total number of them, a list of them, or a specific one
based on a parameter passed into the appropriate method.

While having a nested data structure would be nice for tab pages (list
of windows each of which has an associated buffer), I think we could
still get what we want without nesting.  That is, get a flat list of
windows in a given tab page.  For each window in the list, get the
buffer it contains, etc.

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Arif Khokar
In reply to this post by Nikolay Aleksandrovich Pavlov
On 01/06/2017 01:41 AM, Nikolay Aleksandrovich Pavlov wrote:

> 2017-01-06 5:56 GMT+03:00 Arif Khokar <[hidden email]>:
>> [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).

Interestingly enough, it appears that none of the other language
bindings, aside from python, allow for direct tab page access.  The ones
I looked through were lua, mzscheme, tcl, and ruby.  I guess that means
that python is the most popular binding :)

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...