Implementing the KISS4691 RNG

V

Victor Bazarov

You'd think that would all it's capabilities, C++ would allow you to
devise a way of writing just:

print x

I think you meant

println x

and in fact you can, if you define the macro ('println') that would
expand to

somecustomoutputter(std::cout) <<

and which would output newline and purge its buffer upon every output.
You're obviously not interested in that, so I won't bore you with the
details.

V
 
D

David Thompson

In comp.lang.fortran Keith Thompson <[email protected]> wrote:
If you program Java for a while, you get used to it. Java compilers
are supposed to treat it as an error, not a warning, if the
compiler can't determine that a scalar variable is initialized.
(No such test for arrays.)
If you mean a reference to a whole array
int f ( ) { int [] x; return /*unset=garbage*/x . length; }
that is covered by the 'definite assignment' rule.
If you mean elements of an array
int f ( ) { int [] x = new int [42]; return x[6] - x[7]; }
actual arrays are heap-allocated and all of their elements
initialized, to zero/false/null by default if no explicit initializer.
(And with an explicit initializer what the bytecode actually does is
allocate a default-initialized array and then compute and store each
element separately, recursively for multidim, so even if an
initializer element throws, all array elements are type-valid.)
But, yes, I always think it is dumb when I know it is initialized,
but the compiler doesn't. With the Java exception model, though,
it isn't always so obvious. If a called method throws an exception,
it might be that the variable isn't assigned a value, even if it

Although the compiler does know where (all) catch and finally clauses
are and can use them in flow analysis. In fact when I look closely at
the -g:vars info it actually specifies modified lifetimes that start
after the first assignment and have gaps for handler blocks that could
be invoked before/without such assignment.
is in an assignment statement. Or consider:
Presumably in C, since Java doesn't have unsigned except char.
unsigned i,x;
for(i=-1;i<3;i++) x=3

If you try hard enough, you can always find a way to fool the
compiler initialization test logic.
That one has a good chance of fooling the human reader but won't
even faze the compiler. (Once you add the missing semicolon.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,083
Messages
2,570,591
Members
47,212
Latest member
RobynWiley

Latest Threads

Top