!standard A.5.2(29) 11-11-12 AI05-0280-1/01 !class binding interpretation 11-11-12 !status Amendment 2012 11-11-11 !status ARG Approved 9-0-0 11-11-11 !status work item 11-11-09 !status received 11-09-28 !priority Low !difficulty Easy !qualifier Omission !subject Behavior of Random.Reset with default initialized State !summary The implicit initial value of the type State is such that it will set a generator to the implicit initial value used for all generators. !question The packages Ada.Numerics.Float_Random and Ada.Numerics.Discrete_Random have the following procedures; procedure Save (Gen : in Generator; To_State : out State); and procedure Reset (Gen : in Generator; From_State : in State); The intent is that one must call Save first to save the State of the random number generator, and then one can restore the state using the Reset call. What happens if Reset is called, without having previously called Save, to save the state? That is, if From_State is default initialized? !recommendation (See summary.) !wording Add to the end of A.5.2(29): The implicit initial value of type State corresponds to the implicit initial value of all generators. !discussion The default value for State can be set using default expressions or (if it is a scalar or array type), with one of the new Ada 2012 Default_Value/Default_Component_Value aspects. There is a slight chance that this new requirement would cause an inconsistency in a program, but only if the compiler initialized these to something else useful, and the program depended upon that initialization. Both parts of this seem unlikely (its much more likely that the compiler simply left these uninitialized, which would not be useful), and any such usage surely would not have been portable to other compilers. !corrigendum A.5.2(29) @drepl An object of the private type State can be used to hold the internal state of a generator. Such objects are only needed if the application is designed to save and restore generator states or to examine or manufacture them. @dby An object of the private type State can be used to hold the internal state of a generator. Such objects are only needed if the application is designed to save and restore generator states or to examine or manufacture them. The implicit initial value of type State corresponds to the implicit initial value of all generators. !ACATS Test An ACATS C-Test should be created to check that State is initialized. This is fairly low priority, however. (The main reason it is important is that it reflects a change, and a test would tell if implementations did indeed make the change.) !ASIS No ASIS impact. !appendix !topic Behavior unclear if Ada.Numerics.???_Random.Reset is called with default initialized State. !reference Ada 2005 RM/A.5.2(12, 35)/ !from /Brad Moore 11-09-27/ !keywords Random Number Generation !discussion The packages Ada.Numerics.Float_Random and Ada.Numerics.Discrete_Random have the following procedures; *procedure* Save (Gen : *in* Generator; To_State : *out* State); and *procedure* Reset (Gen : *in* Generator; From_State : *in* State); The intent is that one must call Save first to save the State of the random number generate, and the one can restore the state using the Reset call. What happens if Reset is called, without having previously called Save, to save the state. ie. From_State is default initialized? The RM does not specify the behaviour. Would this be equivalent to the time-dependent Reset procedure? Does an exception get raised? Should this be specified? ****************************************************************