Aubrey Jaffer wrote:
> An example of an exception
> is the use of a pseudo-random-number-generator having shared state:
>
> (require 'random)
> (+ (random 99) (random 99))
>
> The concurrency-safe version could be written:
>
> (require 'random)
> (let* ((rnd1 (random 99))
>        (rnd2 (random 99)))
>    (+ rnd1 rnd2))

I have a rather long list of questions, some of which are more like
statements; but please bear with me, as I want to understand the
implications of such design better.

For one thing, `let*'-wrapping in addition to preventing concurrency
also restricts the order of evaluation; but you only want sequential,
and don't care which exactly. Note that many optimizing compilers
shuffle the order of evaluation to achieve better register usage. So
shouldn't we specify additional sequential-call form (`scall') to
explicitly mark call sites where you want to forbid concurrency?

I wonder what would be the ratio of explicitly sequential call sites
to implicitly concurrent one in a typical program. Or may it be better
to explicitly mark concurrent call sites (e.g. with `pcall'), not the
sequential ones?

Another thing, let's say I have an expression like this:

  (f (x) (y))

Am I required to know if both `x' and `y' share the same mutable state,
so I can't call them in parallel? What if I don't know (e.g. I'm
calling some user-passed functions, or the documentation did not
specify such details), do I change each call to `scall'?

What if at some point in the development both `x' and `y' where pure,
but then I added `random' to both; do I now have to go through all
the code that uses them and sequentialize the calls? Do I also have
to find all the functions that call `x' or `y' and sequentialize calls
to those functions as well?

Isn't this a rather major penalty for using side-effecting code? I just
wonder how much of a problem this may be in practice.

Finally, how do I use code which I cannot sequentialize? E.g. if we
specify `map' to be concurrent, how do I (map random '(1 2 3))?
Or shall we have a separate `sequential-map' in the standard library?

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to