#292 [Perl] add accessor to std_list.i

open
nobody
general (37)
5
2012-12-21
2012-01-19
No

I just found out that I was unable to access elements from a std::list in Perl. After some mails in the users mailing list I figured out that other languages, like Python and Ruby, have accessors and setters for std::list.

My time, and my understanding on the std_list.i file for Perl is not complete, and therefore I just hacked it a little to implement a get method. Together with the size method (already available) it makes it possible to fetch elements from the list.

In the future I might try to implement a method to return the full list as a standard Perl list (not sure how hard that would be). But that or an iterator would be the preferred solutions (I know).

So, for now I would thank if you could accept this patch for the next release (although incomplete).

Thanks
Alberto

Discussion

  • Alberto Manuel Brandão Simões

    Note that I did not test for built-in types. Sorry.

     
  • Alberto Manuel Brandão Simões

    Meanwhile, added an elements method, that returns a list of elements. It seems to be working, but again, I didn't check the specializations for built-ins.

     
  • Alberto Manuel Brandão Simões

    Patch fixed. It was a stupid bug.
    If you like the idea, I can try to help adding more accessors, but for that I would need some feedback.

    Cheers

     
  • William Fulton

    William Fulton - 2012-12-11

    The std_list_i_perl5.patch patch does not apply ... it is nothing like what is in Lib/perl5/std_list.i. Please submit a fixed patch. Also I don't think we'll apply any hacks... any improvements should provide the equivalent to what is in a normal perl like container. You'll have to explain that when you provide the fixed patch.

     
  • Alberto Manuel Brandão Simões

    Well, after one year it would be magic if the patch still apply. :-)
    If there are such big differences probably what I need already exists in swig (I do not look into it since February, when I submitted the patch)

    Anyway, access on lists by index is an usual Perl idiom.

    Will give feedback shortly, I hope (well, less than one year :-))

    Cheers
    ambs

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks