From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c733905936c6b6b0 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.204.149.210 with SMTP id u18mr365063bkv.1.1336882440866; Sat, 12 May 2012 21:14:00 -0700 (PDT) Path: h15ni2120bkw.0!nntp.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe19.iad.POSTED!1d9d5bd3!not-for-mail From: David Thompson Newsgroups: comp.lang.ada Subject: Re: [OT] interesting reason why a language is considered good Message-ID: References: X-Newsreader: Forte Agent 3.3/32.846 MIME-Version: 1.0 X-Complaints-To: abuse@teranews.com NNTP-Posting-Date: Sun, 13 May 2012 04:14:00 UTC Organization: TeraNews.com Date: Sun, 13 May 2012 00:14:01 -0400 X-Received-Bytes: 4128 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: 2012-05-13T00:14:01-04:00 List-Id: On Tue, 17 Apr 2012 21:59:08 +0000 (UTC), anon@att.net wrote: > Most languages uses, a limited set of words. One reason is that it is > easier to implement. An example is where a routine does not return a > value aka a procedure is defined in some languages like Ada with the > usage of the word "procedure" but in other languages like C the same > routines is defined as a function with a "void" return value. The Yes, although this doesn't tie directly to use of (reserved) keywords. You can declare an ordinary identifier as a typedef for void, use that identifier as the return type for a function, and you have a function returning void, i.e. a procedure or 'void function', exactly as if you used the keyword. Nit: void return *type*. C treats void as a type that has no values. Um, well, okay. > problem in C is that a "return " statement can still be used > with a C's procedure, unlike Ada. > Not true, but approximately equidistant from three true things: - in original=K&R1 C, there was no void. (Kind of the opposite of Genesis ) All functions returned some primitive or pointer type (original C couldn't return struct, and C still can't return array); if you didn't specify a return type, it defaulted to int. The/each caller could either use or ignore any type of function value. If a function had no meaningful value to return, the convention was to default the type to int but not execute any 'return expr' statement and the caller didn't use the invalid value. Being only a convention the compiler(s) couldn't catch bugs here. - in C89, type void was added, and it became a constraint violation (and mandatory diagnostic) to use 'return expr' in a void function, or for a caller to use a 'void' return. But it was allowed to use 'return /*noexpr*/' in a nonvoid function as long as all callers didn't use the invalid value. In C99 'return /*noexpr*/ became c.v. also, but it is still permitted to return by 'falling off the end' which in a nonvoid function returns bogus; better compilers warn for this. - in *C++*, which is *not* a superset of C although it comes close enough to fool many people, you can 'return expr' in a void function *if* the expression has type void (and necessarily no value). This allows writing generics that work equally for void and other(?) types; that isn't useful very often, but sometimes it is. > > An exception is PL/I. > > Due to it origins PL/I is the one of a very few language that more > language words. And in PL/I there is no "Reserved words." All words > can be use for any purpose, an and example of a legal statement is, > It's true PL/I keywords aren't reserved, and this can be badly abused as in your example. I don't understand what 'very few language that more language words' means. If you mean PL/I has very many keywords, not so; I'd guess COBOL has easily twice as many, and COBOL *does* reserve them, so with each revision (and expansion) of the standard people had to change now-illegal identifiers in their programs. Ada has roughly as many as PL/I, although Ada's are more carefully chosen. I'd bet even SQL has more keywords than PL/I, although SQL has a syntax to un-keyword something you want as an identifier. And modern Fortran (>=90 and especially >=03) has probably about as many keywords as PL/I, also unreserved (and sometimes context-limited).