Keyboard support in C (was Re: making characters disappear)
Conor O'Neill
conor at lion.inmos.co.uk
Fri Mar 1 00:41:26 AEST 1991
In article <15302 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
>In article <1991Feb23.170142.538 at ux1.cso.uiuc.edu>
>>mcdonald at aries.scs.uiuc.edu (Doug McDonald) writes:
>>That is because it SHOULD be possible to do such very common things
>>as non-echo reading or reading single characters without terminating
>>carriage returns. We should be discussing how to put this into the
>>next standardized version of the language. It SHOULD have been in the
>>present version.
>
>I don't think you would find many (if any) people among those who have
>carefully considered what needed to go into the C standard, who would
>agree with you. This is clearly a very system-specific notion; there
>are C environments where the notion makes no sense. The C standard
>addresses (for hosted environments only) just the minimum universally-
>implementable support necessary for useful applications across all
>hosted environments. There are other standards, such as POSIX.1, that
>address more system-specific features, and that is an appropriate way
>to deal with them.
I agree strongly with Doug McDonald.
There is already a huge quantity of `system-specific' stuff in the hosted
version of ANSI C. Examples such as getenv and system spring to mind.
Since all computers which support files almost certainly have a keyboard,
it would seem sensible to provide for keyboard access within ANSI C.
I agree that some operating systems would not support un-buffered/echoed
input, but there again, some operating systems do not support
environment variables, the system function,
or access to the time of day, or...
The function ("inkey", or whatever it might be called) could simply
return an error code if it could not be supported.
It also seems, because of the frequency with which this question occurs,
that it is exactly the sort of problem which it would have been useful
to standardise, so that it would be possible to write interactive
programs which were at least portable to machines and operating systems
with `normal' keyboards.
(Standard disclaimer that ANSI C existed to standardise existing practice,
and not to introduce new ideas. It is unfortunate that a large proportion of
existing practice was UNIX, which has terrible support for keyboards).
(Sorry - pretend that I didn't say that!)
---
Conor O'Neill, Software Group, INMOS Ltd., UK.
UK: conor at inmos.co.uk US: conor at inmos.com
"It's state-of-the-art" "But it doesn't work!" "That is the state-of-the-art".
More information about the Comp.lang.c
mailing list