Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: "Perlifying" an XSpp method

by Anonymous Monk
on Mar 08, 2015 at 23:35 UTC ( [id://1119271]=note: print w/replies, xml ) Need Help??


in reply to "Perlifying" an XSpp method

I would like to write: ...

No you wouldn't :)

The beauty of mirroring the C++ api is you're mirroring the C++ api -- its like the same API, same names, same usage (basically)

If you want to change it, don't make it the same , same level of wordiness, same names, but with slightly different semantics, make it easy to use, like

yippy( sub { my($seq ) = @_; warn $seq; } ); sub yippy { my( $do_something ) = @_; my $reader = Compress::DSRC::Archive->new; my $seq = Compress::DSRC::FastqRecord->new; while ($reader->next_seq($seq)) { $do_something( $seq ); } }

I have a lot to learn about XS ...

:) Avoid XS as much as possible, unless you want to learn a lot about XS instead of just getting on with whatever task you have to complete :)

Replies are listed 'Best First'.
Re^2: "Perlifying" an XSpp method
by jdv (Sexton) on Mar 09, 2015 at 03:23 UTC
    The beauty of mirroring the C++ api is you're mirroring the C++ api -- its like the same API, same names, same usage (basically)

    Well, fair enough. This way of "recycling" the FastqRecord object seems awkward in an otherwise OO module (at least to someone who learned Perl first and only later delved into C/C++). I do see your point, however - sticking as close as possible to the C++ API probably has the least potential for confusion and will be easiest to maintain.

    Avoid XS as much as possible, unless you want to learn a lot about XS instead of just getting on with whatever task you have to complete

    That is advice that I have no problem embracing.

Re^2: "Perlifying" an XSpp method
by Anonymous Monk on Mar 08, 2015 at 23:38 UTC

    If you still want the sameness, you can do like this

    sub Compress::DSRC::Archive::NextSeq { my( $reader ) = @_; my $seq = Compress::DSRC::FastqRecord->new; return $seq if $reader->next_seq($seq) return undef; }
      Thanks for this suggestion. I'm not sure why I didn't think of doing this in the Perl class rather than mucking about in the XS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1119271]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-28 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found