home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / docs / misc / old / gnatchat.2 < prev    next >
Encoding:
Text File  |  1996-04-29  |  43.2 KB  |  817 lines

  1. Administrative note: The preferred address for submission of comments is
  2. gnat-chat@cs.nyu.edu. We fiddle things so that gnat-world is essentially an
  3. alias for gnat-chat so that replies do not automaticaly go to the gnat-world
  4. list. This list has hundreds of names, growing daily, and we prefer not to
  5. have it turn into an email free-for-all, which is why the only output channel
  6. is us generating abstracted and referenced comments. Later on, we think the
  7. best thing will be to establish an unmoderated internet newsgroup for GNAT
  8. that will allow free discussion of problems etc. The time to do this seems
  9. to us to be when we make the first release (not so far away, as we constantly
  10. remind ourselves!)
  11.  
  12. Reference: GC-2.1
  13. Date: 24 Apr 1993
  14. Author: Stephen M. Youndt (hacker!steve@uunet.UU.NET)
  15. Subject: GNAT Library model
  16. References: GNOTE1, April 12
  17.  
  18.  >Regarding the "one file-one object" model of GNAT, I think you're mistaken
  19.  >in the level of acceptance you expect. You may not be aware, but many Ada
  20.  >programmers have grown to expect that the library system will allow them to
  21.  >do certain things. One example that I can think of now is having two files
  22.  >with different names, containing the source, slightly different, to the
  23.  >same compilation unit(s). One compilation unit might contain stubbed out
  24.  >procedures to talk to devices that don't exist on the development machine,
  25.  >and the other would contain the full up device control routines.
  26.  
  27.  Robert Dewar replies
  28.  
  29.    Well there are actually three points here. First the issue of one source
  30.    file to one object. That seems pretty much irrelevant. Ada systems differ
  31.    widely on how many objects are produced for a program. Some existing systems
  32.    generate one object module per Ada *program* (i.e. one giant object module
  33.    for the whole program), whereas some generate object files at a granularity
  34.    even smaller than a compilation unit. Especially if you take Steve's view
  35.    that the compilation engine is a black box, the number of object modules
  36.    is irrelevant. Where it is relevant is when Ada speaks to the rest of the
  37.    world. In the GNAT world, we quite expect a program to be composed of C
  38.    and Ada freely mixed together with a make file controlling the whole program
  39.    and in this situation a single object per source file is useful and natural.
  40.  
  41.    Now what I thought might actually be under discussion was the restriction
  42.    to a single compilation unit per file, although the example actually has
  43.    nothing to do with that. Still let me address it since at least nominally
  44.    it is relevant to the point. Many Ada style guidelines in any case require
  45.    this approach, and in some Ada systems, notably Rational, there isn't any
  46.    existing concept of multiple CU's per file. The question is, do people
  47.    really use this and is it important to support? The limitation is not
  48.    actually inherent to our approach, and we could certainly relax it. I had
  49.    hoped that Steve's note might give some examples but actually it really
  50.    doesn't address this issue at all. Any one else out there want to put in
  51.    an oar saying "AARGH! I can't do without multiple units per file!"?
  52.  
  53.    Now let's address the example in Steve's comment, which has nothing to do
  54.    with one object per source, or one unit per file, but rather with the
  55.    default naming restriction that requires unit and file names to match.
  56.    In his example, we have multiple implementations of the same unit, with
  57.    the desired unit to be selected at compile time, or possibly, in the case
  58.    of a body, at bind time. There are several possible approaches in the GNAT
  59.    environment for handling this, and in a given situation one would want to
  60.    choose and codify an approach that makes sense.
  61.  
  62.      1.  Call the files by different names, and then rename the file to be
  63.          compiled. This is obviously suitable only on a small scale. It's
  64.      what we do in GNAT itself for the small number of situations of this
  65.      kind (e.g. we have two implementations of the body of package Osint,
  66.      the operating system interface, and we call then osintds.ada and
  67.      osintux.ada for DOS and Unix, and then rename the appropriate one
  68.      to osint for compilation).
  69.  
  70.      2.  The different files can live in different directories, and then the
  71.      search path selects the appropriate directory. This is quite
  72.      convenient if you have a whole collection of files that is specialized
  73.      to an environment.
  74.  
  75.      3.  A file name directory can be used. Remember that this mechanism allows
  76.      arbitrary mapping of unit names to file names. The selection of the
  77.      appropriate files to be compiled is then a matter of selecting the
  78.      proper file name directory, which is simply a text file that gives
  79.      the names of the source files.
  80.  
  81.    There are a number of other possible approaches, but these three probably
  82.    cover the ground in practice. Note that similar management issues arise
  83.    when you have multiple header files in a C environment.
  84.  
  85.    Note that I don't mention the general Adalib mechanism, because basically
  86.    we regard that as a kludge with so many undesirable characteristics that
  87.    we think most users should avoid it. In particular for the given example,
  88.    the single library approach results in the semantics that the version you
  89.    get depends on which version was compiled most recently. That sounds very
  90.    error prone in a distributed development environment.
  91.  
  92.  >Granted, you propose a partial solution, in wrapping GNAT in shell scripts
  93.  >and such that make use of an AdaLib subdirectory, but I think it needs to
  94.  >go a bit farther. Most Ada programmers I have met have very little under-
  95.  >standing of the machines they're running on, and a freindlier APSE is
  96.  >definitely a plus when dealing with these people.
  97.  
  98.    We don't really think of the AdaLib subdirecttory as a solution, partial or
  99.    otherwise, but rather it's just a demonstration that arbitrary semantics
  100.    can be achieved. Since the semantics of the AdaLib approach seem to us
  101.    undesirable (e.g. it replicates the undesirable behavior of conventional
  102.    Ada library systems where if you happen to have two units of the same name,
  103.    then the later compiled one is taken, and it also allows the creation of
  104.    programs for which no consistent source exists. We certainly don't want to
  105.    disallow it (there is no way we could), but we certainly don't want to
  106.    suggest its use.
  107.  
  108.  >Additionally, if the AdaLib approach is not implemented up front, the idea
  109.  >of compiling "into" a library that many shops have become dependent on
  110.  >goes out the window. Within my company (GTE Government Systems) we tend to
  111.  >organize our source code in directory trees made up of what we call CSCIs
  112.  >(Computer Software Configuration Items), which corresponds to a single
  113.  >"system", a complete program or set of programs to do a given task. These
  114.  >CSCIs are broken up into lower level components that are logically related,
  115.  >and given to a single group of programmers. On particularly large systems,
  116.  >these lower level components may in turn be broken up into smaller units,
  117.  >and this happens again and again until the size of a given component is
  118.  >manageable by a small group of people (typically 2 or 3). The idea of
  119.  >compiling into a black box master library is very important to this sort
  120.  >of setup. Once all the components are in place, a single responsible
  121.  >person will link the program(s) and carry on to the testing phase.
  122.  
  123.    A lot of this comment is in the category of "we've always done things that
  124.    way, and that's the way we want to do things". In a sense you can't answer
  125.    this because you can't tell people what they think. However, looking
  126.    objectively at the description of the environment, it seems to me to fit
  127.    perfectly well into our scheme. In particular, the whole discussion of
  128.    the source tree arrangement makes perfect sense, and since in our system
  129.    the structure of the library mirrors the structure of the source (since
  130.    in a sense the source *is* the library), my guess is that once our scheme
  131.    is fully understood, it will certainly work better than "a library". Indeed
  132.    most Ada vendors have found that the idea of a single library just plain
  133.    doesn't work, and have had to implement various multi-library systems.
  134.    Since sources can be arranged hierarchically and spread out across networks
  135.    and multiple file systems etc, you could say that GNAT automatically has
  136.    the notion of a distributed library which can have either a hierarchical
  137.    or network structure (the latter coming from the use of links).
  138.  
  139.    As to the specific issue of compiling into a black box library and having
  140.    someone else do the link etc., this also seems to fit perfectly well into
  141.    our scheme. The generated objects can be placed into a separate directory,
  142.    and then the binder and linker is run from this directory (remember that
  143.    the binder references *only* the object modules).
  144.  
  145.    Finally, as Gnote1 points out, the shell script can recreate the black box
  146.    monolithic library for those who want it. I really don't understand the
  147.    point that if we don't somehow enforce this (in our view undesirable)
  148.    choice of approaches, then it is "out of the window". If people chuck it
  149.    out of the window, fine, we expect them to. If people like this approach
  150.    they can use it, no problem!
  151.  
  152.  >I don't believe this sort of organization is all that unusual within the
  153.  >Ada industry, and an APSE similar to those in use for the last 10 years
  154.  >is vital to its continuation. It's great that C programmers won't find
  155.  >GNAT unusual, but C programmers probably won't use GNAT. Ada programmers
  156.  >will, but only of if it looks like an Ada development environment,
  157.  >not a C environment. If your purpose is to see GNAT used, it needs to
  158.  >look like a traditional system, even if it isn't. Most Ada programmers
  159.  >couldn't care less what the compiler does in the background. They just
  160.  >want it to act as they expect.
  161.  
  162.    If GNAT only finds an audience among current Ada users then it is a total
  163.    failure, and a pointless excercise in waste of tax payers money. The whole
  164.    idea is to expand the use of Ada and in particular to provide a vehicle
  165.    which is suitable for research purposes which need the availability of the
  166.    source code. I hope (and believe) that you are quite wrong in your
  167.    estimation on this point!
  168.  
  169.    As to the idea that Ada programmers will only use GNAT if it looks like
  170.    a traditional environment to them, I think this overstates the issue, but
  171.    there certainly are difficulties in moving to any new system. One of the
  172.    problems is that in practice Ada environments look very different from one
  173.    another and this problem of having to rethink how to do things when moving
  174.    from say the Alsys model of multi-libraries to the Telesoft one is quite
  175.    tricky (yes I know they are the same company now, but at least for the
  176.    moment, they still have two ways of solving this problem!) Similarly, moving
  177.    to the Rational environment can be quite a shock if you are determined to do
  178.    things exactly as you have always done them.
  179.  
  180.    If you absolutely insist on maintaining your current working practices,
  181.    completely unchanged, then your obvious choice is to continue using the Ada
  182.    compilation system that you are used to using!
  183.  
  184.  >Now that I've completed this treatise, somebody is bound to tell me to
  185.  >put up or shut up. Fine, I'm willing to work to make GNAT what I need.
  186.  
  187.    Well we are certainly not going to tell you to shut up--the whole point of
  188.    this mailing list is to encourage comments of this kind, and it's
  189.    particularly useful to get input of the form "what you're doing won't
  190.    work for our problems". On the other hand, "putting up" is certainly welcome.
  191.    putting up by all means. In particular, more detailed scenarios of what
  192.    you and others are doing, and the descriptions of the problems you are
  193.    addressing in terms of program structure are very relevant and useful. We
  194.    are not particularly oriented to solving these problems in exactly the same
  195.    way as existing Ada systems, but we do want to be sure that we have workable
  196.    and hopefully superior solutions.
  197.  
  198.  >Just tell me who I need to talk to. :-)
  199.  
  200.    You're talking to the right people, this is where the action is!
  201.  
  202. Reference: GC-2.2
  203. Date: 28 Apr 1993
  204. Author: Wolfgang Polak (wp@pocs.com)
  205. Subject: GNAT Library model
  206. References: GNOTE1, April 12
  207.  
  208.  >Your library design looks very nice. A minor point came to mind while
  209.  >reading. In outlining the "traditional" way it looks like you've
  210.  >thought in the same direction. Instead of requiring additional shell
  211.  >sripts, why not
  212.  >
  213.  > - Have an option for the compiler to rewrite the source (if error-free)
  214.  >   with the proper name (possibly into a different directory).
  215.  >
  216.  > - Make this option work for multiple units in a single file.
  217.  >
  218.  >This would allow Ada programmers to use their old ways and would
  219.  >simplify importing of existing code. One can even choose to either
  220.  >continue development with the old source structure (I may use
  221.  >another ada compiler on the same sources) or the new ones.
  222.  
  223. Robert Dewar replies
  224.  
  225.    The important thing to realize is that GNAT is not an Ada compiler, rather
  226.    it is an Ada front end for GCC, together with necessary enhancements so
  227.    that GCC supports the semantics of Ada. That means that we have to fit into
  228.    the structure of the GCC driver, which certainly does not accomodate writing
  229.    source files, and is committed to only generating a single call to the
  230.    assembler per invocation, and hence a single object file. That's why we need
  231.    to accomplish this with external means.
  232.  
  233.    In any case, we really don't want to encourage the "traditional" monolithic
  234.    library approach, since we think it has severe flaws, but we do of course
  235.    want to allow it. We feel that if w provide appropriate utilities and
  236.    scripts, then from a programmer's view it doesn't make much difference
  237.    whether you are running a shell script called gnat, or gcc itself directly.
  238.  
  239.    Generally we expect most Ada compilations to be run via a make utility in
  240.    any case, so in practice, the user is unlikely to interact directly with
  241.    either the compiler or the shell script.
  242.  
  243.    Regarding source structures, see my note at the end of this issue.
  244.  
  245. Reference: GC-2.3
  246. Date: 28 Apr 1993
  247. Author: Wolfgang Polak (wp@pocs.com)
  248. Subject: GNAT Library model
  249. References: GNOTE1, April 12
  250.  
  251.  >As you predicted, the approach taken (with regard to not preserving the
  252.  >results of some compilations) seems a bit radical. Although the potential
  253.  >exists for better optimization across compilation units, the question
  254.  >of general efficiency with normal use is a major concern.
  255.  
  256.  >I think the approach should quickly be studied from a performance
  257.  >point of view. The claims of the GNote (Dated: April 12,1993):
  258.  
  259.   >> ...                          It's not at all clear that rereading and
  260.   >> recompiling the source is less efficient than writing and reading back in
  261.   >> these trees.
  262.  
  263.  >need to be substantiated.  Clearly, all current implementations have
  264.  >taken a different approach and this seems like unnecessary risk.
  265.  >Especially the subunit issue which is stated to be a SEPARATE  :-)
  266.  >decision should be treated as an option.  I believe the TeleSoft
  267.  >compiler had the ability to defer code generation until bind-time
  268.  >but it was an optimization option that was only expected to be used
  269.  >infrequently because of efficiency concerns.    It may be valuable to
  270.  >find out how much benefit they were able to gain with this type of
  271.  >optimization.  Although I believe their approach took advantage of
  272.  >all library units, not just subunits.  With the introduction of
  273.  >child packages in 9x, is it likely that use of subunits will increase?
  274.  
  275. Robert Dewar replies:
  276.  
  277.   Well of course you can't get really good figures on performance until you
  278.   have something like a finished product. Our preliminary testing indicates
  279.   that we are on the right track, compared to existing Ada compilers, from
  280.   a performance point of view. You should also realize that my experience
  281.   comes from the land of fast compilers (the Realia COBOL compiler for the
  282.   PC compiles at over 100,000 lines per minute, producing very high quality
  283.   code, and the syntax checker I wrote in assembler parsers Ada at over
  284.   three million lines a minute on my PC (55,000 lines in 0.9 seconds), that
  285.   figure includes system I/O (from a disk cache), scanning and parsing). The
  286.   performance of existing Ada compilers is dismal by these kind of standards.
  287.   Now our goal is not specially to build an outstandlingly fast compiler, but
  288.   rather that it should be reasonably fast. We'll see! See also the discussion
  289.   in GC-2.6.
  290.  
  291.  >My overall point is that it seems the project may be taking
  292.  >unnecessary risk by adopting this policy. Although GNAT may come
  293.  >close to "C" performance in re-reading specs, the recompilation of bodies
  294.  >required by generics, inline subprograms, and subunits will almost certainly
  295.  >exact a serious performance penalty.
  296.  
  297. Robert Dewar comments:
  298.  
  299.   Actually I think of this decision as a risk reduction approach, since it
  300.   completely eliminates a very tricky and error prone part of the compiler
  301.   (namely the writing and reading of trees). How do I know it's tricky and
  302.   error prone -- well I wrote this code, in preliminary form, before we
  303.   decided on our current approach!
  304.  
  305.   One thing to realize is that there is nothing fundamental in our decision
  306.   to recompile the sources. We could perfectly well write out the trees and
  307.   read them back in if we wanted to write the code to do this. The only
  308.   disadvantage would be that the compiler would have to read object files,
  309.   which is peculiar in the GCC environment.
  310.  
  311.   Phrases like "serious performance penalty" don't mean much in the absense
  312.   of quantitative data. Ada compiler users are used to extremely slow
  313.   compilers, so the concern is not surprising I suppose!
  314.  
  315.   The concern about recompiling bodies is a natural one, but remember that
  316.   here too, a "traditional" compiler would have to reread the trees for these
  317.   bodies, and these trees can be giant (often a factor of several bigger than
  318.   the source, and as anyone who has written fast compilers knows, system
  319.   I/O is a major part of compilation time).
  320.  
  321.   As for subunits, it is important to realize that this really is a major
  322.   risk reduction step. In order to do true separate compilation of subunits,
  323.   we would have to make radical changes to the structure of the GCC back end,
  324.   since it has no concept of compiling nested procedures where the context
  325.   is in a different object file. For example, there is no way that the inner
  326.   procedure could know stack offsets in the outer procedure, so probably we
  327.   would have to do our own stack layout, but that would really break things.
  328.   Not only is the required work on GCC substantial, but it is not clear that
  329.   it would be within the acceptable range of modification (remember that there
  330.   is only one GCC backend, and we can make necessary modifications for Ada,
  331.   but not at the expense of introducing significant instability).
  332.  
  333.   Actually, our initial inclination was to indefintely postpone the
  334.   implementation of subunits, precisely because we couldn't figure out
  335.   how to solve some of the difficulties involved. The approach we are
  336.   taking now makes the implementation of subunits trivial and also has
  337.   the side effect of generating better code than would be possible with
  338.   any separate compilation approach. The only downside is increased
  339.   compilation time. It's interesting to note that Tony Hoare recently
  340.   observed that with current fast processors the whole idea of separate
  341.   compilation should be rethought. We aren't going quite that far, although
  342.   we have considered an option that lets the whole program be compiled
  343.   together. Note that the MIPS C compiler has always had this option (to
  344.   permit inter-procedural optimization).
  345.  
  346.  >I am also a little concerned
  347.  >that one or more "killer" commercial applications will come along
  348.  >that will have a nice Ada interface (with generics) that will exclude
  349.  >GNAT users because of the need to have source for the bodies. Although you
  350.  >say that holding back source is not it the spirit of GNU, the reality
  351.  >is this is the common practice and GNAT users will suffer because
  352.  >of the lack of access to these products. Vendors of reusable libraries
  353.  >are likely to comment that GNAT is "broken". ... Could be a problem!
  354.  
  355. Robert Dewar comments:
  356.  
  357.   Maybe in the commercial world, the distribution of compiler specific
  358.   Ada libraries in object form only is common practice (I don't know, I
  359.   never saw such a product!) However in the academic/research world, which
  360.   is the target community for GNAT, the common practice is to distribute
  361.   source.
  362.  
  363.   If a commercial manufacturer came along and wanted to distribute secure
  364.   source for GNAT, the easiest thing would be to encrypt the source, and
  365.   then add a decryption circuit in the compiler. Of course this can be
  366.   subverted, but with the kind of knowledge that comes from having the
  367.   source of the compiler, distributing things in internal tree form would
  368.   not protect the integrity of the source in any case.
  369.  
  370.  >----------------------------------------------------------------------
  371.  >Questions:
  372.  
  373.  
  374.  >A) Around or about line 383 the note states:
  375.  >
  376.  >>>  Bodies of packages containing either inlined subprograms that are called,
  377.  >>>    of generic bodies that are instantiated.
  378.  >    ^^
  379.  >  Should this be "or"
  380.  
  381.    Yes, thanks! (it's useful to have typos pointed out!)
  382.  
  383.  >B) On a different topic: how will exception propagation be done?
  384.  >Is it planned to generate tables that will reduce the non-exception
  385.  >case overhead, or to use predominately run-time generated structers.
  386.  
  387.    We will shortly be releasing GNOTE2 which outlines our approach to
  388.    exception handling. Yes, we are planning to reduce the non-exception
  389.    case overhead as far as possible, and an interesting aspect of the
  390.    design is that the exception handler is language-independent (i.e. our
  391.    GCC exception handler knows nothing special about Ada).
  392.  
  393.  >Good luck,
  394.  >  Tom Griest
  395.  
  396.    Thanks!
  397.  
  398. Reference: GC-2.4
  399. Date: 29 Apr 1993
  400. Author: Sy Wong
  401. Subject: Names of files
  402. References: GNOTE1, April 12
  403.  
  404.  >I assume GNAT uses limited filename lengths for a particular OS. For NT and
  405.  >OS/2, the filenames can be 256 which is longer than most Ada compiler
  406.  >filename length limits. How can I get some early release source to see the
  407.  >problems in transporting to OS/2?
  408.  
  409. Robert replies:
  410.  
  411.   On any given system, a file name length will introduce some restrictions
  412.   in unit names and deeply nested subunits or child units. If the restriction
  413.   is severe, there are two possible reactions:
  414.  
  415.     Live with rather short package names at the library level. This is what
  416.     we are currently doing, at least on a short term basis, for GNAT, since
  417.     we are doing bootstrapping compilations under DOS.
  418.  
  419.     Use a file name directory, this removes all name length restrictions
  420.  
  421.   We are not releasing any sources prior to the initial release of the system
  422.   in June (they are simply much too fluid at the moment). However, don't worry
  423.   about "transporting to OS/2" -- since OS/2 is one of our primary targets
  424.   (it's at the moment the only stable home of GCC on the PC!)
  425.  
  426.  >On many Ada Repository (SIMTEL 20) files the files extensions of .ads, .adb,
  427.  >.sep, .ada (for procedure) seems to be used. The .ada on VAX I recall allows
  428.  >compilations commands to omit writing .ada and seems to be not very
  429.  >satisfactory. An often encountered bad example:
  430.  > very_long_common_part_a-few-unique-characters.ada.
  431.  >This makes converting repository files to be manipulated on DOS extremely
  432.  >difficult. May be you can spell out some recommended rules for truncation
  433.  >between old OS and newer OSs.
  434.  
  435.   Well the problem of short DOS file names is not exactly a GNAT-specific
  436.   problem. We do allow any choice of distinguishing extensions, so if any
  437.   one is using this kind of approach for choosing file names, then things
  438.   are smooth. In general if you are acquiring a structure of Ada file names
  439.   from a foreign source to use with GNAT, it will often be most appropriate
  440.   to use the file name directory approach. We'll provide a little tool for
  441.   constructing these directory files from an existing set of sources.
  442.  
  443.  >  As an example of another such switch, consider the switch in GNAT which
  444.  >  specifies the character set to be used for identifiers. The 9X RM requires
  445.  >  that the standard mode allow only Latin-1 letters in identifiers, however,
  446.  >  it quite explicitly suggests that other modes might be appropriate,
  447.  >  depending on local character set usage....
  448.  >  ......... In GNAT, we have a switch with the current settings:
  449.  >
  450.  >    1  Latin-1
  451.  >    ....
  452.  >    5  IBM PC
  453.  >    6  Allow all possible upper half ASCII characters
  454.  >    7  Allow no upper half ASCII characters (like Ada-83)
  455.  >
  456.  >  The default is Latin-1, except on PC's where the default is IBM PC. Of
  457.  >  course if anyone ever tried to validate GNAT (we have no current intention
  458.  >  of doing so, and it's not part of our project), then of course they would
  459.  >  have to specify Latin-1 as part of the validation switch choice.
  460.  
  461.  >It is a pleasant surprise to see options 5,6,7 in GNAT.
  462.  >
  463.  >By IBM PC means ALL 256 character or that is option 6? I expect all the
  464.  >upper set will be allowed but not C0 non-format-effecter characters. If this
  465.  >surmise is correct, then options 5 and 6 will be indistinguishable if punning
  466.  >is used.
  467.  
  468. Robert Dewar replies:
  469.  
  470.   The surmise is incorrect. The PC mode allows only upper half characters that
  471.   correspond to letters on the PC, with appropriate upper/lower case
  472.   equivalence. For example, the character that you get by typing Alt-130,
  473.   whose code is 16#82# is a lower case e-acute and is allowed in identifiers
  474.   as is the character you get by typing Alt-144 (16#90#) which is upper case
  475.   E-acute, and these letters are case equivalent. On the other hand, if you
  476.   type Alt-242, that's a plus-or-minus sign, and it's not allowed in
  477.   identifiers in mode 5. Roughly the idea in mode 5 is that you type valid
  478.   identifier names with allowed Latin-1 type graphics in the normal PC style,
  479.   and as long as you stay on the PC everything works as you expect. Of course,
  480.   as is to be expected with any localization option, you will run into trouble
  481.   trying to port the source program to non-PC environments without doing
  482.   a character conversion.
  483.  
  484.   This means that mode 5 and mode 6 are quite different, because in mode 6,
  485.   any old upper half character is allowed in identifiers, and no case
  486.   equivalence is assumed. As Sy Wong has pointed out, this is useful in
  487.   dealing with some encoding methods for Chinese character sets and similar
  488.   approaches, but of course sources that take advantage of this may be even
  489.   harder to port!
  490.  
  491.  >Is validation rule such that any of local character set including 5 and 6
  492.  >will be acceptable as long as latin-1 is included as default or option.
  493.  
  494.   OF COURSE! That's the point I had hoped to make absolutely clear in my
  495.   original note. Furthermore this has always been the case in Ada 83. To
  496.   validate, you need a compiler which, when run with a set of options which
  497.   is documented in the VSR (validation status report), implements exactly
  498.   the Ada semantics as required by the validation suite.
  499.  
  500.  >p.s. I hope my earlier question with regard to Erhard's MUST have body
  501.  >statement and GNAT's must NOT have body contradiction has an obvious answer.
  502.  
  503.   Sy, I never got your earlier note, but see GC-2.8 for a discussion of
  504.   this issue. It is a place where Ada 9X thinking is undergoing some changes.
  505.  
  506. Reference: GC-2.5
  507. Date: 28 Apr 1993
  508. Author: Fred Roeber (fjr@ssd.ray.com)
  509. Subject: GNAT Library model
  510. References: GNOTE1 (Apr 12)
  511.  
  512.  >I got the document fine. I went through it. I am really impressed
  513.  >by the design approach you guys are taking. The fact that shared code
  514.  >generics are not supported was about the biggest problem I saw since that
  515.  >directly impacts executable code size which is constrained in many cases.
  516.  >The fact that subunits are recompiled in a block didn't bother me too much
  517.  >since with most existing compilers it is more efficient to do that anyway
  518.  >for the majority of the cases. Having to reparse the source for all
  519.  >dependent packages is a concern but is a reasonable tradeoff of processor
  520.  >power against ease of development. People may want to change their coding
  521.  >practices as a result of it. Our normal approach is to embed all the
  522.  >descriptive documentation for functions in the package spec since that is
  523.  >where their public interface is defined. Thus, the specs have a lot of
  524.  >extra comments in them that would slow parsing under your scheme. Anyway,
  525.  >keep up the good work on everything. Fred
  526.  
  527. Robert replies:
  528.  
  529.   Don't be too quick to change your coding practices. What is important is not
  530.   some abstract impression of what performance might be, but the actuality of
  531.   the performance. For example, the current GNAT scans and parses comment lines
  532.   on a PC at well over a million lines a minute. This means that even if your
  533.   specs contain a 50,000 lines of extra documentation, you are only talking
  534.   about adding 3 seconds of compilation time. Furthermore, many tree structures
  535.   such as Diana store the comments in the tree anyway, and it is almost
  536.   certainly the case that reading in such trees is slower than reading in the
  537.   source, since really the parsing of comments is I/O limited.
  538.  
  539.   We realize that there are ways of using virtual memory addresses to read in
  540.   only the part of the tree that is needed, but this is likely to add a
  541.   significant amount of overhead to the entire compilation process.
  542.  
  543.   With regard to shared generics, there is nothing in our approach that is
  544.   inconsistent with shared generics. Indeed if anything they fit in more
  545.   smoothly, since a generic unit would then generate a single object file
  546.   in a completely familiar manner. Our decision not to do shared generics
  547.   initially has nothing to do with the library design, and everything to do
  548.   with the inherent difficulties in implementing shared generics. In fact
  549.   before we got so radical in our design that we got to the point of allowing
  550.   generic macro expansion to be used *without* creating dependencies that
  551.   limit expressive power, we were quite drawn to shared generics, since they
  552.   fit the model better than inline expansion!
  553.  
  554. Reference: GC-2.6
  555. Date: 28 Apr 1993
  556. Author: Ian Wand (ian.wand @jrc.it)  [Ian is on sabbatical in Italy!]
  557. Subject: GNAT Library model
  558. References: GNOTE1 (Apr 12)
  559.  
  560.   ADA LIBRARY MECHANISMS
  561.  
  562.  >Your recent mailings about the library mechanisms have been most
  563.  >interesting. In many ways the GNAT decisions are similar to
  564.  >those we implemented 7-8 years ago for the York compiler
  565.  >(for Ada 83), which was subsequently validated for VAX,
  566.  >SUN and various Clipper-based machine (and we also
  567.  >have other versions, including one for the RS6000). The compiler is still
  568.  >available commercially from Intergraph. We have used it for teaching
  569.  >for the last 6 years.
  570.  
  571.  >Essentially we tried to implement a system as compatible as possible
  572.  >with existing UNIX/C usage: we resisted the closed Ada world favoured by
  573.  >most implementors. Conventional UNIX tools are used for manipulating
  574.  >files (rm, etc) and make is used to build complete systems. However
  575.  >the system is not as radical as yours. We don't implement (i.e. we ignore)
  576.  >INLINE.
  577.  
  578. Robert comments:
  579.  
  580.   The nice thing about implementing inline is that we can do inline generic
  581.   instantiations by macro expansion *without* restricting expressive power.
  582.  
  583.  >In summary:
  584.  >
  585.  >1. We do have a small text file "ADA-LIBRARY" that contains:
  586.  >
  587.  >    name
  588.  >    file name
  589.  >    the time it was compiled
  590.  >    the kind of unit - subprogram spec, package body etc.
  591.  >    the kind of subunit if applicable
  592.  >    whether it is a generic, an instantiation, obsolete
  593.  >    a list of units it depends on
  594.  >    a list of stubs if applicable
  595.  >      for subunits, the parent's name
  596.  >
  597.  > No further information is saved for the unit.
  598.  
  599. Robert Dewar comments:
  600.  
  601.   As Ian notes, we have basically followed the same line of thinking, but
  602.   taken it to a more radical conclusion. In particular, we avoided the notion
  603.   of a central library file, and information that is required about a unit
  604.   goes in the object file. The most notable single difference is that we base
  605.   our consistency checks on the source files, so the time of compilation is
  606.   completely irrelevant. To make this clear, consider the effect of
  607.   recompiling a source that has not been modified when there is no need to
  608.   do so. In conventional Ada systems, this would force recompilation of all
  609.   dependent units. In our system, nothing at all would happen with respect
  610.   to previously compiled dependent units. If you want the effect of forcing
  611.   recompilation of all sources depending on source BLA, then in GNAT you
  612.   would simply "touch BLA" to update its time stamp.
  613.  
  614.  >2. The front end of the compiler reparses and builds the compiler
  615.  >   data structures for each unit named in a with clause.
  616.  >   This gives a uniform treatment of all units in the compiler at the
  617.  >   expense of rebuilding each time from the source code (it gets cheaper
  618.  >   as processor power goes up, but disc access times remain roughly the same).
  619.  >   I am convinced this was the correct decision.  In early experiments
  620.  >   we found that a "flattened" form of our internal data structure was
  621.  >   up to ten times the size of the source it represented: the rebuilding
  622.  >   time was often comparable with the time taken to recalculate the
  623.  >   internal data structure from source.
  624.  
  625.    This is the point at which our approaches are essentially identical. It is
  626.    encouraging to have some past data based on experimentation in a different
  627.    environment which confirms that our decision is reasonable. This should
  628.    at least encourage the skeptics (those worrying about efficiency) to take
  629.    a wait and see attitude.
  630.  
  631.  
  632.  >3. The Ada library file is used by the compiler to note and find units, and
  633.  >   by a tiny Ada loader (Ald) to ascertain the object files that will be
  634.  >   needed to make a final executable program.  The standard UNIX loader is
  635.  >   used to make the final object program.
  636.  
  637.    As desribed in GNOTE1, our normal method of finding units is to use an
  638.    algorithm that connects unit names and file names. However, we also allow
  639.    the use of a unit/file name directory file that functions in this respect
  640.    much like the York library file.
  641.  
  642.    The equivalent of Ald, is what we call our binder, which is incidentally
  643.    also a tiny program. It gets its information from what we call the ADL
  644.    files, one of which is generated for each object file, and in fact we
  645.    hope on most systems that the ADL file can merely be a section of
  646.    foreign text living inside the object file, so that from a users point
  647.    of view there is only an object file.
  648.  
  649.  >4. The compiler will deal with multiple units per file, but it "prefers"
  650.  >   single units in each file. We use extensions .H for specs, .A for
  651.  >   bodies, and .O and .o for their corresponding object code.
  652.  
  653.    The current implementation of GNAT allows use of any nmaing scheme based
  654.    on suffixes and/or separate extensions for source files. We only generate
  655.    one object file for a combined spec/body combination, so we don't need
  656.    two extensions for this purpose (see also discussion in GC-2.8.
  657.  
  658.  >5. Search paths can be set up using flags (just like C) for library sharing.
  659.  
  660.  >6. A tool "adep" constructs a make file that can be used to maintain
  661.  >   a complete Ada program.
  662.  
  663.    Reasonable, we plan to do the same.
  664.  
  665.  >However, unlike you, we do separately compile subunits.  We thought that
  666.  >efficiency problems would mandate this approach.  Furthermore we insist
  667.  >on seeing a complete generic before compiling any instantiation (which
  668.  >is done by macro expansion - we decided, after much debate, against
  669.  >the option of providing linkage code for each generic and with a
  670.  >single copy of the body).
  671.  
  672.    As previously noted, the decision on subunits is not particularly mandated
  673.    by our library approach, but by other considerations. We'll see how the
  674.    compilation efficiency issues shape up. One advantage we have over you is
  675.    that machines have got faster since you started your work!
  676.  
  677.  >The system has been used to build some very large systems (during testing).
  678.  >The largest system we compiled was made up of 50 separate libraries,
  679.  >involving 2500 units and several million lines of source. This compiled in
  680.  >about 15 hours on an Intergraph workstation (somewhat faster than many other
  681.  >systems we have heard about!).
  682.  
  683.    Encouraging! One point is that we certainly do not thing of GNAT as a toy
  684.    that can only compile small programs. Even in the academic/research setting
  685.    there are many giant programming projects around for which we intend GNAT
  686.    to be suitable.
  687.  
  688. Reference: GC-2.7
  689. Date: 28 Apr 1993
  690. Author: Robert Dewar
  691. Subject: GNAT Library model, object file generation
  692. References: GNOTE1 (Apr 12)
  693.  
  694.   In this note, which is basically an addendum to GNOTE1, I add our thinking
  695.   about generation of object files.
  696.  
  697.   The basic decision is that when you have a spec and body of a package or
  698.   subprogram, only one object file is generated, from the compilation of the
  699.   body (remember that the compilation of the body in any case involves the
  700.   compilation of the spec, so that all the necessary code for both the spec
  701.   and body can be generated at that time).
  702.  
  703.   A consequence of this approach is that it is not in general *necessary* to
  704.   compile specs separately at all. However, in practice it will often be
  705.   useful to be able to compile specs for syntax/semantic checking purposes,
  706.   to make sure they are OK before letting clients much with them, and of
  707.   course GNAT permits such checking compilations, just as it permits similar
  708.   compilations of subunits on their own for checking purposes.
  709.  
  710.   The case of packages with no bodies is broken down into three subcases:
  711.  
  712.     1.    If package bodies are always required (the current 9X proposal, almost
  713.     certain to be changed to 2, if it has not already been so changed)
  714.  
  715.       In this case the issue of packages with no bodies does not arise, you
  716.       won't be able to even try to compile them generating code.
  717.  
  718.     2.    If package bodies are forbidden for packages that in Ada 83 would not
  719.     require a body. This is the likely decision in Ada 9X according to
  720.     current thinking.
  721.  
  722.       In this case you know at the time of compiling a spec that there will be
  723.       no body, and you generate the required (single) object file for the
  724.       package as a result of compiling the spec. Compilation of the spec in
  725.       this case is required (at least it's required in general when there is
  726.       elaboration required -- interesting thought, should we at least for
  727.       pre-elaborable packages *not* require it to be compiled?)
  728.  
  729.       If there is an attempt to compile a body in such a case it is a fatal
  730.       semantic error which prevents generation of an object file in any case.
  731.  
  732.     3.    In the Ada 83 case, a package body is truly optional in some cases
  733.  
  734.       We aren't committed to supporting full Ada 83, but we do have an Ada 83
  735.       switch and we take the attitude that we will use it where it isn't too
  736.       much trouble to give the 83 semantics. A little surprisingly, the
  737.       infamous optional Ada 83 packages turn out to be such a case.
  738.  
  739.       Suppose in Ada 83 mode we compile a package spec that does not require
  740.       a body. Well, as in Ada 9X, we generate an object file for the spec
  741.       (the conditions for allowing an optional body in 83, and forbidding
  742.       a body in 9X under assumption of approach 2 are identical, so this isn't
  743.       even a case where we need to test the 9X flag.
  744.  
  745.       Now suppose we compile the body, well we test the Ada 83 switch, and
  746.       allow the compilation to proceed normally if it is set (avoiding the
  747.       9X diagnostic that the body is not allowed). The compilation produces
  748.       an object file that contains the required code for both the spec and
  749.       the body, as usual, and overrides the object file for the spec.
  750.  
  751.       Now suppose we reedit and recompile the spec. Well this compilation
  752.       outputs another object file that obliterates the previous object file
  753.       that contained the body code, and we have faithfully reproduced the
  754.       required (and horrible) semantics of Ada 83, where such a compilation
  755.       silently causes the body to be lost.
  756.  
  757.   For subunits, we will generate a single object module that corresponds to
  758.   the entire subunit tree.
  759.  
  760.   As mentioned previously, we will probably also have a switch that requests
  761.   that the entire program be compiled as a single unit, allowing additional
  762.   inter-module optimizations, such as inter-module inline expansion even if
  763.   pragma Inline is not used.
  764.  
  765. Reference: GC-2.8
  766. Date: 28 Apr 1993
  767. Author: Robert Dewar
  768. Subject: GNAT Library model, multiple units per file
  769. References: GNOTE1 (Apr 12), GC-2.1, GC-2.2
  770.  
  771.   Revisiting the issue of allowing multiple units per file, we could take
  772.   any of the following three approaches:
  773.  
  774.     1.    The current approach, one unit per file period.
  775.  
  776.     2.    Allow multiple units per file in the following specific circumstances.
  777.  
  778.        Spec and body in the same file (happens especially in 83 mode when
  779.        you have a trivial body and want to document this fact in the spec)
  780.  
  781.        Subunits in same file as parent (seems a bit strange to some, but
  782.        actually is more common than you think, reflects a top-down
  783.        programming style that wants the presentation, but not necessarily
  784.        the separate compilation) afforded by subunits.
  785.  
  786.     3.    Allow multiple units per file if a file name directory is used (this
  787.     would work almost automatically by just having multiple entries that
  788.     map multiple units to the same file name).
  789.  
  790.   Options 2 and 3 are not hard to implement. The attraction of option 1 is
  791.   simplicity.
  792.  
  793.   Option 2 is definitely irregular, and thus a bit confusing to describe. It
  794.   is motivated by a guess as to the most common cases of actually using the
  795.   ability to have multiple units in a file. Furthermore it of course fits fine
  796.   into our library approach, since the bodies/subunits are never with'ed
  797.   separately.
  798.  
  799.   Option 3 is fairly easy to implement. It perhaps is also fairly easy to
  800.   describe. After all there is a general rule:
  801.  
  802.     The file name must match (i.e. be derivable) from the unit name
  803.  
  804.   If one is using standard suffixes or extensions to form file names, then it
  805.   is a natural context of this rule that you can't have more than one unit in
  806.   a file, since they have to have separate names, and thus would map to
  807.   separate file names. If on the other hand you were using a file name
  808.   directory file, then it falls out pretty smoothly to allow this. One
  809.   annoying complication is dealing with an attempted recompilation of the
  810.   same unit more than once in a single file. Ada 9X allows this to be rejected,
  811.   and we would certainly want to reject it, but it makes for a complication in
  812.   the rules.
  813.  
  814.   This is an area in which we really would like input. On the one hand we want
  815.   to be as flexible as possible. On the other hand, we don't want to introduce
  816.   unnecessary complexity into the system. Thoughts anyone?
  817.