delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/11/16/10:43:34

Date: Mon, 16 Nov 1998 10:37:18 -0500 (EST)
Message-Id: <199811161537.KAA11282@indy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: eliz AT is DOT elta DOT co DOT il
CC: djgpp-workers AT delorie DOT com
In-reply-to: <Pine.SUN.3.91.981116172732.8995H-100000@is> (message from Eli
Zaretskii on Mon, 16 Nov 1998 17:29:32 +0200 (IST))
Subject: Re: src/libc/ansi/stdlib/rand.c
Reply-To: djgpp-workers AT delorie DOT com

> > so I figured I'd let libc randomize itself if srand() wasn't called
> 
> Yes, but are we willing to break ANSI compliance because of what some 
> people's unjustified (IMHO) expectations?

Sometimes, like when we flush after printf() even when we shouldn't.

When the spec says to do X and the users expect Y and there's no
advantage to X, I think Y is the right thing to do.  Let the other
vendors answer the FAQs for a change.

People who really need a repeatable sequence of numbers from rand()
will need to use srand() anyway, to get different sets of repeatable
numbers.  When debugging something that uses random numbers, the
program must select a random seed manually, and *print* it.  If the
program displays bad behavior, it can be modified to always use
whatever seed it picked that time, so that that particular sequence
(and its consequences) can be debugged.

I see no advantage to arbitrarily picking one particular sequence as
the "default" random number sequence, especially since ANSI doesn't
define the random number generator, so cannot specify the sequence
itself.

The only advantage to doing it the ANSI way is that people learn what
will work correctly on other platforms.

Does anyone else have an opinion on this?

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019