home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / docs / faq / prog / part4.dos / text0000.txt < prev   
Encoding:
Text File  |  1996-04-29  |  37.2 KB  |  870 lines

  1. Archive-name: computer-lang/Ada/programming/part4
  2. Comp-lang-ada-archive-name: programming/part4
  3. Posting-Frequency: monthly
  4. Last-modified: 28 February 1996
  5. Last-posted: 26 January 1996
  6.  
  7.                                Ada Programmer's
  8.                        Frequently Asked Questions (FAQ)
  9.  
  10.    IMPORTANT NOTE: No FAQ can substitute for real teaching and
  11.    documentation. There is an annotated list of Ada books in the
  12.    companion comp.lang.ada FAQ.
  13.  
  14. This is part 4 of a 4-part posting.
  15. Part 2 begins with question 5.
  16. Part 3 begins with question 6.
  17. Parts 1, 2, and 3 should be the previous postings in this thread.
  18.  
  19.     Recent changes to this FAQ are listed in the first section after the table
  20.     of contents (in part 1). This document is under explicit copyright.
  21.  
  22.  
  23. 9: Ada and Other Programming Languages
  24.  
  25.  
  26. 9.1: Where can I find programs that will translate from [some language] to
  27. Ada?
  28.  
  29.    It is generally advisable to simply interface from Ada to the
  30.    existing code segments that (should) already work. Note that Ada (95)
  31.    now has an annex devoted to specifying how to interface with code
  32.    written in other programming languages (C, Fotran, and Cobol), and
  33.    there are already interfaces to C++ too.
  34.  
  35.    Another option is to redesign the code, taking of course advantage of
  36.    one's knowledge of the current system. For instance, JobáHonig
  37.    reported that he did this twice, once for Coco, a parser generator for
  38.    LALR left attributed grammars, and once for Flex, the well known
  39.    scanner generator. Both attempts revealed errors in the original
  40.    software; they were uncovered by designing the new system using the
  41.    higher abstraction level allowed by Ada...
  42.  
  43.    So there is support for the requirements analysis (transition to Ada),
  44.    but it is not obvious that the proposed implementation (using a source
  45.    code translator) is a good solution.
  46.  
  47.    Still, you may have compelling reasons to translate your existing
  48.    source to Ada. In that case, here is a list of available translators:
  49.  
  50.      * Pascal to Ada:
  51.  
  52.        R.R. Software's Pastran program (Pascal to Ada Translator).
  53.  
  54.        To see the differences in programming style, see "Ada for
  55.        Experienced Programmers", by A. Nico Habermann and Dewayne E.
  56.        Perry (Addison-Wesley Pub. Co., Reading, Mass., 1983). Covers Ada
  57.        and Pascal.
  58.  
  59.      * Fortran to Ada: ???
  60.  
  61.      * COBOL to Ada: ???
  62.  
  63.      * C++ to Ada: ???
  64.  
  65.      * C to Ada: ???
  66.  
  67.      * Modula-2 to Ada:
  68.  
  69.        (from Wayne R. Lawton)
  70.        The Idaho National Engineering Laboratory (INEL), a Dept of Energy
  71.        Lab has a basic capability for Modula-2 to Ada-83. The tool is
  72.        "research grade" quality, but may provide a starting point for
  73.        what you need. This is the same group of people who brought you
  74.        AdaSAGE. Give them a ring at (208) 526-0656. This is an answer
  75.        desk hotline in the section that wrote the tool.
  76.  
  77.        If you are looking for commercial quality, I wish you the best of
  78.        luck. If you just need something to perform 80% of the grunt code
  79.        translation, I think this might meet your needs. I know of two
  80.        systems comprising about 250,000 lines of code that were
  81.        originally developed in Modula-2 then translated and cleaned up in
  82.        Ada 83 after Alsys 1.0 for the PC came out back around 1987.
  83.  
  84.      * Visual Basic to Ada: NOT! :-)
  85.  
  86.  
  87. 9.2: How can I convert Ada 83 sources to Ada 9X?
  88.  
  89.    First you should read the following document, which will provide you
  90.    with much useful information: "Changes to Ada -- 1987 to 1995", file
  91.    ch83.{ps,doc}, in directory
  92.    ftp://sw-eng.falls-church.va.us/public/AdaIC/standards/95lrm_rat/v6.0
  93.  
  94.  
  95.    If you're using GNAT, the tool you are probably looking for is
  96.    "gnatchop". In csh you could use something like this to quickly
  97.    process existing files:
  98.  
  99.      cd dest_dir                    # The destination directory
  100.      foreach f ( ../src_dir/*.a )   # ../src_dir is the source directory
  101.        gnatchop $f
  102.      end
  103.  
  104.    gnatchop will show you what sources are causing problems.
  105.  
  106.  
  107. 9.3: I hear that Ada is slower than Fortran or C, is that true?
  108.  
  109.    First, note that you are comparing compilers, not languages. There is
  110.    no such thing as "fast" Ada code any more than there is "fast" C++ or
  111.    Fortran code. Now, when comparing execution speeds on similar
  112.    platforms, you must keep in mind the optimization levels, OS tuning,
  113.    etc. while making the comparisons. The bottom line is that
  114.    benchmarking, especially between two different languages, requires
  115.    _very_ careful measurement. In general, such results should be viewed
  116.    with caution.
  117.  
  118.    (A message from Bevin Brett of DEC)
  119.  
  120.    I have been asked to comment on the relative performance of algorithms
  121.    coded in Ada and in Fortran.
  122.  
  123.    This question has come up repeatedly over the years, and deserves a
  124.    complete answer, rather than a simplistic one.
  125.  
  126.    There are many factors which influence the size and execution speed of
  127.    the running program, and they all play together to get a full answer.
  128.    I shall then discuss an exact Ada v. Fortran comparison that Digital
  129.    was involved in.
  130.  
  131.    First, a position statement: The variation between Ada and Fortran is
  132.    less than the variation within the language caused by the exact
  133.    implementation details. A person versed in the Ada issues should do as
  134.    well in Ada as a person versed in the Fortran issues will do in
  135.    Fortran. The size and execution speed of the result should be within a
  136.    few percent of each other.
  137.  
  138.    (a) Differences due to the compiler
  139.  
  140.    In the case of the DEC Ada and Fortran compilers, the optimizer and
  141.        code generator are the same. Never-the-less, the exact inputs into
  142.        the optimizer and code generator may differ slightly when the same
  143.        algorithm is compiled by the Ada and Fortran compilers, and this
  144.        can result in major differences in the generated code. In these
  145.        cases the compiler front ends can usually be modified to correct
  146.        the slower one.
  147.  
  148.        We have not observed any major differences in generated code
  149.        quality between the DEC Ada and DEC Fortran compilers caused by
  150.        such issues.
  151.  
  152.  
  153.    (b) Differences due to the language
  154.  
  155.    It is very important that the same algorithm be written in the two
  156.        languages. The biggest differences we have observed are
  157.          1. Having the wrong dimension varying fastest, since it is
  158.             desireable to have the first dimension changing fastest in
  159.             Fortran, and the last dimension in Ada. Thus when an
  160.             algorithm is transliterated, the array indexes must be
  161.             reversed.
  162.  
  163.          2. Using compile-time-known bounds for arrays in Fortran, and
  164.             using unconstrained arrays in the Ada code. Knowing the exact
  165.             values of the dimensions at compile-time results in much
  166.             better code.
  167.  
  168.          3. Not suppressing all the runtime checks in Ada. The Fortran
  169.             compiler assumes all array bounds are in range, and all
  170.             arithmetic operations do not overflow. You must use a pragma
  171.             Suppress to tell this to the Ada compiler as well.
  172.  
  173.          4. Don't use arrays of Ada Booleans to match arrays of Fortran
  174.             Integers, because accessing bytes on a RISC system might be
  175.             much worse than accessing fullwords.
  176.  
  177.  
  178.    (c) Differences due to the bindings
  179.  
  180.    The biggest bindings differences are related to Fortran's built-in
  181.        support for complex types, and for various math routines such as
  182.        SQRT and SIN, compared with Ada code that often uses hand-coded or
  183.        ISO standardised versions of these functions with different
  184.        requirements than are imposed on the Fortran versions.
  185.  
  186.        DEC Ada has built-in support for complex types, and also has
  187.        bindings directly to the same primitives that Fortran uses for its
  188.        math routines and so gets the same performance as Fortran does.
  189.  
  190.  
  191.    (d) Differences due to the author
  192.  
  193.    The use of good Ada and Fortran style can also effect the generated
  194.        code. Provided the author writes in good Ada style, and follows
  195.        the above guidelines, the generated code should do as well as
  196.        Fortran.
  197.  
  198.  
  199.     The Ada Performance Benchmark
  200.  
  201.    A DEC Ada customer had a Fortran benchmark that had been translated
  202.    into Ada without awareness of the above issues, and was running
  203.    substantially slower with DEC Ada than the original was with DEC
  204.    Fortran.
  205.  
  206.    Bevin Brett, a DEC Ada team member, developed the above guidelines in
  207.    the process of retranslating the code into Ada.
  208.  
  209.    Portions of this translation are shown here (a) as an illustration of
  210.    the application of the above rules, and (b) as an illustration of the
  211.    kind of operations that were present in the benchmark.
  212.  
  213.    The whole benchmark has not been provided to avoid possible issues of
  214.    ownership.
  215.  
  216.    The resulting Ada benchmark components each ran within a few percent
  217.    of their Fortran counterparts. The Ada code is available by FTP, in
  218.    file ftp://lglftp.epfl.ch/pub/Ada/FAQ/ada-vs-fortran.ada
  219.  
  220.  
  221. 9.4: Isn't Ada less "elegant" than Eiffel?
  222.  
  223.    While it is true that programming-language support for "assertions"
  224.    is an important contribution of Eiffel to software construction, this
  225.    is not an issue of "elegance", and there are many other important
  226.    factors to consider.
  227.  
  228.    Note also that preconditions and postconditions can be fairly easily
  229.    and efficiently included in Ada code. Invariants seem difficult to
  230.    emulate directly in Ada. If you're really interested in the formal use
  231.    of assertions with Ada, maybe Anna is a solution for you.
  232.  
  233.    (Tucker Taft comments)
  234.  
  235.    I guess one thing that bothers me a little is that people are quick to
  236.    say that Eiffel is "elegant" without really looking at it. I fear that
  237.    such statements will become self-fulfilling prophecies, with those
  238.    programmers interested in elegance migrating over to Eiffel rather
  239.    than sticking with Ada.
  240.  
  241.    In particular, although I like the assertion stuff in Eiffel, I think
  242.    the language has a number of "inelegant" aspects. For example:
  243.  
  244.     1. exception handlers only at the top level of a routine, with the
  245.        only way to "handle" an exception being by retrying the whole
  246.        routine.
  247.  
  248.     2. No way to return from a routine in the middle. This makes it a
  249.        pain in the neck to search through a list for something in a loop,
  250.        and then return immediately when you find what you want. (I have
  251.        never found the addition of extra boolean control variable a help
  252.        to the understanding of an algorithm.)
  253.  
  254.     3. Namespace control handled by a separate sublanguage, and no real
  255.        higher level concept of "module" or "subsystem."
  256.  
  257.     4. An obscure notation like "!!" being used for an important and
  258.        frequent operation (construction).
  259.  
  260.     5. No way to conveniently "use" another abstraction without
  261.        inheriting from it.
  262.  
  263.     6. No strong distinctions between integer types used for array
  264.        indexing.
  265.  
  266.     7. Using the same operator ":=" for both (aliasing) pointer
  267.        assignment, and for value assignment, depending on whether the
  268.        type is "expanded." (Simula's solution was far preferable, IMHO).
  269.  
  270.     And most critically:
  271.  
  272.  
  273.     8. No separate interface for an abstraction. You can view a interface
  274.        by running a tool, but this misses completely the importance of
  275.        having a physical module that represents the interface, and acts
  276.        as a contract between the specifier or user of an abstraction and
  277.        its implementor. In Eiffel, one might not even be truly aware when
  278.        one is changing the interface to an abstraction, because there is
  279.        no particular physical separation between interface and
  280.        implementation.
  281.  
  282.  
  283.    I consider many of the above problems quite serious, with some of them
  284.    being real throwbacks to the old style of programming languages where
  285.    there were no well defined interfaces or modules.
  286.  
  287.    Hence, I cringe a bit when people say that Eiffel is the "most
  288.    elegant" OOP and that they would use it if only it were practical to
  289.    do so. In many ways, I think Ada is much better human-engineered than
  290.    Eiffel, with important things like range constraints built into the
  291.    language in a way that makes them convenient to use. Although general
  292.    assertions are nice, they don't give you the kind of line-by-line
  293.    consistency checks that Ada can give you.
  294.  
  295.    To summarize --
  296.    Although Eiffel certainly has a number of nice features, I don't
  297.    consider it ready for prime time as far as building and maintaining
  298.    large systems with large numbers of programmers. And from a human
  299.    engineering point of view, I think Ada is significantly better.
  300.  
  301.  
  302. 9.5: Are there any papers detailing the differences between Ada and C++?
  303.  
  304.    Below are two references. Bear in mind that it is difficult to make
  305.    such a comparison without exposing biases. However, the two papers
  306.    below are well worth reading.
  307.  
  308.    "A Comparison of the OO features of Ada9x and C++" in Springer Lecture
  309.    Notes in CS: "Ada Europe 93" pp.125-141 (short paper, good reading,
  310.    enlightens idioms)
  311.  
  312.    ftp ajpo.sei.cmu.edu in directory: /public/ada9x, document:
  313.    9x_cplus.hlp
  314.  
  315.  
  316. 9.6: I keep hearing that Ada is a "strongly typed language", but it seems
  317. different from what's meant in C++. Are they different?
  318.  
  319.    (Tucker Taft responds)
  320.  
  321.    I certainly agree that ANSI C and C++ are statically typed languages,
  322.    but I would debate the "strength" of their typing.
  323.  
  324.    Essentially any support for implicit conversion (implicit "casting,"
  325.    "promotion", "usual" arithmetic conversions, etc.) "weakens" a type
  326.    system (but also makes it "friendlier" in some ways).
  327.  
  328.    C allows implicit conversion between all integer types and all
  329.    enumeration types. C++ at least cuts off implicit conversion to
  330.    enumeration types, but retains implicit conversion among all integer
  331.    (and floating-point) types. Also, in both C and C++, typedefs for
  332.    pointer/array types are essentially "macros"; all pointer types with
  333.    the same target type are implicitly interconvertible.
  334.  
  335.    Finally C++ allows the user to define a number of their own implicit
  336.    conversion operators, which basically allows the user to "weaken" the
  337.    type system as they see fit.
  338.  
  339.    Of course, all of this implicit conversion serves a purpose, but it
  340.    does tend to move C/C++ toward the "weaker" end of the weak vs. strong
  341.    typing spectrum.
  342.  
  343.    Note that the "strong" distinctions between integer types helps
  344.    dramatically in catching (at compile-time) array indexing errors in
  345.    Ada programs, by making sure that if you have an array indexed by a
  346.    count of apples, you don't index into it with a count of oranges
  347.    (without an *explicit* conversion). The advantages of "strongly"
  348.    distinguishing enumeration types is even more obvious (and the
  349.    designers of C++ recognized this).
  350.  
  351.    The strong distinctions between access types (pointer types) in Ada
  352.    also has advantages, allowing access types to be represented as
  353.    offsets within their storage pool rather than as addresses, and giving
  354.    more high-level control over storage management.
  355.  
  356.    Strong typing can be carried too far, and some amount of implicit
  357.    conversion is essential to make OOP palatable. But note that in Ada
  358.    9X, even with OOP, we don't allow implicit conversions that truncate
  359.    the extension part of a record (this is a relatively common mistake in
  360.    C++ when passing parameters by value). Instead, in Ada 9X, the
  361.    language distinguishes between a specific type T and the class-wide
  362.    type T'Class, and allows implicit conversions to T'Class from T or any
  363.    of its derivatives, but not to the specific type T. Conversions to the
  364.    class-wide type never implicitly truncate the extension part.
  365.    Conversions to a specific type can truncate, and hence must be
  366.    explicit.
  367.  
  368.    Note also that in Ada there are three distinct kinds of conversions,
  369.    implicit ones, explicit ones, and unchecked ones. Only the unchecked
  370.    ones are potentially unsafe. The explicit ones are safe, with either
  371.    compile-time or run-time checks to ensure that. In C there are only
  372.    implicit and explicit/unchecked conversions. C++ has recently added a
  373.    checked, explicit "dynamic" cast, but still it will be common to use
  374.    "normal" explicit casts for both checked and unchecked conversions,
  375.    thereby making it more difficult to identify places where the type
  376.    system might be compromised.
  377.  
  378.    Hence, the bottom line is that the type checking is (objectively)
  379.    "stronger" in Ada than C/C++, though that doesn't necessarily mean
  380.    "better" -- whether one is "better" for a particular style of
  381.    programming than the other is a "religious" issue IMHO. I know my
  382.    religion currently favors the stronger checking of Ada in most cases
  383.    [except perhaps for multiply/divide, where I personally believe the
  384.    checking should either be weaker, or directly support the concept of
  385.    "units"/"dimensions"].
  386.  
  387.  
  388. 9.7: I'm told Ada does all sorts of static type checking, but can't you get
  389. the same effect using a tool like "lint" with C?
  390.  
  391.    No, here are a few reasons why (this list is by no means complete):
  392.  
  393.    (Submitted by Norm Cohen)
  394.      * Running both Lint and a C compiler requires the program text to be
  395.        parsed and semantically analyzed twice. The results of an Ada
  396.        compiler's parse and semantic analysis are used directly in
  397.        performing consistency checks.
  398.  
  399.      * The rules of Ada provide the opportunity for stronger consistency
  400.        checks than are possible with C. For example, an Ada programmer
  401.        can declare distinct integer types to represent distinct
  402.        abstractions. An Ada compiler will catch an inadvertent
  403.        intermixing of these two types, but there is no way a
  404.        corresponding distinction can be made in C, so there is no way for
  405.        Lint to perform a corresponding check. Similarly, in C, a pointer
  406.        to an object of type T is indistinguishable from an array of
  407.        objects of type T.
  408.  
  409.      * The rules of the Ada language ensure that the program text
  410.        provides information allowing PRECISE consistency checks. For
  411.        example, the expression in an Ada case statement can be written to
  412.        have a static subtype, allowing the compiler to ascertain that all
  413.        possible values have been covered without resorting to a default
  414.        (when others) arm.
  415.  
  416.      * With lack of precise information, Lint has no choice but to be
  417.        overly pessimistic or, with different settings for a complicated
  418.        set of options, overly optimistic. When it is overly pessimistic,
  419.        the user sees too many "false alarms" and may end up ignoring
  420.        valid warnings. When it is overly optimistic, Lint overlooks
  421.        certain errors.
  422.  
  423.      * It is impossible to forget to run consistency checks when using an
  424.        Ada compiler. (Of course a C programming environment could be set
  425.        up so that the C compiler could only be invoked from a script that
  426.        also invokes Lint.)
  427.  
  428.      * A compilation that fails Ada consistency checks is rejected. A
  429.        compilation that fails Lint consistency checks may still be
  430.        compiled, and its object file used (intentionally or accidently)
  431.        in building the system. (One cannot automate the rejection of
  432.        programs that fail Lint unless one is certain that there will
  433.        never be any false warnings.)
  434.  
  435.      * Ada enforces consistency among separately compiled units.
  436.  
  437.  
  438.    Of course even stronger arguments can be made about Ada's RUN-TIME
  439.    checks (which can be used with little additional overhead because the
  440.    information contained in an Ada program and the knowledge that the
  441.    program has passed compile-time consistency checks make it possible to
  442.    optimize away the majority of the checks). These checks, which are
  443.    absent in C, tend to smoke out errors early by detecting internal
  444.    inconsistencies that might not otherwise be detected during testing.
  445.    This reduces the likelihood of fielding a system that appears to work
  446.    well during testing but fails in operational use.
  447.  
  448.  
  449. 9.8: Does Ada have something like the Standard Template Library (STL) in C++,
  450. or components like you find in Smalltalk environments?
  451.  
  452.    Yes, in various ways.
  453.  
  454.    Few components are part of the ISO standard. Ada 95 has an expanded
  455.    set of predefined library units, covering e.g. strings of varying- or
  456.    dynamic-length, elementary numerical functions, random number
  457.    generators, complex numbers, and more; in addition, the Special Needs
  458.    Annexes standardize many advanced services which have commonly been
  459.    provided by separate components in the past.
  460.  
  461.    A lot of free Ada software components are available from anonymous FTP
  462.    sites. There is also an upcoming release of the Booch Components for
  463.    Ada 95 under the GNU Library General Public License (LGPL); this will
  464.    give you the ability to freely include the library components in your
  465.    application without any cost or obligation. (Contact dweller@dfw.net
  466.    for more details.)
  467.  
  468.     What about STL and the Smalltalk library?
  469.  
  470.    The C++ STL doesn't contain much. Really. Breaking its source code
  471.    down, it contains less than 3000 semicolons (~7000 total lines). The
  472.    entire library exists in C++ header files as inlineable code
  473.    (supposedly within a few percent of the efficiency of hand-optimized
  474.    code).
  475.  
  476.    STL class hierarchy
  477.  
  478.      bool, heap     -- of course Ada does not need a bool class!
  479.       \ function, pair, stack
  480.          \ iterator, tempbuf, projection
  481.             \ algobase
  482.                \ algorithms, bitvector, deque, list, tree, vector
  483.                   \ map, multimap, set, multiset
  484.  
  485.  
  486.    The main author of the library, Alexander Stepanov, created the Ada
  487.    Generic Library in the 1980's -- and later borrowed from this to
  488.    create STL. (There is an interview with Stepanov in the March 1995
  489.    issue of Dr. Dobb's Journal -- in the C Programming column beginning
  490.    on page 115. Stepanov explains that these components were first done
  491.    in Ada.)
  492.  
  493.    The Smalltalk library is quite eclectic. It covers everything from
  494.    Boolean to bitmaps, dictionaries and other collections. Parts of it
  495.    have direct equivalents in Ada 95, parts are already available in
  496.    components from anonymous FTP sites and/or will be in the Booch Ada 95
  497.    components, and other parts are available from commercial Ada
  498.    component suppliers.
  499.  
  500.  
  501. 9.9: Where can I find the equivalent of "printf" in Ada?
  502.  
  503.    While the standard package Text_IO provides many features, the
  504.    request for a printf-like function is not unusual.
  505.  
  506.    (solution based on a suggestion by Tucker Taft)
  507.  
  508.    It is possible to produce a printf-like capability by overloading the
  509.    "&" operator to take an object of type Format and an object of some
  510.    type and return the Format, properly advanced, after having performed
  511.    the appropriate output. The remaining format can be converted back to
  512.    a string--e.g. to examine what is left at the end of the format
  513.    string-- or simply printed to display whatever remains at the end. For
  514.    example:
  515.  
  516.      with Text_IO;
  517.      package Formatted_Output is
  518.        type Format is
  519.          limited private;
  520.  
  521.        function Fmt (Str : String)
  522.          return Format;
  523.  
  524.        function "&" (Left : Format; Right : Integer)
  525.          return Format;
  526.        function "&" (Left : Format; Right : Float)
  527.          return Format;
  528.        function "&" (Left : Format; Right : String)
  529.          return Format;
  530.        ... -- other overloadings of "&"
  531.  
  532.        procedure Print (Fmt : Format);
  533.  
  534.        function To_String (Fmt : Format)
  535.          return String;
  536.  
  537.      private
  538.        ...
  539.      end Formatted_Output;
  540.  
  541.      with Formatted_Output; use Formatted_Output;
  542.      procedure Test is
  543.        X, Y : Float;
  544.      begin
  545.        Print (Fmt("%d * %d = %d\n") & X & Y & X*Y);
  546.      end Test;
  547.  
  548.    The private part and body of Formatted_Output are left as an exercise
  549.    for the reader ;-).
  550.  
  551.    A "File : File_Type" parameter could be added to an overloading of Fmt
  552.    if desired (to create something analogous to fprintf).
  553.  
  554.    This capability is analogous to that provided by the "<<" stream
  555.    operator of C++.
  556.  
  557.      _________________________________________________________________
  558.  
  559.  
  560. 10: Interfacing with Ada
  561.  
  562.  
  563. 10.1: I am writing software that used the Distributed Interactive Simulation
  564. (DIS) interface, does an interface exist in Ada?
  565.  
  566.    Yes. DIS is a standard for communications between simulators using an
  567.    Internet Protocol network (IP). DIS provides a unified virtual
  568.    environment for multiple simulator users on a network. It is used
  569.    mostly in the DoD simulations business, but it is applicable to ANY
  570.    simulation. It is an industry initiative involving military training
  571.    and procurement organisations, simulator vendors and universities
  572.    mostly in the US, but the technology is unclassified.
  573.  
  574.    The US Army is funding quite a bit of DIS research and development.
  575.    The Institute of Simulation and Training, URL
  576.    http://www.tiig.ist.ucf.edu/ is a center at the University of Central
  577.    Florida (UCF) which serves as the support contractor for the UCF IST,
  578.    as are BBS's for the DIS working groups who are attempting to push
  579.    those standards forward. The BBS contains an Ada binding for DIS.
  580.  
  581.    Note that the above provides a thin binding to C code. It may be
  582.    worthwhile to take the time to make high-level DIS bindings. Ted
  583.    Dennison, dennison@escmail.orl.mmc.com reports having done it (while
  584.    working for what is now Lockheed Martin Simulation Systems) in over 2
  585.    man-months using an experienced Ada engineer, and that it was well
  586.    worth it. Many bugs were found in the C DIS code of the machine they
  587.    were networked with. "A strongly-typed interface is the network
  588.    programmer's best friend."
  589.  
  590.    At TRI-Ada'94 there was a demonstration by Coleman Research
  591.    Corporation (CRC); here's their short pitch: "CRC presents Ada
  592.    VR-Link, the first commercially available DIS NIV. It provides all of
  593.    the facilities necessary to jump start your DIS compliant simulation
  594.    development efforts. For more information call (205) 922-6000."
  595.  
  596.    Also, the AJPO sponsored an Ada Technology Insertion Program (ATIP)
  597.    relating to this: FY93 ATIP project 17, titled "Ada Distributed
  598.    Interactive Simulation (ADIS)". Available from directory
  599.    ftp://sw-eng.falls-church.va.us/public/AdaIC/source-code/bindings
  600.        /ADIS-bindings
  601.  
  602.    The Ada Distributed Interactive Simulation (ADIS) provides an Ada
  603.    interface to the IEEE 1278 Distributed Interactive Simulation (DIS)
  604.    protocols. The project was developed in Ada 83 (MIL-STD-1815), on
  605.    Silicon Graphics Indigo R4000 machines using Verdix Ada 6.2.1 under
  606.    the IRIX operating system, version 5.2.  The Graphical User
  607.    Interfaces (GUIs) were developed for X Window version X11R5 using
  608.    Motif 1.2.
  609.  
  610.    There are several sources of information available on DIS itself. The
  611.    IEEE version of the DIS standard is available through (and only
  612.    through) the IEEE (std IEEE 1278). Draft versions of the standard are
  613.    available from the Institute for Simulation and Training at the
  614.    University of Central Florida. They take orders at (407) 855-0881, and
  615.    questions (about ordering) at (407) 658-5054.
  616.  
  617.  
  618. 10.2: Is there any support for Common Object Request Broker Architecture
  619. (CORBA) for Ada 9X?
  620.  
  621.    OC Systems sells a CORBA Ada product; it is "Standard equipment" with
  622.    their PowerAda compiler. Rational, and OIS are also planning on
  623.    selling CORBA products for Ada.
  624.  
  625.    Objective Interface Systems, Inc. (OIS), MITRE, and DISA have been
  626.    working on a mapping from CORBA IDL to Ada 95 for about six months.
  627.    Bill Beckwith (Bill.Beckwith@ois.com) will send a recent copy of the
  628.    mapping document to any interested parties.
  629.  
  630.    Note that CORBA IDL to Ada 95 mapping specifies a mapping, not a
  631.    binding. This will put Ada 95 on equal footing with the C++ and
  632.    Smalltalk products. (except that, of course, the Ada mapping is
  633.    cleaner ;-).
  634.  
  635.      _________________________________________________________________
  636.  
  637. 11: Finding Additional Information
  638.  
  639. 11.1: Where can I find Ada books?
  640.  
  641.    Look at the companion comp.lang.ada FAQ or the HBAP WWW Server, URL
  642.    http://lglwww.epfl.ch/Ada/
  643.  
  644.    Michael Feldman maintains the "Annotated Sampling of Ada-Oriented
  645.    Textbooks"; if you don't have access to WWW, drop him a note at
  646.    mfeldman@seas.gwu.edu
  647.  
  648.  
  649. 11.2: Are there other Ada-related FAQs?
  650.  
  651.    Yes. They all appear in comp.lang.ada at regular intervals:
  652.    comp.lang.ada FAQ, public Ada library FAQ, and Ada WWW server FAQ. All
  653.    these are permanently available in hypertext format from the HBAP WWW
  654.    Server (see below) and in ASCII format from
  655.    ftp://lglftp.epfl.ch/Ada/FAQ
  656.  
  657.  
  658. 11.3: What is the "HBAP WWW Server"?
  659.  
  660.    The Home of the Brave Ada Programmers (HBAP) WWW Server is alive and
  661.    heavily used. It is a hypertext, multimedia information server for the
  662.    Ada programming language.
  663.  
  664.    The URL of the HBAP WWW Server is
  665.  
  666.         http://lglwww.epfl.ch/Ada/
  667.  
  668.    [don't forget the trailing '/'.]
  669.  
  670.    The HBAP WWW Server provides Ada-related information and hypertext
  671.    access in areas including:
  672.      * Historical notes on Ada
  673.      * References
  674.      * Ada FAQs
  675.      * State of Ada 9X revision process
  676.      * Standards
  677.      * Bindings
  678.      * Tools and Components
  679.      * Intellectual Ammunition
  680.      * Introductory Material
  681.      * Resources
  682.      * CS Technical Reports
  683.      * FTP and WWW Sites--including mirror sites
  684.      * Calendar of Ada-related events
  685.      * Ada Today
  686.      * Frequently Asked Questions--with Answers (from comp.lang.ada)
  687.  
  688.  
  689.    For instance, you will find a list of schools using Ada in CS1 or CS2,
  690.    an article on commercial success stories, information about software
  691.    components, as well as hypertext versions of the Ada reference manual
  692.    (both 83 and draft 9X).
  693.  
  694.    The HBAP WWW Server keeps growing. All comments, ideas, and requests
  695.    for additions or corrections, are welcome (e-mail to
  696.    Magnus.Kempe@di.epfl.ch).
  697.  
  698.      _________________________________________________________________
  699.  
  700.  
  701. 12: Pretty-printing and Measuring Ada Source Code
  702.  
  703.  
  704. 12.1: Is there software that generates a pretty PostScript file from Ada
  705. source code?
  706.  
  707.    Pretty Ada code in PostScript means that e.g. reserved words are in
  708.    bold and comments are in italics. This is a separate issue from
  709.    re-formatting and automatic indenting.
  710.  
  711.    If you use the new Ada Mode for GNU Emacs (available from
  712.    ftp://cs.nyu.edu/pub/gnat), go and get the package ps-print.el from
  713.    any emacs archive (e.g. in directory
  714.    ftp://archive.cis.ohio-state.edu/pub/gnu/emacs/elisp-archive). With
  715.    this package you can print your code as you see it on the screen, say
  716.    with bold keywords and italic comments.
  717.  
  718.    Another possibility is to feed the source to "vgrind" (see below),
  719.    then pipe the result through "pscat" (to get PostScript) or "lpr -t"
  720.    (to print), e.g.:
  721.  
  722.      vgrind -d <vgrind_defs_file> -lada -o1- -t -w $* | lpr -t
  723.  
  724.  
  725. 12.2: I use vgrind to do "pretty printing" of my source. Is there a vgrind
  726. definition for Ada?
  727.  
  728.  
  729. # Ada!
  730. ada|Ada:\
  731.         :pb=(^\d?(procedure|function|package|package body))\d\p:\
  732.         :bb=if|case|begin|loop:be=end:\
  733.         :cb=--:ce=$:\
  734.         :sb=":se=":\
  735.         :lb=':le=':\
  736.         :id=_.:\
  737.         :oc:\
  738.         :kw=abort abs abstract accept access aliased all and array at\
  739.         begin body case constant declare delay delta digits do else\
  740.         elsif end entry exception exit for function generic goto if in is\
  741.         limited loop mod new not null of or others out package pragma\
  742.         private procedure protected raise range record rem renames requeue\
  743.         return reverse select separate subtype tagged task terminate then\
  744.         type until use when while with xor:
  745.  
  746.  
  747.    Note that the above has a problem with attributes, because the "lb"
  748.    and "le" terms make two-attributes-20-lines-apart look like one
  749.    "string literal." Ada 95 keywords are recognized.
  750.  
  751.    Here is another definition, which "fixes" this problem (not perfect,
  752.    but probably better). Only Ada 83 keywords are recognized.
  753.  
  754.  # In order to get the ticks to work, we are assuming that there will be
  755.  # whitespace before a literal (like '"') and *not* when used for an
  756.  # attribute (like 'Length).
  757.  # For sb/se, we are ALSO assuming that literals have whitespace before/after.
  758. Ada|ada:\
  759.         :pb=^\d?(procedure|function|package|package\dbody)\d\p:\
  760.         :bb=begin:be=end:\
  761.         :cb=--:ce=$:\
  762.         :sb=( |\t|\()":se="( |\t|;|,|\)):\
  763.         :lb=(>| |\t)':le='(\)| |\t|;):\
  764.         :tl:\
  765.         :oc:\
  766.         :kw=abort abs accept access all and array at begin body case constant\
  767.         declare delay delta digits do else elsif end entry exception exit for\
  768.         function generic goto if in is limited loop mod new not null of or\
  769.         others out package pragma private procedure raise range record rem\
  770.         renames return reverse select separate subtype task terminate then\
  771.         type use when while with xor:
  772.  
  773.  
  774. 12.3: How about a source code reformatter?
  775.  
  776.    If you can run a Perl script (Perl is freely available for almost
  777.    every OS in the world), you can use the program aimap, written by Tom
  778.    Quiggle of SGI. It can be found (where ???).
  779.  
  780.  
  781. 12.4: How can I count source lines of code (SLOC)?
  782.  
  783.    Under Unix and many operating systems (apparently even MS-DOS), the
  784.    following works well:
  785.  
  786.      wc -l file_name
  787.  
  788.  
  789.    If you only want to count "statement lines" (lines with semicolons),
  790.    use
  791.  
  792.      sed 's/--.*$//' file_name | grep ';' | wc -l
  793.  
  794.  
  795.    Some versions of grep have a '-c' option to print a count of the
  796.    matching lines, but this may not be universal. You can fold the
  797.    grepping into the sed command but that's not as readable:
  798.  
  799.      sed -n -e 's/--.*$//' -e '/;/p' file_name | wc -l
  800.  
  801.  
  802.    Please note that measuring SLOC should be used to indicate an
  803.    approximate relationship to the size of other projects, and as such,
  804.    provided that there is some uniformity in the form and number of
  805.    comments, it does not matter whether comments are counted or not. It
  806.    has often been observed that there is a very high correlation between
  807.    measurements of SLOC, semicolons, and Halstead bits (there is probably
  808.    also a high enough correlation with the number of characters).
  809.  
  810.    With VMS, try the following, which will print out the number of lines
  811.    ("records") and characters (use ";" instead of "~~~~~" to count lines
  812.    with semicolons; note that "records" will match even in comments):
  813.  
  814.      $ search/stat file_name.ada "~~~~~"
  815.  
  816.  
  817. 12.5: Can I measure other things?
  818.  
  819.    There is ASAP, the Ada Static Analyzer Program, written in Ada and
  820.    set up to compile under Dec Ada on a Vax running VMS. Gives SLOC,
  821.    McCabe's, and more. It is available via anonymous ftp in directory
  822.    ftp://ftp.sei.cmu.edu/pub/dd
  823.  
  824.  
  825.      _________________________________________________________________
  826.  
  827. 13: Credits
  828.  
  829.    The first draft was made by Dave Weller. The following persons have
  830.    contributed (directly or indirectly, intentionally or unintentionally,
  831.    through e.g. comp.lang.ada) to the information gathered in this FAQ:
  832.    TuckeráTaft, DaveáWeller, DavidáArno, ChristineáAusnit, BilláBeckwith,
  833.    MotiáBen-Ari, ChipáBennett, BevináBrett, DavidáBulman,
  834.    G.áVincentáCastellano, NormáCohen, MarináDavidáCondic, JohnáCosby,
  835.    RichardáCrutchfield, TheodoreáE.áDennison, RobertáDewar, BobáDuff,
  836.    RobertáEachus, RolfáEbert, DaveáEmery, MitcháGart, JeffreyáL.áGrover,
  837.    LaurentáGuerby, RichardáG.áHash, MatthewáHeaney, FergusáHenderson,
  838.    NiklasáHolsti, JobáHonig, JeanáD.áIchbiah, NasseráKettani,
  839.    WayneáR.áLawton, RobertáMartin, RobbáNebbe, JonathanáParker,
  840.    IsaacáPentinmaki, BruceáPetrick, PauláPukite, RichardáRiehle,
  841.    KeitháShillington, DavidáShochat, AndrΘáSpiegel, KeitháThompson,
  842.    JoyceáTokar, KevináWeise, DavidáA.áWheeler, FraseráWilson, and the
  843.    maintainer has simply :-) organized, polished, or added some
  844.    information for your satisfaction. The general HTML structure of this
  845.    FAQ was originally inspired by the (now differently structured) WWW
  846.    FAQ.
  847.  
  848.      _________________________________________________________________
  849.  
  850. 14: Copying this FAQ
  851.  
  852.    This FAQ is Copyright ⌐ 1994-1996 by Magnus Kempe. It may be freely
  853.    redistributed --as posted by the copyright holder in comp.lang.ada--
  854.    in other forums than Usenet News as long as it is completely
  855.    unmodified and that no attempt is made to restrict any recipient from
  856.    redistributing it on the same terms. It may not be sold or
  857.    incorporated into commercial documents without the explicit written
  858.    permission of the copyright holder.
  859.  
  860.    Permission is granted for this document to be made available under the
  861.    same conditions for file transfer from sites offering unrestricted
  862.    file transfer on the Internet and from Forums on e.g. Compuserve and
  863.    Bix.
  864.  
  865.    This document is provided as is, without any warranty.
  866.  
  867.      _________________________________________________________________
  868.  
  869.     Magnus Kempe -- Magnus.Kempe@di.epfl.ch
  870.