home *** CD-ROM | disk | FTP | other *** search
/ Programmer's ROM - The Computer Language Library / programmersrom.iso / ada / misc / tbd.ada < prev    next >
Encoding:
Text File  |  1988-05-03  |  12.9 KB  |  325 lines

  1. -------- SIMTEL20 Ada Software Repository Prologue ------------
  2. --                                                           -*
  3. -- Unit name    : TBD_PACKAGE                                -*
  4. -- Version      : 1.1                                        -*
  5. -- Author       : Bryce Bardin                               -*
  6. --                Ada Projects Section                       -*
  7. --                Software Engineering Division              -*
  8. --                Ground Systems Group                       -*
  9. --                Hughes Aircraft Company                    -*
  10. --                Fullerton, CA                              -*
  11. --                                                           -*
  12. --                                                           -*
  13. --                                                           -*
  14. -- DDN Address                                               -*
  15. -- Copyright    : (c) 1985                                   -*
  16. -- Date created :                                            -*
  17. -- Release date : 3 Dec 85                                   -*
  18. -- Last update  : 3 Dec 85                                   -*
  19. -- Machine/System Compiled/Run on :                          -*
  20. --         Vax 11/785   VMS 4.1    Dec-Ada                   -*
  21. ---------------------------------------------------------------
  22. --                                                           -*
  23. -- Keywords     : TBD_Package         
  24. ----------------:                                            -*
  25. --                                                           -*
  26. -- Abstract     :                                            -*
  27. ----------------:                                            -*
  28. --                                                           -*
  29. -- TBD  stands  for  "To  Be  Determined".   This package is -*
  30. -- intended  to  be  used  during design to aid in producing -*
  31. -- partial designs that are expressed in valid Ada.  It also -*
  32. -- may  be  used  advantageously  in  development  while the -*
  33. -- implementation is incomplete or in rapid prototyping.     -*
  34. --                                                           -*
  35. -- In   particular,  it  supplies  type  definitions,  range -*
  36. -- limits, and default values which may be used to assist in -*
  37. -- describing  unknown  or partially defined types, objects, -*
  38. -- and  values.   In  addition,  it supplies a place-holding -*
  39. -- procedure call.                                           -*
  40. --                                                           -*
  41. -- If  this  TBD_PACKAGE  is  used,  simple searches for the -*
  42. -- string "TBD"                                              -*
  43. -- may  be  used  to  find  many  places where the design is -*
  44. -- incomplete.                                               -*
  45. --                                                           -*
  46. -- N.B.:   The  types  defined here should be used to derive -*
  47. -- those used in the design, rather than being used directly -*
  48. -- (see  the  usage  given  below for examles of the style). -*
  49. --                                                           -*
  50. --                                                           -*
  51. ------------------ Revision history ---------------------------
  52. --                                                           -*
  53. -- DATE         VERSION    AUTHOR                  HISTORY      -*
  54. --                                                           -*
  55. ------------------ Distribution and Copyright -----------------
  56. --                                                           -*
  57. -- This prologue must be included  in  all  copies  of  this -* 
  58. -- software.                                                 -*
  59. --                                                           -*
  60. -- This software is copyright by the author.                 -*
  61. --                                                           -*
  62. -- This software is released to the Ada community.           -*
  63. -- This software is released to the Public Domain (note:     -*
  64. --   software released to the Public Domain is not subject   -*
  65. --   to copyright protection).                               -*
  66. -- Restrictions on use or distribution:  NONE                -*
  67. --                                                           -*
  68. ------------------ Disclaimer ---------------------------------
  69. --                                                             
  70. -- This software and its documentation are provided "AS IS"  
  71. -- and without any expressed or implied warranties whatsoever.
  72. -- No warranties as to performance, merchantability, or fitness
  73. -- for a particular purpose exist.
  74. --
  75. -- Because of the diversity of conditions and hardware under
  76. -- which this software may be used, no warranty of fitness for
  77. -- a particular purpose is offered.  The user is advised to
  78. -- test the software thoroughly before relying on it.  The user
  79. -- must assume the entire risk and liability of using this
  80. -- software.
  81. --
  82. -- In no event shall any person or organization of people be
  83. -- held responsible for any direct, indirect, consequential
  84. -- or inconsequential damages or lost profits.
  85. --                                                           
  86. -------------------END-PROLOGUE--------------------------------
  87. generic
  88.     type ITEM is private ;
  89.     VALUE : in ITEM ;
  90.  
  91. function TBD_VALUE return ITEM ;
  92.  
  93. function TBD_VALUE return ITEM is
  94. begin
  95.     return VALUE ;
  96. end TBD_VALUE;
  97.  
  98. with TBD_VALUE ;
  99. with SYSTEM ;
  100.  
  101. package TBD_PACKAGE is
  102.  
  103. --========================================================================
  104. --
  105. -- Author :   Bryce Bardin
  106. --            Ada Projects Section
  107. --            Software Engineering Division
  108. --            Ground Systems Group
  109. --            Hughes Aircraft Company
  110. --            Fullerton, CA
  111. --
  112. --========================================================================
  113.  
  114.     type TBD_TYPE is (TBD) ;
  115.  
  116. -- The following construct should rarely, if ever, be necessary.
  117.  
  118. -- For an arbitrary unknown type:
  119. --     type UNKNOWN is new TBD_TYPE ;
  120. --     ANONYMOUS : UNKNOWN := TBD ;
  121. --
  122. --------------------------------------------------------------------------
  123. --
  124. -- function TBD return INTEGER ;
  125.    function TBD is new TBD_VALUE ( INTEGER , 1 ) ;
  126. --
  127. -- function TBD return FLOAT ;
  128.    function TBD is new TBD_VALUE ( FLOAT , 1.0 ) ;
  129. --
  130. -- function TBD return BOOLEAN ;
  131.    function TBD is new TBD_VALUE ( BOOLEAN , TRUE ) ;
  132. --
  133. -- For an unknown value of any user-defined type, T:
  134. --    function TBD is new TBD_VALUE ( T , <value of type T> ) ;
  135. --    OBJECT : T := TBD ;
  136. --
  137. -- N.B.:  The usage of the predefined types INTEGER and FLOAT (which 
  138. -- are machine dependent) should, as a matter of policy, generally be
  139. -- avoided unless the usage is clearly portable (e.g., in small index
  140. -- ranges for loops).
  141. --
  142. -- For an unknown value of type INTEGER:
  143. --    INT : INTEGER := TBD ;
  144. --
  145. -- For an unknown value of type FLOAT:
  146. --    FLT : FLOAT := TBD ;
  147. -- 
  148. -- For an unknown value of type BOOLEAN;
  149. --    BOOL : BOOLEAN := TBD ;
  150. -- and
  151. --    if TBD then ... end if ;
  152. --
  153. --========================================================================
  154. --
  155. -- The constructs given below are recommended and will usually convey
  156. -- the abstraction desired more concisely and correctly.  The also
  157. -- are easily evolved into the required final form.
  158. --
  159. --========================================================================
  160.  
  161.     TBD_INT : constant := 1 ;
  162.  
  163.     TBD_REAL : constant := 1.0 ;
  164.  
  165.     TBD_FLT : constant := TBD_REAL ;  -- an alias
  166.  
  167.     TBD_FIX : constant := TBD_REAL ;  -- an alias
  168.  
  169. -- For unknown static integer values:
  170. --    type STATIC is range 0 .. TBD_INT ;
  171. --
  172. -- For unknown static real values:
  173. --    type IMMOBLE is digits 6 range 1.0 .. TBD_FLT ;
  174. --
  175. --------------------------------------------------------------------------
  176. --
  177. -- The smallest (most negative) integer possible:
  178.    TBD_MIN_INT : constant := SYSTEM.MIN_INT ;
  179. --
  180. -- The largest integer possible:
  181.    TBD_MAX_INT : constant := SYSTEM.MAX_INT ;
  182. --
  183. -- The largest range integer type possible:
  184.    type TBD_INTEGER is range TBD_MIN_INT .. TBD_MAX_INT ;
  185. --
  186. -- function TBD return TBD_INTEGER ;
  187.    function TBD is new TBD_VALUE ( TBD_INTEGER , 1 ) ;
  188. --
  189. --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
  190. --
  191. -- For an integer type of unknown range [case 1]:
  192. --   type MY_INTEGER is range TBD_MIN_INT .. TBD_MAX_INT ;
  193. --   type MY_POSITIVE is range 1 .. TBD_MAX_INT ;
  194. --
  195. -- N.B.:  Only integer literal values and named numbers are available.
  196. --   MINE : MY_INTEGER := 3 ;
  197. --   ME : MY_POSITIVE := TBD_INT ;
  198. --
  199. -- When the design is complete the form should be:
  200. --   type MY_INTEGER is range N .. M ;
  201. --
  202. --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
  203. --
  204. -- For an integer type of unknown range [case 2]:
  205. --   type UNKNOWN is new TBD_INTEGER [range TBD .. TBD] ;
  206. --
  207. -- N.B.:  Both TBD and integer literal values are available.
  208. --   INCOGNITO : UNKNOWN := TBD ;
  209. --   ANONYMOUS : UNKNOWN range 0 .. TBD := 1 ;
  210. --
  211. -- When the design is complete, the form should be:
  212. --   type UNKNOWN is range N .. M ;
  213. --   INCOGNITO : UNKNOWN := N ;
  214. --   ANONYMOUS : UNKNOWN range 0 .. M := 1 ;
  215. --
  216. --------------------------------------------------------------------------
  217. --
  218.      TBD_DIGITS : constant := SYSTEM.MAX_DIGITS ;
  219. --
  220. -- The most precise floating point type possible:
  221.    type TBD_FLOAT is digits TBD_DIGITS ;
  222. --
  223. -- function TBD return TBD_FLOAT ;
  224.    function TBD is new TBD_VALUE ( TBD_FLOAT , 1.0 ) ;
  225. --
  226. -- The largest floating point value possible :
  227.    TBD_MAX_FLT : constant := 2.0 ** TBD_FLOAT'SAFE_EMAX *
  228.        ( 1.0 -1.0 /2.0 ** TBD_FLOAT'MANTISSA ) ;
  229. --
  230. --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
  231. --
  232. -- For a floating-point type of unknown precision (and range) [case 1]:
  233. --    type YOUR_FLOAT is digits TBD_DIGITS
  234. --    [ range -TBD_MAX_FLT .. TBD_MAX_FLT ] ;
  235. --
  236. -- N.B.:  Only real literal values and named numbers are available.
  237. --    YOURS : YOUR_FLOAT range -TBD_MAX_FLT .. 100.0 := TBD_FLT ;
  238. --
  239. -- When the design is complete, the form shoud be :
  240. --    type YOUR_FLOAT is digits D [ range F .. L ]
  241. --    YOURS : YOUR_FLOAT range X .. Y := Z ;
  242. --
  243. --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
  244. --
  245. -- For a floating-point type of unknown precision (and range) [case 2]:
  246. --    type MY_FLOAT is new TBD_FLOAT ;
  247. --    [ range -TBD_MAX_FLT .. TBD_MAX_FLT ] ;
  248. --
  249. -- N.B.:  Both TBD and real literal values are available.
  250. --    MINE : MY_FLOAT := TBD ;
  251. --    YOURS : MY_FLOAT range 0.0 .. MY_FLOAT'LAST := 1.0 ;
  252. --
  253. -- When the design is complete, the form should be:
  254. --    type MY_FLOAT is digits D [ range F .. L ] ;
  255. --    MINE : MY_FLOAT := X ;
  256. --
  257. ------------------------------------------------------------------------
  258. --
  259.    TBD_DELTA : constant := 1.0 ;  -- arbitrary
  260. --
  261.    TBD_MAX_FIX : constant := 1.0 / SYSTEM.FINE_DELTA ;
  262. --
  263. -- The largest range fixed-point type with the given delta:  
  264.    type TBD_FIXED is delta TBD_DELTA range -TBD_MAX_FIX .. TBD_MAX_FIX ;
  265. --
  266. -- function TBD return TBD_FIXED ; 
  267.    function TBD is new TBD_VALUE ( TBD_FIXED , 1.0 ) ;
  268. --
  269. --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
  270. --
  271. -- For a fixed-point type of unknown precision (and range) [case 1]:
  272. --     type MY_FIXED is delta TBD_DELTA range -TBD_FIX .. TBD_MAX_FIX ;
  273. --
  274. -- N.B.:  Only real literal values and named numbers are available.
  275. --     MINE : MY_FIXED := 1.0 ;
  276. --     MY   : MY_FIXED range 1.0 .. TBD_MAX_FIX := TBD_FIX ;
  277. --
  278. -- When the design is complete, the form should be:
  279. --     type MY_FIXED is delta D range F .. L ;
  280. --
  281. -- --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  
  282. --
  283. -- For a fixed-point type of unknown precision and range [case 2]:
  284. --     type YOUR_FIXED is new TBD_FIXED [ delta TBD ] [ range TBD .. TBD ] ;
  285. --
  286. -- N.B.:  Both TBD and real literal values are available.
  287. --     YOURS : YOUR_FIXED := TBD ;
  288. --     YOU   : YOUR_FIXED range 0.0 .. TBD_MAX_FIX := 1.0 ;
  289. --
  290. -- When the design is complete, the form should be:
  291. --     type YOUR_FIXED is delta D range F .. L ;
  292. --
  293. --------------------------------------------------------------------------
  294. --
  295. -- For an enumeration type with unknown values:
  296. --     type MY_ENUM is (TBD) ;
  297. --     ENUM : MY_ENUM := TBD ;
  298. --
  299. -- For an enumeration type with some known and some unknown values:
  300. --     type UNCERTAIN is ( KNOWN , TBD ) ;
  301. --     AMBIGUOUS : UNCERTAIN := TBD :
  302. --
  303. --------------------------------------------------------------------------
  304. --
  305.    procedure TBD ;
  306. --
  307. -- For processing which is not yet defined:
  308. --     TBD ;
  309. --
  310. -- N.B.:  Don't use null statements for this purpose since they should
  311. -- be reserved for intentional null processing.
  312. --
  313. --------------------------------------------------------------------------
  314. end TBD_PACKAGE ;
  315.  
  316.  
  317. package body TBD_PACKAGE is 
  318.  
  319.     procedure TBD is
  320.         begin
  321.             null ;
  322.         end TBD ;
  323.  
  324. end TBD_PACKAGE ;
  325.