Joel, Looking at your implementation, I can see a couple of differences between a Devel::Declare based approach and the current source filter.
If you do lots of NiceSlice operations, the source filter is convenient because it's global. On balance, the DD approach is local, which helps avoid accidental applications of the filter code if you use the slicing syntax sparsely in your code. I think the key advantage of a DD approach is that it could be faster, since it is called directly by the Perl tokenizer when it encounters an unknown token. In contrast, the standard source filter must process all the source text, and then the tokenizer handles all of it again. Have you done any benchmarks to compare the two approaches? David On Aug 8, 2011 11:01 PM, "Joel Berger" <[email protected]> wrote: > On Fri, Aug 5, 2011 at 12:33 PM, Chris Marshall <[email protected]> wrote: >> >> On Fri, Aug 5, 2011 at 12:12 PM, Joel Berger <[email protected]> wrote: >> > I see that you are working on NiceSlice2, but I keep wondering if there >> > isn't some way to do something like it (probably not drop-in replacement) >> > using Devel::Declare. >> >> Interesting. I'm not sure it would work so well to upgrade >> PDL::NiceSlice but it could work for adding a FORALL construct >> to pdl. > > More as a reason to try I have implemented a PDL::DeclareSlice > available on my github at https://github.com/jberger/PDL-DeclareSlice > of which all the important bits are in the module (should you not want > to go through the rigmarole of Dist::Zilla). As I suspected it isn't a > drop-in replacement, you need a keyword to initiate the slice. I'd be > interested if there are comments and would this be something worth > pursuing further. Its benefit is that it doen't use the source filter, > of course I'm sure it has edge cases just like a source filter would > have so perhaps thats not too much of an improvement. > > One more question, is there any real magic in the nslice method? For > now all my sugar does is convert to a slice call (i.e., `sl $pdl(1:4)` > to `$pdl->slice("1:4")`). > > What kind of FORALL did you have in mind? Perhaps I can take a look. > >> > Also, and while I have tried I have failed miserably, I have been wanting to >> > figure out how to make a useful PDL type for Moose, and most importantly >> > compatible with MooseX::Storage. That way I can make my physics simulations >> > within Moose and have attributes which are piddles and cache results for >> > future use. >> >> I'm only familiar with Moose enough to implement the pdl2 >> shell but maybe you could do this by implementing a wrapper >> class for pdl using the has-a approch as in PDL::Objects. >> That might provide enough perl "glue" to get the job done... >> > > Thanks for that hint, I'm taking a look at it now, it does seem more promising. > > _______________________________________________ > Perldl mailing list > [email protected] > http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
_______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
