Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Stroustrup "desk calculator" chapter 6

Reply
Thread Tools

Stroustrup "desk calculator" chapter 6

 
 
arnuld
Guest
Posts: n/a
 
      11-10-2006
> Alf P. Steinbach wrote:

> You have it backwards. The C++ program is to analyze a calculator
> "program" text, as a specification of what it should do, and then either
> produce the numerical result (acting as an interpreter) or some
> intermediate form of the specification (acting as a compiler) that's
> easier and more efficient to evaluate. Anyway it will probably involve
> recursive functions, that is, functions calling themselves, which is
> then probably much of the point.
>
> Personally I like much better to use L-systems to introduce the power of
> recursive functions, creating "interesting" graphics, but then Bjarne
> can't assume availability of any graphics package in that book.
>
> And parsing is very much AT&T Bell Labs stuff...


is it really necessary to understand DC programme to understand rest of
the book? it is too complex for me to understand it. can i leave this
& go directly to section 6.2 without much loss?

 
Reply With Quote
 
 
 
 
Alf P. Steinbach
Guest
Posts: n/a
 
      11-10-2006
* arnuld:
>> Alf P. Steinbach wrote:

>
>> You have it backwards. The C++ program is to analyze a calculator
>> "program" text, as a specification of what it should do, and then either
>> produce the numerical result (acting as an interpreter) or some
>> intermediate form of the specification (acting as a compiler) that's
>> easier and more efficient to evaluate. Anyway it will probably involve
>> recursive functions, that is, functions calling themselves, which is
>> then probably much of the point.
>>
>> Personally I like much better to use L-systems to introduce the power of
>> recursive functions, creating "interesting" graphics, but then Bjarne
>> can't assume availability of any graphics package in that book.
>>
>> And parsing is very much AT&T Bell Labs stuff...

>
> is it really necessary to understand DC programme to understand rest of
> the book?


I don't think so, because I don't recall the book mentioning any program
called "DC".

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
 
arnuld
Guest
Posts: n/a
 
      11-10-2006
> Alf P. Steinbach wrote:

> I don't think so, because I don't recall the book mentioning any program
> called "DC".


ok, ok here is the complete thing:

is it really necessary to understand "Desk Calculator programme" in
chapter 6 to understand rest of
the book?

it is too complex for me to understand it. can i leave this section
(6.1) of Desk Calculatro and go directly to section 6.2 without much
loss?

 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      11-10-2006
* arnuld:
>> Alf P. Steinbach wrote:

>
>> I don't think so, because I don't recall the book mentioning any program
>> called "DC".

>
> ok, ok here is the complete thing:
>
> is it really necessary to understand "Desk Calculator programme" in
> chapter 6 to understand rest of
> the book?
>
> it is too complex for me to understand it. can i leave this section
> (6.1) of Desk Calculatro and go directly to section 6.2 without much
> loss?


What's the exact first /word/ in that text where it starts sounding
difficult?

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      11-11-2006
* Alf P. Steinbach:
> * arnuld:
>>> Alf P. Steinbach wrote:

>>
>>> I don't think so, because I don't recall the book mentioning any program
>>> called "DC".

>>
>> ok, ok here is the complete thing:
>>
>> is it really necessary to understand "Desk Calculator programme" in
>> chapter 6 to understand rest of
>> the book?
>>
>> it is too complex for me to understand it. can i leave this section
>> (6.1) of Desk Calculatro and go directly to section 6.2 without much
>> loss?

>
> What's the exact first /word/ in that text where it starts sounding
> difficult?


Sorry, I'm beginning to see your problem.

I learned C++ from the first edition of TCPPPL, which was clear and
short and sweet, being based on K&R TCPL. Comparing it to the second
edition (someone got away with "borrowing" and never returning the third
edition, so I don't have it), which is four to five times heavier (in
weight) and much less readable: The very clear & short language overview
at the start of the first edition has been replaced with /long/ sections
of nothing particularly useful to know, in the second edition.

And without the clear language overview first, the desktop calculator
program may be difficult to grok; I mean, in the second edition not even
the 'for' loop has been explained at this point, not that 'for' loops
are explained later on either, except in the reference section. It was
of course properly explained in the first edition...

I therefore suggest looking up things in the reference section at the
back of the book.

That reference section is a very very positive feature of the book, and
before the standard of 1998 it served as a kind of de facto standard
(together with the Annotated Reference Manual book, the "ARM", now not
particularly useful).

Another reason why the program can be hard to understand is that it's
presented one small piece at a time, has some unreadable names, and uses
raw arrays and pointers and such.

So for your & others' convenience I've placed a version that has
(hopefully) more readable names, no pointer or raw array usage for most
of the code, and is in one single file, at <url:
http://home.no.net/alfps/misc/dc.cpp>.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stroustrup Chapter 4, Exercise 5 arnuld C++ 4 03-05-2007 04:05 PM
Stroustrup Chapter 4, Exercise 3 - displaying the sizes of char, int etc. arnuld C++ 0 03-05-2007 03:18 PM
Stroustrup Chapter 4, Exercise 2 arnuld C++ 0 03-05-2007 02:34 PM
Stroustrup: chapter 4 arnuld C++ 13 03-05-2007 07:41 AM
Stroustrup chapter 3 - 3.6 arnuld C++ 4 11-05-2006 11:25 AM



Advertisments