For those who are curious, the current implementation keeps a Perl array of the currently available stream numbers, initially 0 ... 99. When one is used, it gets shifted off the bottom. When a stream is done being used, it gets pushed back on the top. In particular, this means that you can have various lifetimes for the different streams and you won't run into a problem of two streams having the same stream number.

Roberto, your idea of decrementing the current stream number is a problem if you have short-lived stream followed by a long lived stream. Then the stream numbers would be like this:
  1. Create stream 0; initialize and begin to use. Now $next_plplot_stream = 1.
  2. Create stream 1; initialize and begin to use. Now $next_plplot_stream = 2.
  3. Finish with stream 0. Now $next_plplot_stream = 1.
  4. Without finishing with stream 1, create a third stream. It will have stream number 1, but we already have a stream with number 1!
David