comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Ada standard and maximum line lengths
Date: Wed, 30 Jan 2013 11:18:38 +0200
Date: 2013-01-30T11:18:38+02:00	[thread overview]
Message-ID: <ams6reFdfsdU1@mid.individual.net> (raw)
In-Reply-To: <51085776$0$6637$9b4e6d93@newsspool2.arcor-online.net>

On 13-01-30 01:12 , Georg Bauhaus wrote:
> On 29.01.13 20:54, Niklas Holsti wrote:
> 
> Upfront, my question was about the possible effects of
> enforcing shorter identifiers  on the programming
> profession.  I venture to read Robert Duff's recent post
> as: that is a tool/setting to put into programmers' hands
> if they want it, and otherwise there should be no limits.
> 
>>> Linker symbols reappear in source text.
>>
>> Show an example, please, where it is necessary to write a linker symbol
>> verbatim as an Ada identifier.
> 
> Sure. I'll assume that the subject of good lengths of identifiers
> shouldn't be argued in a stick-to-the-letter (200) fashion.
> 
> You have mentioned old Fortran's 6 characters, so lets go crazy
> and start with doubling this, twice, to 24 characters per identifier.
> 
> This is from Win32Ada:
> 
>   function CreateDialogIndirectParamW
> 
> Ouch. 26 characters. You have mentioned that 32 is uncomfortable,
> so 24 certainly is more uncomfortable. Still, the Win32 bindings
> show that most programmers want these foreign names to be just
> like the originals. So, there is a need to not impose a lower
> bound that excludes unchanged Win32 identifiers.

I agree that one often wants Ada bindings to other-language libraries to
use the same, or similar, identifiers.

But these are *identifiers*, not linker symbols.

Are there some 200-character *identifiers* in the Win32 API? I doubt it.

> The issue is present both ways. Say, I export this to C++:

Sure. But since languages are different, it is often impossible to use
the same identifier. For example, Cobol allows identifiers with hyphens,
Calculate-Average-Salary, IIRC.

C++ has namespaces, which can be used to emulate Ada package scopes. A
harsher example would be exporting Ada subprograms for calling from a C
program. Typically, large C programs use abbreviated prefixes in
identifiers to simulate Ada packages or C++ namespaces.

> Chances are that a limit on lengths of C++ identifiers will require
> an assignment of a different exception identifier with the help
> of #pragma or __attribute__. There is no standard way to address
> this. *But*! There could be a standard way to address this, if
> the profession is offered an incentive to move away from library
> style name mangling.

I agree, in principle. In practice, there is probably not enough
language mixing going on, at least not mixing that requires portablity,
to make the effort motivated.

> Third, GNAT.
> 
> When GNAT started to support ISO/IEC 10646 ("universal characters"),
> GNAT's upper bound on identifier lengths had to be lifted. Even
> in the sense that line length implies identifier length: There
> are names in the Unicode character database that have made the
> source files exceeded GNAT's upper bound on line lengths (79).

What "upper bound" of 79? I've certainly compiled longer lines, even
with very early versions of GNAT. Is that limit in the GNAT style rules?

> A unicode character's name is not a linker symbol, but still it
> is a name from a "library" of characters that is "imported".

OK. Perhaps the Unicode character names should be organized into
packages rather than a flat namespace, but that can't be done if the
names must define an enumerated type.

Unicode is a good example of long identifiers, though. From
http://www.unicode.org/charts/charindex.html I compute that the longest
is/are 73 characters, counting blanks and commas. One of these
73-character names is "Bold Italic Greek Mathematical Symbols, Sans-serif".

>> But it has nothing to do with limits on identifier length in Ada.
> 
> Yes, it does: practical naming enforces a lower bound on names,
> as seen.

But only for convenience (to use similar names) and not close to 200
characters.

> But practically, names of imported subprograms import the risk of
> hitting _any_ (project or compiler) limit on identifier lengths
> when these foreign entities should not be renamed.

Of course it is better if an Ada compiler accepts lines of any length,
and identifiers of any length.

To summarize, I think this thread started by asking why the ARM mentions
maximum line length at all. The discussion has shown that:

- Ada 83 did not discuss line length or lexical-element length, so
compilers were in principle obliged to support any length, but perhaps
many compilers had limits motivated by "capacity limits".

- Ada 95 introduced the lower bounds of 200 characters on lines and
lexical elements. Perhaps they were not meant to be independent, and the
ACATS test require the compiler to support identifiers that are as long
as the longest possible line. Therefore, in practice compilers use the
same limit (if any) for both, if I understood Randy correctly.

