Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!ncar!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.misc Subject: Re: Dynamic typing (part 3) Message-ID: <18401:Mar2013:52:2291@kramden.acf.nyu.edu> Date: 20 Mar 91 13:52:22 GMT References: <602@optima.cs.arizona.edu> <2400035@otter.hpl.hp.com> Organization: IR Lines: 38 In article <2400035@otter.hpl.hp.com> sfk@otter.hpl.hp.com (Steve Knight) writes: > This program read a file of syllables and printed out "passwords" composed > from three random syllables. sed 's/$/XXXXXXXXXX/' | travesty -s -o10 | ... Sorry, couldn't resist. > define program(); ;;; build a list of syllables > lvars syllables = 'syllables'.discin.incharline.pdtolist; > repeat 3 times > syllables.oneof.pr ;;; print a syllable 3 times > endrepeat; > nl( 1 ); ;;; throw 1 new line > enddefine; Fine, this is sort of example I was looking for. I claim that the conciseness of this program comes from the libraries available, not from the dynamic typing. #include #include "sop.h" #include "strinf.h" main() { SOP(strinf) *syl; strinf *s; int i; syl = SOPempty(strinf); while (s = strinfgets(stdin)) { strinfchop(s); SOPadd(syl,s,strinf); } for (i = 0;i < 3;++i) puts(strinftos(SOPrandpick(syl,strinf))); putchar('\n'); } (Yes, I admit I stole the name and concept of strinfchop from Perl.) Here strinf is a library for handling arbitrary-length strings, and sop is a generic set-of-pointers library. Surely you agree that, syntax aside, the C and Pop11 versions work the same way to accomplish the same results. The difference? I get better type checking and almost certainly better efficiency. For longer programs this means better turnaround time. ---Dan