mason@utcsrgv.UUCP (Dave Mason) (02/12/85)
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@Toronto ARPA: mason%Toronto@CSNet-Relay
ljdickey@watmath.UUCP (Lee Dickey) (02/13/85)
A recent writer says: > ...... I want to talk about programming idioms. > These are code sequences which produce some useful non-obvious result. I react when I see the word ``idiom'' used this way. To me, an idiom is a set of works which, when combined, have a meaning that cannot be deduced from the meanings of all of the constituent parts. For instance, the meaning of the phrase ``Fat chance!'' is not likely to be discovered by someone with a dictionary. I am not saying that we, as programmers, should not have certain common phrases that we use often. We do. Nor am I saying that what we write must always be immeadiately obvious to a beginning programmer in a survey course that touches on several different languages. But, is there any serious programmer who advocates the introduction of new meanings for programming phrases that are different from the combined meanings of the constituent parts?
dgary@ecsvax.UUCP (D Gary Grady) (02/14/85)
<> > > ...... I want to talk about programming idioms. > > These are code sequences which produce some useful non-obvious result. > > I react when I see the word ``idiom'' used this way. To me, an idiom is a > set of works which, when combined, have a meaning that cannot be deduced > from the meanings of all of the constituent parts. A common example of a programming "idiom" is the sequence temp = var1; var1 = var2; var2 = temp; for interchanging var1 and var2. But the writer above is correct; this isn't an "idiom" or even analogous to an idiom in the normal sense of that word. A better term might be "cliche." I therefore propose that we discuss programming cliches... :-) -- D Gary Grady Duke U Comp Center, Durham, NC 27706 (919) 684-3695 USENET: {seismo,decvax,ihnp4,akgua,etc.}!mcnc!ecsvax!dgary
ee163acp@sdcc13.UUCP (DARIN JOHNSON) (02/17/85)
I think the term idiom is appropriate in this usage. To me and idiom is something native speakers of a language readily understand, but which book-learned speakers have difficulty when translating. They are usually context sensitive. For example, the C favorite for for (;;) is usually readily understood by C programmers, but FORTRAN and other similar programmers have a different concept of what the word 'for' means. They may think that this is an endless loop until the context is looked at (a break inside the loop). Another problem with C 'for' statements is that it is really a form of the 'while' confusing lots of people who thought they knew what a 'for' statement was. LISP provides lots of confusion for people who read the manuals that have only definitions of the words. There is almost no way to understand a LISP program by using a 'dictionary'. A moderate user will also be confused over some strange shorthand. The APL example given earlier is a classic example of what I consider an 'idiom'. Why in the world would anyone want to '.and' a list of words???? So if you take 'idiom' at its defined meaning, it is mostly applicable to usage as a programming word. (at least it is the closest in meaning what is needed) Darin Johnson @ UCSD
gnu@sun.uucp (John Gilmore) (02/18/85)
Please move the bickering about the meaning of "idiom" to net.nlang, or kill it. Some good lists of APL idia have appeared, but I don't have the details handy. I believe Al Perlis' group at Yale did one; also a European university or users' group. Any APLers out there with a copy who'll post the details? Check back issues of the QuoteQuad if you really care. (Available thru ACM/SIGPLAN/STAPL -- Special Tech committee on APL).
arnold@ucsfcgl.UUCP (Ken Arnold%CGL) (02/19/85)
Can this discussion be moved out of every individual net.lang.foo group and be moved where such globabl discussion belong: net.lang? -- Ken Arnold ================================================================= Of COURSE we can implement your algorithm. We've got this Turing machine emulator...