- Janus/Ada has a limit of around 250 characters on identifier length,
which Randy would find "annoying" to remove.

- The longest real-life identifier exhibited so far is from the Unicode
character names and is 73 characters.

The second question, posed by George, was:

> I wonder what will be the effect on working in the
> programming profession of a general limit on line
> lengths that is, say, <= 100 characters:

Two people (Dmitry and I) came out in defense of short lines, that is, a
limit on 100 characters would not have any effect on our work.

J-P. reported that code he saw, written with a line-length limit of 72
characters, was horrible to read. On the other hand, some code that I
have written with an 80-char limit has been praised as easy to read, so
there are other factors that affect readability. And different readers
have different preferences, too.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .



  reply	other threads:[~2013-01-30  9:18 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-28  5:02 Ada standard and maximum line lengths Lucretia
2013-01-28  6:01 ` J-P. Rosen
2013-01-28  6:28 ` Jeffrey Carter
2013-01-28  8:05   ` Niklas Holsti
2013-01-28 16:42     ` Jeffrey Carter
2013-01-28 20:22       ` Niklas Holsti
2013-01-28 20:46         ` J-P. Rosen
2013-01-28 21:29           ` Niklas Holsti
2013-01-29  1:42             ` Randy Brukardt
2013-01-29  6:15             ` J-P. Rosen
2013-01-29 10:25               ` Niklas Holsti
2013-01-29 11:31                 ` Georg Bauhaus
2013-01-29 12:11                   ` Simon Wright
2013-01-29 12:31                   ` Niklas Holsti
2013-01-29 12:37                     ` Niklas Holsti
2013-01-29 15:29                     ` Georg Bauhaus
2013-01-29 16:58                       ` Niklas Holsti
2013-01-29 17:51                         ` Georg Bauhaus
2013-01-29 18:18                           ` Shark8
2013-01-29 19:54                           ` Niklas Holsti
2013-01-29 23:12                             ` Georg Bauhaus
2013-01-30  9:18                               ` Niklas Holsti [this message]
2013-01-30  9:51                                 ` Simon Wright
2013-01-30 15:28                                 ` Robert A Duff
2013-01-30 23:24                                   ` Randy Brukardt
2013-01-31  2:16                                     ` Robert A Duff
2013-01-31  9:10                                       ` Stefan.Lucks
2013-01-31  9:30                                         ` Niklas Holsti
2013-01-31  9:51                                           ` Simon Wright
2013-01-31 10:56                                           ` Georg Bauhaus
2013-01-31 18:02                                         ` Jeffrey Carter
2013-01-31 23:54                                       ` Randy Brukardt
2013-02-01  9:15                                         ` Niklas Holsti
2013-02-01 23:13                                           ` Randy Brukardt
2013-02-02  1:24                                             ` Lucretia
2013-02-02 14:12                                               ` Robert A Duff
2013-02-05  2:09                                               ` Randy Brukardt
2013-01-31  9:03                                   ` Dmitry A. Kazakov
2013-01-30  9:37                               ` Simon Wright
2013-01-30 12:02                                 ` Georg Bauhaus
2013-01-29 23:47                             ` Jeffrey Carter
2013-01-30  7:24                               ` Niklas Holsti
2013-01-30 10:09                                 ` J-P. Rosen
2013-01-29 20:36                 ` Niklas Holsti
2013-01-29 21:01                   ` Robert A Duff
2013-01-29 21:14                   ` Dmitry A. Kazakov
2013-01-28  8:18 ` Dmitry A. Kazakov
2013-01-28 10:02   ` Maciej Sobczak
2013-01-28 11:57     ` Georg Bauhaus
2013-01-28 13:28       ` Niklas Holsti
2013-01-28 15:14       ` J-P. Rosen
2013-01-28 16:13       ` Dmitry A. Kazakov
2013-01-28 15:13     ` Dmitry A. Kazakov
2013-01-28 13:49 ` Robert A Duff
2013-01-29  2:09   ` Randy Brukardt
2013-01-29 18:46 ` Lucretia
2013-01-29 20:53   ` Robert A Duff
2013-01-29 21:22   ` Dmitry A. Kazakov
2013-01-30  3:22     ` Lucretia
2013-01-30  9:49       ` Dmitry A. Kazakov
2013-01-30 23:28         ` Randy Brukardt
2013-02-01  1:48       ` Shark8
2013-01-29 21:29   ` Dmitry A. Kazakov
2013-01-29 21:53   ` Adam Beneschan
replies disabled

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