using "!!" in "c"

P

pemo

Keith Thompson said:
(A number of attributions were snipped. I wrote the text starting
with "So is (value, 0)", pemo wrote the text starting with "What's the
point here?", and Flash Gordon wrote the text starting with "I believe
that Keith was". Please leave attributions in place. Thanks.)

After this reply, I'll try and remember to simply enter any further replies
I make to posts at the bottom of any existing text - and then let others
either ignore my posts, or else figure out to what it is I might be
referring - seems like I'll never get the hang of this process, and if I'm
black-flagged, knobbled, f**ked up the ass [or whatever the proper 'in the
know' usenet term is] by some for not posting correctly, at least I won't be
committing the ultimate sin: top posting.

What you wrote was:

!! is a good way of turning a scalar value into 1 or 0.

That's not a useful specification unless you also specify *when*
it yields 0 and when it yields 1. By itself, it doesn't provide any
clue of why you'd want to turn a scalar value into 1 or 0. I was just
emphasizing the fact that !! maps 0 to 0 and all non-zero mappings
to 1. There are many many other possible mappings.

By itself, it doesn't provide any clue of why you'd want to turn a scalar
value into 1 or 0.

'By itself' - yes - which is why I then gave an example (malloc).


Whether I was being overly pedantic is a matter of opinion, of course.
I likely wouldn't have bothered mentioning it if I weren't commenting
on other things in your article.
printf("%p\n", (void *)"boo");

will output some value that's not 0, and very unlikely to be 1, e.g.,
0040300

It will output some implementation-specific sequence of printing
characters. The sequence may or may not look like a number.

Can you explain this comment too? Is it an allusion to some obscure
minutiae in the std, like "In reality, an implementation is free to
encode
an address such that it is displayed in egyptian hieroglyphics"?
One very common format of output is something like "1234:5678", another
is something like "0x12345678". <snip>

Ah, so it was as I expected - an allusion to some obscure minutiae [well,
it
is isn't it - letter-of-the-law-correct-or-not] that seems picky and
generally non-constructive. The two examples you gave look like numbers
to
me. And I would hazard a guess that most every compiler outputs
something
similar - even if it doesn't *have to*. So, saying that a compiler
*could*
output this in a braille encoding of the morse-code interpretation of
egyptian hieroglyphics is kinda like saying that there is a remote
possibility that you *could* pick up a book which is written in English -
but that you can't read - because the author decided to choose a remote
vocabulary and to 'encode' his/her prose in such an impenetrable way as
it
make it more or less impossible. Both situations *could* exist, but both
are, in reality, unlikely to - so what's the point in making a noise
about
it?

No, this is not "some obscure minutiae", this is part of a basic
understanding of the language.

Here's what the standard says about the "%p" format for the *printf()
functions:

The argument shall be a pointer to void. The value of the pointer
is converted to a sequence of printing characters, in an
implementation-defined manner.

There's also some wording for the *scanf() functions saying that it
can read the same format produced by *printf().

There is no implication that the output looks anything like a number,
and portable code cannot depend on any particular output format.

Ok, so this is where the problem is - although the OP might not give a
flying f**k about it, as they also might possibly not give the same for
portability - you're saying that I should have added ...

"will output some value that's not 0, and very unlikely to be 1, e.g.,
0040300. But remember that nothing is said in the C stds about the actual
output here, so you might see output that's in a format that you might not
readily understand for example, some version of printf might output cockney
rhyming slang! - "two fat ladies, two rubber ducks, and a ton" (meaning
8822100 in base 10)"
 
K

Keith Thompson

pemo said:
You think x86 based machines are obscure minutiae?

No, not that! [see also below], rather that the comment I thought
uneccesary, *was* (IMHO)

It was essentially 'pulling me up' for stating that the output *might* be
0040300 [or 0123456, or 123, or 34234234234234234] - and that I didn't add
some, 'oh, and it might just be in output in hieroglyphics on your
implementation'!

Maybe the point was made so that some 'knumb nuts' didn't get the wrong end
of the stick, or maybe it was made just to remind someone [who I don't know]
that the output might actually be different from the example - maybe it was
just made to personally annoy me - I dunno, but it pissed me off anyway!

I did not intend to be offensive. In fact, I don't believe that I
was, and I'm surprised that you took offense. Feel free to interpret
my comments as a helpful commentary on what you wrote rather than as a
correction. And grow a thicker skin.
 
F

Flash Gordon

pemo said:
Sorry, I'm a terrible poster, and I'll look at QuoteFix.

I would not class you as a terrible poster. The terrible posters are
those who make no effort or deliberately go against convention. You may
make mistakes, but you are attempting to do it correctly. That puts you
on the good side rather than the bad. To make it clear, I have reason to
suspect that OE sometimes does the wrong thing even when users have done
their best to configure it correctly, but I've heard from people I
respect that QuoteFix helps to make OE behave nicely.
printf("%p\n", (void *)"boo");

will output some value that's not 0, and very unlikely to be 1, e.g.,
0040300
It will output some implementation-specific sequence of printing
characters. The sequence may or may not look like a number.
Can you explain this comment too? Is it an allusion to some obscure
minutiae in the std, like "In reality, an implementation is free to
encode an address such that it is displayed in egyptian hieroglyphics"?
One very common format of output is something like "1234:5678", another
is something like "0x12345678". <snip>
Ah, so it was as I expected - an allusion to some obscure minutiae [well,
it
You think x86 based machines are obscure minutiae?

No, not that! [see also below], rather that the comment I thought
uneccesary, *was* (IMHO)

That is not the way your comment that I was making "an allusion to some
obscure minutiae" reads to me. said:
It was essentially 'pulling me up' for stating that the output *might* be
0040300 [or 0123456, or 123, or 34234234234234234] - and that I didn't add
some, 'oh, and it might just be in output in hieroglyphics on your
implementation'!

No, it was not you picking a number, but your wording read to me as
implying it would be a simple number.
Maybe the point was made so that some 'knumb nuts' didn't get the wrong end
of the stick, or maybe it was made just to remind someone [who I don't know]
that the output might actually be different from the example - maybe it was
just made to personally annoy me - I dunno, but it pissed me off anyway!

It wasn't made to annoy you, or to show you up, or anything like that.
is isn't it - letter-of-the-law-correct-or-not] that seems picky and
generally non-constructive. The two examples you gave look like numbers
to me. And I would hazard a guess that most every compiler outputs
something
Numbers do not have colons in the middle, at least not in any
representation I've come across and "(null)" is definitely *not* a number
which was another example I gave but you snipped.

Yes, my phd wasn't wasted - and I've noticed that numbers don't have numbers
in the middle **using standard notation [see below]** - but they *can* have
camels in the middle if *you* want them to - and if you want to use such
notation personally - as some legal characterisation of some abstract scalar
view of the world.

If you put a camel in the middle it won't look like a number to most
people, it will look like 2 numbers separated by a camel. Just as two
numbers seperated by a colon looks like two numbers separated by a colon
to most people.
> Which comes back to a problem with this ... if the
output can be anything, well, we ought to always include standard
disclaimers about *any* claim we make here regarding *any* output.
Ridiculus - so, lets point it out when it's properly pertinent, and not just
when we just feel the urge to bump our gums, and add some white noise into
the system?

For most things the output cannot be anything, but letting people who
don't know any better think that pointers are basically the same as
numeric types is dangerous.
Actually, that's rubbish, as I used them for many years with segmented
architectures - such numbers then meant as much to me - as in they had an
intuitive meaning for me (as 123 does now/then). This last bit is a little
like the 'pulling up' I had

Show a "number" with a colon in the middle to a mathematician and they
won't think of it as a number. Explain to them that 0010:0000 is the
same as 0000:0010 because you multiply the number before the colon by 16
and add it to the other and they will probably consider it to be two
numbers separated by an operator. Most of the people I've talked to
about x86 systems would also consider it to be two numbers, a segment
and an offset, not as one number, and as an ex-assembly language
programmer there have been times when the distinction has been very
important.
'Actually the output of pemo's mathematics will be a pemo
implementation-specific sequence of printing
characters [maybe]. The sequence may or may not look like any number you're
used to'

Well, your explicit statement that the value would not be 0 is not
necessarily correct and so should not have been stated as fact, and I
know of systems where it is very easy to end up with a pointer to
address 1 (and possibly 0 as well, but I can't be certain of that since
I can't remember what was used for a null pointer) since it is normal
memory at that address. Had you not said what values it would not be I
might not have bothered commenting, but that combined with the rest of
what you were saying looked to me like it would read to the naive as if
pointers where just integers.
 
C

CBFalconer

pemo said:
.... snip ...
(A number of attributions were snipped. I wrote the text starting
with "So is (value, 0)", pemo wrote the text starting with "What's the
point here?", and Flash Gordon wrote the text starting with "I believe
that Keith was". Please leave attributions in place. Thanks.)

After this reply, I'll try and remember to simply enter any further
replies I make to posts at the bottom of any existing text - and
then let others either ignore my posts, or else figure out to what
it is I might be referring - seems like I'll never get the hang of
this process, and if I'm black-flagged, knobbled, f**ked up the ass
[or whatever the proper 'in the know' usenet term is] by some for
not posting correctly, at least I won't be committing the ultimate
sin: top posting.

The other sin is failing to snip. The count of '>' marks on the
left keeps track of the attributee (with a one-off error :) You
should also try to keep your line width under 72 (I use 67).
Notice how I have removed attribution lines only for material
totally excised. See the following references.

http://www.netmeister.org/news/learn2quote.html
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.greenend.org.uk/rjk/2000/06/14/quoting.html
http://www.i-hate-computers.demon.co.uk/
http://web.ukonline.co.uk/g.mccaughan/g/remarks/uquote.html
http://www.cs.indiana.edu/docproject/zen/zen-1.0_6.html

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
 

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

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top