POV-Ray : Newsgroups : povray.off-topic : Teach yourself C++ in 21 days : Re: Days 1-5 Server Time
30 Jul 2024 00:30:26 EDT (-0400)
  Re: Days 1-5  
From: Invisible
Date: 20 Apr 2012 04:28:18
Message: <4f911e22@news.povray.org>
On 20/04/2012 01:57 AM, Darren New wrote:
> On 4/17/2012 1:52, Invisible wrote:
>> Except that assembly generally follows a simple and consistent syntax,
>
> ... says the man who never programmed in an assembly language for
> machines designed to be programmed in assembly language.

So what /was/ the Motorola 68000 designed to be programmed in then?

>> an "obscure feature" which you don't need to know about. :-P
>
> It *is* outside the C standard, tho, in terms of what it "means".

Sure. But in terms of writing practical code that runs on common 
hardware under common operating systems - which is the target of this 
book - it's not exactly "obscure". It's not like this is a book about 
how to program microcontrollers. (That would be something else entirely...)

>> I dislike code that's so littered with comments that you can't see the
>> code
>
> Except in assembler.

?

>> I guess this is why autoconf exists. :-P
>
> That and amongst many, many, *many* other reasons.

I found another one:

http://tinyurl.com/32vda9

>>> Second warning: the signedness of char is local to the compiler.
>>
>> Really? The book seems to say that all integer types default to signed,
>> unless you request unsigned. (AFAIK, there isn't a way to request
>> signed.)
>
> Except characters. Because PDP-11.

It worries me that we're still using a language who's fundamental design 
decisions are based on hardware first produced in the 1970s.

But it worries me more that they only stopped manufacturing the PDP-11 
in the 1990s. o_O

>> So much for C and C++ being for system-level programming. :-P
>
> It was never very *good* for it. It was just better than its competitors
> of the time.

Jesus, did it even *have* any competitors?!

>>> Usually, float is a 32 bits, double is 64 bits. But it is known that
>>> some compiler would perform the computation on 80 bits registers...
>>
>> Is there a way to explicitly request 80 bits?
>
> No, of course not. C doesn't provide any way to ask for a type based on
> what you need. You can only ask for types based on what the CPU
> provides

OK, well IA-32 provides 80-bit floats. So... is there a standard way to 
get them?

>> Right. So if I request a 2GB array, it won't actually sit there trying to
>> zero all 2GB of RAM, right before my for-loop rolls over it to
>> initialise it
>> /again/.
>
> The OS probably will, tho, if you have a multi-user OS.

Not much I can do about that. ;-) But yeah, it does make the whole 
design decision seems a be out-dated. (Then again, calling the default 
constructor for each array element might do a lot more work than just 
zeroing some bytes. Presumably the way the OS zeros memory is quite 
efficient.)

>> Oh that's sick. So comma really /is/ an operator? Wow, that's evil.
>
> Why? It's just an operator. Is it really worse than Haskell's "." or
> ">==" operators, or whatever they're called?

You'd expect part of the language's basic syntax to be, you know... part 
of the language's basic syntax. But it isn't. It's just a regular 
operator, which means you can use it in places where you shouldn't be 
putting random commas, and that makes it do strange stuff. (And, being 
C, this isn't checked in any way.)

>> I was referring more to the fact that it's legal to not specify the
>> return
>> type, and if you don't, it defaults to something absurd.
>
> It defaults to integer. Not sure what makes that "absurd".

The /logical/ thing is for a function that doesn't mention a return type 
to default to returning nothing. And yet, it doesn't. It arbitrarily 
defaults to int. Not bool, not void*, not w_char, but int. No reason, it 
just does.

>>> At one point in the argument list, you must start providing default
>>> values, for all argument at the right of that point.
>>
>> ...which makes infinitely more sense than what the book said. :-P
>
> Really!? What the book said was clearly and simply a mathematical-type
> statement. No parameter without defaults can be preceeded by one with
> defaults. Hence all defaults must come after all non-defaults.
>
> The previous statement is inaccurate in that it does not take into
> account no-defaults and all-defaults.

I forget who said it: comprehension = 2 ^ -precision.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.