make-random-state: allow fixnum as the argument

This commit is contained in:
Daniel Kochmański 2016-08-04 10:32:18 +02:00
parent 691e77c3be
commit 86a591461c
3 changed files with 17 additions and 14 deletions

View file

@ -32,15 +32,15 @@
- make-random-state: fix problem with simple-vectors
The correct initialization types for =make-random-state= are:
=(OR RANDOM-STATE (MEMBER T NIL))=
=(OR RANDOM-STATE FIXNUM (MEMBER T NIL))=
Initializing a random state with an appropriate array (element type and
arity) or with a fixnum is now possible only with the #$ reader macro.
arity) is now possible only with the #$ reader macro.
** Enhancements
- Removed 15000 lines of obsolete code
Files not included in the buildsystem but lingering in the codebase or
options failing to build. All info is added in the new documentation in
options failing to build. All info is added in the new documentation in the
section "Removed interfaces".
- Improved man page and help output.

View file

@ -287,18 +287,25 @@ ecl_make_random_state(cl_object rs)
if (rs == ECL_T) {
z->random.value = init_random_state();
return z;
}
if (Null(rs))
} else if (Null(rs)) {
rs = ecl_symbol_value(@'*random-state*');
if (ecl_t_of(rs) == t_random) {
z->random.value = cl_copy_seq(rs->random.value);
return z;
}
FEwrong_type_only_arg(@[make-random-state], rs,
ecl_read_from_cstring(type));
switch (ecl_t_of(rs)) {
case t_random:
z->random.value = cl_copy_seq(rs->random.value);
break;
case t_fixnum:
z->random.value = init_genrand(ecl_fixnum(rs));
break;
default:
FEwrong_type_only_arg(@[make-random-state], rs,
ecl_read_from_cstring(type));
}
return z;
}
@(defun random (x &optional (rs ecl_symbol_value(@'*random-state*')))

View file

@ -1399,10 +1399,6 @@ sharp_dollar_reader(cl_object in, cl_object c, cl_object d)
break;
}
#endif
case t_fixnum:
rs = ecl_alloc_object(t_random);
rs->random.value = init_genrand(ecl_fixnum(c));
break;
default:
rs = ecl_make_random_state(c);
break;