Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

statebelt (2975)

  (email not shown publicly)

Journal of statebelt (2975)

Friday April 05, 2002
12:14 PM

Using scm2perl to understand SICP

[ #3990 ]
At PerlWhirl '02 I sat in on one of Dominus' lectures on using functional programming techniques in Perl. I asked where I could learn more about this and was recommended the book Structure and Interpretation of Computer Programs .

The examples are in Scheme, which is line-noise to me, so I've been using the scm2perl translator to help me understand the examples in my native perl. It does a decent job of translation, although it doesn't understand lambda functions (anon subs). scm2perl is part of the Gimp CPAN package and handles Gimp's script-fu dialect of Scheme.


[localhost:~] thomas% less sum.scm
(define (sum term a next b)
  (if (> a b)
      (+ (term a)
         (sum term (next a) next b))))

[localhost:~] thomas% scm2perl sum.scm
creating parser...done
[localhost:~] thomas% less

use Gimp qw(:auto);
use Gimp::Fu;

sub sum {
   my ($term, $a, $next, $b) = @_;
   if ($a > $b) {
   } else {
      (term ($a) + sum ($term, next ($a), $next, $b));

exit main;

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Um... if you follow the book through from the beginning you'll get introduced to scheme as you go. It's worth the effort too, seriously head stretching.

    The Little Schemer and The Seasoned Schemer are also worth a go, the stuff in 'seasoned' dealing with continuations, co routines and all that jazz is definitely deep voodoo.
  • ugh (Score:3, Informative)

    by jhi (318) <> on 2002.04.05 17:01 (#6676) Homepage Journal

    I seriously suggest trying to wean yourself out of the translator. Grok Scheme. Then move on and grok Smalltalk. Prolog. Forth. (*) That's called "learning", I believe.

    (*) No, that's not a progression of "guruness", or recommendations, just a selection of mind-expanding experiences.

  • It's a very good book, but I was really happy once I was able to recognize that it has some serious problems and unexamined prejudices. Among other things, it has a definite air of "the perfect language" [] about it. I wish the authors had gone thru had had a co-author hang "rebuttal" footnotes off of their wackier unexamined statements which they always manage to phrase in totally absolutist terms.