Zeno -

Others have addressed many of your questions. However, there is one
bit that I felt could get a little more attention:

On Thu, May 26, 2011 at 5:21 AM, Zeno Gantner <[email protected]> wrote:
> <snip>
>
> By the way, PDL::NiceSlice is implemented as a Perl source filter,
> what can be a bit dangerous.
> What are the general recommendations towards PDL::NiceSlice? Is its
> usage encouraged?

The basic problem is that a source filter simply reads in text and
applies overly simple text processing methods to do magic. This means
that most source filters are fragile, and when they break the errors
can be very weird. Source filters also do not (did not?) work with
modperl. This has been addressed on stack overflow here:
http://stackoverflow.com/questions/1785852/why-are-perl-source-filters-bad-and-when-is-it-ok-to-use-them

However, source filters do allow arbitrary syntax modifications. They
may be brittle, but they would be impossible otherwise. Furthermore,
common operations should require very few keystrokes. Since slicing is
a very common operation, it makes sense to minimize the number of
keystrokes needed to perform such slicing operations, and that's why
NiceSlice was created.

Source filters are difficult to test, but NiceSlice is used by many
PDL programmers and in that sense is thoroughly tested. You came
across the only major wart of using NiceSlice (in my opinion), which
is that errors may sometimes make no sense when you use NiceSlice.
However, you quickly learn to look at the line where the error
occurred, and when things mess up you try wrapping it in "no
PDL::NiceSlice" and "use PDL::NiceSlice" lines.

Generally, source filters should be used sparingly. NiceSlice is one
of the few cases where their use makes sense.

David

-- 
Sent via my carrier pigeon.

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to