P
Pascal J. Bourguignon
Joshua Maurice said:Really off-topic here, but let me correct this. While I agree that
this should be done for other reasons, portability is not one of them.
As soon as you're writing to particular hardware memory addresses,
there is no such thing as portability, with peek and poke functions or
not. It is inherently tied to the system, and the C standard says
little to nothing about such things (though it was explicitly written
to allow the system to take some of the undefined behavior and make it
defined /for that platform/).
I beg to differ.
You can get your addresses from a configuration file.
The semantics and of sequences of peeks and pokes depend more on the
device, than on the system. There may be different routing, it's true,
but this also can be dealt with in a modula way. Ultimately, on sane
hardware, I think it's perfectly possible to write portable drivers or
systems. Linux and Microsoft Windows are clear examples.
What I have said in this thread was for portable C programs, aka
programs written to the C standard and not to platform extensions.
Obviously writing device drivers and such is possible in C and not in
Java because of C's unchecked pointer casts and other "unsafe" pointer
stuffs. It's not fair to compare this.
I'm saying you can do the same in Java provided the JVM gives you access
to a low level peek and poke, and some wait to control timing
(eg. disable garbage collection for time-critical sections). Or any
other programming language such as Lisp on the LispMachine.
What is fair is to compare the semantics of pointers and Java
references. You can assign to a pointer without changing the
pointed-to object, changing a passed by value pointer in a function
call leaves the callee pointer unchanged, and so on. This is very much
unlike C++ references which act more like aliases, and I again contend
that because Java in its beginning largely lifted its syntax and
semantics from C++, it should not have conflated and confused these
two terms because it causes (minor) undue confusion in the
communities.
There's so few words...