Language Idioms

Dave Mason mason at utcsrgv.UUCP
Tue Feb 12 11:47:32 AEST 1985


I am teaching a course on comparative programming languages, and one of the
things I wish to bring out is the different viewpoints offered by different
languages.  As an example of this I want to talk about programming idioms.
These are code sequences which produce some useful non-obvious result.  The
languages I am talking about are: PASCAL, SNOBOL4, APL, LISP, and C.  The
students' backgrounds are mostly PL/I and FORTRAN with a smattering of
COBOL.  I would appreciate any examples you know of in any of these
languages.  As an example here are some I know of:
	In APL (there are many) if you have a character array with keywords
		one per row (KEY) and a word you wish to check (WORD) you
		say:	(KEY =.and WORD) iota 1		and you get the
		keyword number.

	In C (I'm sure there are many) to copy a character string:
		while (*dest++ = *source++) /* do nothing */ ;

I'm sure there are lots in APL, C, LISP, maybe SNOBOL4, maybe even PASCAL.
I will post a summary (anonymous if you wish) if there is enough interest.
(Please mail responses, I unfortunately don't have time to read all groups)
-- 
Usenet:	{dalcs dciem garfield musocs qucis sask titan trigraph ubc-vision
 	 utzoo watmath allegra cornell decvax decwrl ihnp4 uw-beaver}
	!utcsrgv!mason		Dave Mason, U. Toronto CSRI
CSNET:	mason at Toronto
ARPA:	mason%Toronto at CSNet-Relay



More information about the Comp.lang.c mailing list