comp.lang.ada
 help / color / mirror / Atom feed
From: David Thompson <dave.thompson2@verizon.net>
Subject: Re: [OT] interesting reason why a language is considered good
Date: Sun, 13 May 2012 00:14:01 -0400
Date: 2012-05-13T00:14:01-04:00	[thread overview]
Message-ID: <k2duq7p9b387pokhgvvmlr0n53jmhvoupf@4ax.com> (raw)
In-Reply-To: jmkp3b$bol$1@speranza.aioe.org

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 <value>" 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 <G>) 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).




      reply	other threads:[~2012-05-13  4:14 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-15 10:27 [OT] interesting reason why a language is considered good Nasser M. Abbasi
2012-04-15 11:57 ` J-P. Rosen
2012-04-16 10:37   ` Peter C. Chapin
2012-04-15 12:27 ` Dmitry A. Kazakov
2012-04-17  6:59   ` tonyg
2012-04-17  7:43     ` Dmitry A. Kazakov
2012-04-15 14:05 ` Bill Findlay
2012-04-15 14:21 ` Pascal Obry
2012-04-15 14:54   ` Simon Wright
2012-04-15 15:34     ` Pascal Obry
2012-04-17  5:42       ` Brad Moore
2012-04-17 16:11         ` Simon Wright
2012-04-17 16:33           ` Robert A Duff
2012-04-17 19:34             ` Simon Wright
2012-04-17 21:42               ` Robert A Duff
2012-04-17 22:24                 ` Randy Brukardt
2012-04-18  7:00                   ` stefan-lucks
2012-04-17 21:17             ` Jeffrey Carter
2012-04-15 23:53     ` Brian Drummond
2012-04-16 10:43 ` Marius Amado-Alves
2012-04-16 11:48   ` Georg Bauhaus
2012-04-16 13:06     ` Dmitry A. Kazakov
2012-04-16 15:01       ` Georg Bauhaus
2012-04-16 15:31         ` Dmitry A. Kazakov
2012-04-16 17:11           ` Georg Bauhaus
2012-04-16 17:19             ` Georg Bauhaus
2012-04-16 18:00             ` Dmitry A. Kazakov
2012-04-16 21:48               ` Georg Bauhaus
2012-04-17  3:43                 ` Randy Brukardt
2012-04-17  4:43                   ` Bill Findlay
2012-04-17  7:46                   ` Georg Bauhaus
2012-04-17 22:32                     ` Randy Brukardt
2012-04-18  7:10                       ` stefan-lucks
2012-04-18 23:48                         ` Randy Brukardt
2012-04-19 14:22                           ` Shark8
2012-04-17 15:48                   ` Simon Wright
2012-04-17 16:15                     ` Dmitry A. Kazakov
2012-04-17 19:33                       ` Simon Wright
2012-04-17  7:34                 ` Dmitry A. Kazakov
2012-04-17 16:01                   ` Simon Wright
2012-04-17 17:42                   ` Georg Bauhaus
2012-04-17 19:17                     ` Dmitry A. Kazakov
2012-04-17  3:24           ` Randy Brukardt
2012-04-17  3:33           ` Randy Brukardt
2012-04-16 19:55   ` sbelmont700
2012-04-17  0:48   ` Peter C. Chapin
2012-04-17 21:59 ` anon
2012-05-13  4:14   ` David Thompson [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox