This is a discussion on Re: [9fans] echo -n - Plan9 ; Francisco J Ballesteros wrote: > Yes, but, what does it mean to write zero bytes? > I know, I know. > But my point is, does it make sense? Sure it makes sense. It's like an empty string, or an ...
Francisco J Ballesteros wrote:
> Yes, but, what does it mean to write zero bytes?
> I know, I know.
> But my point is, does it make sense?
Sure it makes sense.
It's like an empty string, or an empty box -- there is a
container but no contents.
> If you want a write of something weird to mean something, you might
> just use a write of something weird, or a control operation kept appart.
That requires an additional convention that all utilities would
have to understand.
> A related question, can we create a file with an empty name?
In principle, creating "" means creating `pwd`/"", which is
interpreted by many Unix-related systems as the same as `pwd`/
and that operation should fail (since either create isn't the
way to create a new directory, or the target already exists).
I was Point of Contact for the C standards group's "zero-sized
objects" special-interest task force. As it turned out, not
enough people seemed interested in requiring support for zero-
sized objects (e.g. "int x;"), so the C standard doesn't
sanction them, but there was not a problem with the semantics
they would have had were they allowed to exist. The best
argument for allowing such things is that there should be a
parallelism between data structures and the control constructs
used to access them:
#define N 20
for (int i = 0; i < N; ++i)
x[N] = 0;
There is no logical reason why that shouldn't work if N is
defined as N, and indeed the control structure is required to
work (just not the array declaration). There are many useful
applications for this, for example N might have parameterized
how many objects of a certain kind there were and when built
for a specific purpose there may have been no objects of that
kind (although for other purposes there would be some).