Path: utzoo!attcan!uunet!sco!seanf From: seanf@sco.COM (Sean Fagan) Newsgroups: comp.lang.misc Subject: Re: How to make a language downward-extensible? Message-ID: <7935@scolex.sco.COM> Date: 27 Sep 90 22:42:28 GMT References: <28750:Sep2402:58:2290@kramden.acf.nyu.edu> <1990Sep24.160705.21113@newcastle.ac.uk> <9363:Sep2521:41:1290@kramden.acf.nyu.edu> Sender: news@sco.COM Reply-To: seanf (Sean Fagan) Organization: The Santa Cruz Operation, Inc. Lines: 37 In article <9363:Sep2521:41:1290@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: > quickpick > fast(define builtin_bitcount 0) > count = bitcounts[j & 65535] + bitcounts[(j >> 16) % 65535]; > fast(define builtin_bitcount 1) > unsigned long i; > for(i = j;i;i >>= 1) count += (i & 1); > endquickpick Ugh. Are you then going to standardize *everything*? (N.B. The machines mentioned that had the bit-counting were, I suspect, the CDC Cyber and Cray machines, which have a Pop Count instruction.) The Elxsi has an instruction for passing a message (up to 836 bytes, I think) to a "port", which is usually another process (yet need not be). Are you going to straddle your "language" with the semantics of this instruction, simply because someone may find it useful? Some of the highly-specialized graphics processors have instructions to rotate three-dimensional polygons in memory; yet most of them have vastly to slightly different semantics; are you going to straddle the "language" with the semantics of *all* of them? Now, all that said: C has the #ifdef route, which is close to what you want. (The compiler won't automatically know that it can do the popcount, for example, but it's easy enough to add conditional expressions to check for which machine you're on.) Combine this with inline functions and assembly a la gcc, and it's hard to get any better *and* portable. -- -----------------+ Sean Eric Fagan | "Never knock on Death's door: ring the bell and seanf@sco.COM | run away! Death really hates that!" uunet!sco!seanf | -- Dr. Mike Stratford (Matt Frewer, "Doctor, Doctor") (408) 458-1422 | Any opinions expressed are my own, not my employers'.