Python syntax in Lisp and Scheme
Pascal Bourguignon
spam at thalassa.informatimago.com
Tue Oct 7 23:33:44 EDT 2003
prunesquallor at comcast.net writes:
> Excerpts from real C header files:
>
> #define FromHex(n) (((n) >= 'A') ? ((n) + 10 - 'A') : ((n) - '0'))
> #define StreamFromFOURCC(fcc) ((WORD) ((FromHex(LOBYTE(LOWORD(fcc))) << 4) + (FromHex(HIBYTE(LOWORD(fcc))))))
> #define ToHex(n) ((BYTE) (((n) > 9) ? ((n) - 10 + 'A') : ((n) + '0')))
> #define MAKEAVICKID(tcc,stream) MAKELONG((ToHex((stream) & 0x0f) << 8) | (ToHex(((stream) & 0xf0) >> 4)),tcc)
>
> #define va_arg(AP, TYPE) \
> (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)), \
> *((TYPE *) (void *) ((char *) (AP) \
> - ((sizeof (TYPE) < __va_rounded_size (char) \
> ? sizeof (TYPE) : __va_rounded_size (TYPE))))))
>
> #define PLAUSIBLE_BLOCK_START_P(addr, offset) \
> ((*((format_word *) \
> (((char *) (addr)) + ((offset) - (sizeof (format_word)))))) == \
> ((BYTE_OFFSET_TO_OFFSET_WORD(offset))))
:-)
However, taking sources written by the same programmer (me), at about
the same period, I get thrice or twice as many parenthesis in Lisp
than in C:
------- ----- ----- ------------------------------------
(-paren loc (/lin Language
------- ----- ----- ------------------------------------
160 / 627 = 0.255 COBOL sources.
6697 / 18968 = 0.353 C sources (.h + .c)
327 / 825 = 0.396 Java sources.
9071 / 18968 = 0.478 C sources, counting both ( and {
15 / 31 = 0.484 FORTRAN-IV (I've got only one toy program).
15224 / 29990 = 0.508 Modula-2 sources (* comments! *).
14754 / 13890 = 1.062 Lisp sources.
------- ----- ----- ------------------------------------
That's not much more...
for f in *.{h,c,lisp} ; do printf "%6d " $( sed -e 's/[^(]//g'<$f|tr -d '\012'|wc -c ) ; wc $f ; done|awk '{p=$1;l=$2;w=$3;c=$4;n=$5;printf "%6d / %6d = %6.3f %s\n",p,l,p/l,n;pt+=p;lt+=l;}END{printf "%6d / %6d = %6.3f %s\n",pt,lt,pt/lt,"Total";}'
--
__Pascal_Bourguignon__
http://www.informatimago.com/
Do not adjust your mind, there is a fault in reality.
More information about the Python-list
mailing list