(was at ntb-clips) Recursion, Callbacks, Syntax (Was: Local Variables)
- On Tuesday 07 November 2006 11:51, Veli-Pekka Tätilä wrote:
> Alan_C wrote:<snip>
> >> talk a while back about subroutines and concluded that in essence
> Besides filtering their are a great many other list functions that takeIn Perl I've only slightly wrapped my head around map. They say if I want
> advantage of callbacks. Map or apply, grep or filter, reduce, zip or mesh,
> part and so on. Even sorting can be handled with callbacks. Just feed a
partake of the power of Perl to learn map. I keep plugging.
> One of the things that annoy me in NTP clips are the various functions thatAs you've seen, that must be done "a bit differently" in clip, thus:
> work like if. It would be much more minimalist if there was only one kind
> of if in the language level:
> if <condition> <statement>
> The semantics are that statement is executed if condition is true. Yet
> there are functions like:
> That means you cannot easily use the inRange function in any other context
> such as if clip code will some day get a true while loop. It also means you
> cannot use logical operators. Pseudo-code follows:
> if ^!IsNumber ^%variable% and ^!InRange ^%variable%, 1..10
> The point here is to be strict about types.
^!IfFalse $IsNumber(^%variable%)$ alpha
^!IfTrue $InRange(^%variable%, 1..10)$ num_in_range
; do alpha processing here
; passes the and logical operator
; so do num in range processing here
> > [recursion] Stuff like this is in the book entitled "Higher Order Perl"Thanks much for that. I just checked out its object oriented chapter and it's
> > of which
> > I have this book but I'm (mostly) not ready for such book yet.
> On an OT:ish side note, you could start out with the free beginning Perl
> book. Unlike learning Perl, they cover references and objects, too:
what I've been needing. (keeps plugging forward on the learning happy trail).
FWIW I have "Intermediate Perl" (I need to get into it more). But I find it
of value for me to have complimentery texts/authors due to doing so
facilitates better for "light bulbs to come on" for me.
For some reason for me many of the O'Reilly Perl series they seem to take a
programmer background for granted. which sometimes I'm not readily able to
learn/receive what I need to get from just this. (though it's getting better
since I've also been learning programming for some time now too). But add a
complimentary (different) author/publisher/text and all of a sudden I
get "aha" moments as in *now* I get what they were trying to teach me.
> PS: I still have a bit of an attitude problem with clips. To summarize:Once I learned some Perl, I had then also hit upon that/this very same
> CLips are a very elaborate macro language, certainly, but not a very good
> scripting language.
If I were you, I wouldn't learn clips except for only whatever minimal amount
of clip code is needed in order to integrate Perl with Notetab.
To do so, some search terms:
; let Perl do the bulk of the work
ntb-scripts list yahoo groups www archive for that command and also some
The combo of that/those turns Perl into a "tool" (a clip on steroids) whereby
Perl is doing it instead of clip doing it (though a minimal amount of clip
code initiates) -- these can be run just like clips (seamless fashion) on
There are (or used to be) some Perl clip libraries (which use Perl via clip
integration of Perl into Notetab) at the notetab.com clip repository.
"Clip only" needs way much more code. The code is hard to follow unless
utilize copius amounts of comments and documentation within. But,
Extend Notetab with Perl. Now you've got the best of both worlds. The bulk
of coding is done in Perl. Needs way less amount of code. And Perl is
idiomatic. Now I'm using my scripting language.
I had some larger clips. Then I learned some Perl. Then I discovered that a
Perl equivalent to a larger clip happens in about only one third of the code
that clip code needs for same task. And I can read the Perl, nearly as if it
is mostly a self documenting code.
Many months later after writing the code, I'd much rather come back to Perl
code than clip code due to the significant ease with which Perl code is to
follow as it nearly self documents itself and especially so after I've
learned of some of its idioms.
But it is possible to be "obfuscated" with Perl. But I do not program Perl in
this fashion. With Perl, can choose. I choose a common, practical, easy to
follow style also with Perl's idioms whenever/wherever appropriate.