I was going to title this post "Is NiceSlice really the best thing
since... y'know?" but instead chose "learning the basics..." Both
titles are not helpful enough, but hopefully the following will
explain.

Because of my recent, small, trouble with NiceSlice (NiceSlice
affected some DBI-specific code adversely), I started thinking -- I
really know almost nothing about slicing, and slicing is the very
basics of PDL, and, I certainly am not going to learn anything if I
learn NiceSlicing.

>From not too long ago, I remember not being able to get references in
Perl (I also remember not being able to hold my left hand in proper
chords on the guitar, and not being able to grasp that in spite of
having only two wheels, a bicycle could be balanced). Part of the
problem, for me, was the arcane dereferencing syntax, y'know, the one
where you surround your reference with curly braces. Eventually,
things clicked for me when I realized that all I had to do to
reference a variable was to prefix it with a \, and all I had to do to
dereference it was to prefix it with the sigil of the referenced
variable.

There is analog here. I really know nothing about slicing. And,
NiceSlice is not helping. First, I have to learn slicing and indexing,
and once I am good at it, only then can I pass the judgment that that
syntax is not good enough, and I should be using NiceSlice.

Which brings me to the docs -- the docs on indexing and slicing really
need a lot of work.

I started with 
http://pdl.sourceforge.net/?docs=NiceSlice&title=PDL::NiceSlice#the_new_slicing_syntax
but while it showed me the syntax, I couldn't figure out how to parse
that syntax. For example, take $c = $b(0:-3:4,(0)); I really don't
know what is going on here unless I know the basics of slicing. So, I
went looking for slice sytax. But even
http://pdl.sourceforge.net/?docs=Slices&title=PDL::Slices tells me a
lot about what I can do with it, and the functions it has, but it
doesn't show me what exactly is slicing and how I can do it. It
doesn't explain the syntax to me.

Finally, I found
http://pdl.sourceforge.net/?docs=Indexing&title=PDL::Indexing and
there was much brightness there. Actual explanation of the slicing
syntax via the piddle indexing syntax.

Part of this is my own problem -- I want to jump into making correct
sentence without first spending the time learning the alphabet (raise
your hand if you share this with me). Part of it is -- everyone has to
learn some syntax. Whether they learn Slice or NiceSlice, there is no
magic incantation. One *has* to learn something. One may as well learn
Slice. I personally don't find NiceSlice any nicer than Slice because
I don't know how Slice is to begin with. Recall the discussion on this
list about the following (from the docs) -- "Using PDL::NiceSlice
slicing piddles becomes so much easier since, first of all, you don't
need to make explicit method calls." Why is making "explicit method
calls" not easy? I don't really know. And, if I am going to learn
Slice, I may as well learn it and get good at it, instead of looking
for another way, specially a source filter that can screw up with
other parts of my program.

Sidenote -- this is why I never did learn html via CGI.pm. I
personally think the various CGI.pm methods for making html are
nonsense, because they are not any more easier than html. But, that is
another story.

PDL is also compounded with another problem -- since it deals with
complex arrays, it becomes hard to visualize these arrays. And,
personally, until I can visualize them, I can't really deal with 'mv'
and 'at' and slice very easily. I find drawing diagrams of my array
with pen on paper, and then trying to figure out what exactly does mv
do, or what exactly do I need to say in order to grab a chunk out with
slice. (doesn't help much that the darn arrays are indexed starting at
0, so when I want to work with the 3rd column of the 4th array in an
AoA, I really mean a[3][2]. A visualizer would be cool, kinda like the
IDE of PLT-Scheme which actually draws arrows between functions, but
that may be just too complicated.


-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================

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

Reply via email to