Tags:
create new tag
, view all tags
I started to read "Migrating from Pascal to C++" and the first chapter really intrigued me. IIUC, objects were suggested in the same trio of papers that introduced structured programming (and maybe inspired Pascal?) but weren't implemented until Simula (67?) (and then C++?).

Anyway, I plan to keep notes on WikiLearn as I read this book. Not sure if I'm violating copyright in any way -- in a sense this is a derived work, but the "content" is little different than if I were studying the book in school, but, in the past, I would have highlighted or underlined portions of the text in the book, or "scribbled" notes in a notebook. The differences here include:

  • I don't type as fast as I highlight or scribble, so may not make as many notes
  • May end up editing the notes (or being more careful the first time with grammar) more than my handwritten scribbles might be
  • As I read additional books, I suspect I will add notes to these pages rather than create separate pages. (For example, if I start a page on inheritance based on what I learn in "Migrating..." and learn some additional nuances from other books (or other resources), I will probably add them to the page on inheritance originally abstracted from "Migrating...". Then what is the copyright story?
  • These notes will be publically accessible on WikiLearn, my college notes were generally accessible only to myself and possibly a few others.

I guess one way of solving the problem is to write to each of the authors, ask them to take a look at what I'm doing and ask if they object. I basically intend to do that, but will think about it a little first (and need to find their addresses). Oops, I forgot, the publisher probably holds the copyright.

I need to think some more -- I guess I don't see how what I'm doing can be considered violating copyright any more than if I'd write a research paper or thesis and cite my sources. (I certainly don't want to become a "trial" case.)

See:

Contents

Notes

To start, I'm going to probably organize by chapter. Then maybe break things out by subject. We'll see how it goes.

Chapter 1: C++ as Structured Programming, An Historical Perspective

I think my notes on the first chapter are basically embodied in the comments at the top of this page:

I started to read "Migrating from Pascal to C++" and the first chapter really intrigued me. IIUC, objects were suggested in the same trio of papers that introduced structured programming (and maybe inspired Pascal?) but weren't implemented until Simula (67?) (and then C++?).

Listing the topics in the TOC could be useful -- I might do that on a selective basis.

Chapter 2: The C++ Subset that Covers Pascal

Some Quick Analogies

C++ Pascal
{} begin end
int integer
float, double real
char char
na (0=false, else true) boolean
struct record
array subscripts always start at 0 array range can be defined
if (a = b && c d) if ((a = b) and (c <> d))
if if then
if else if then else
switch case
for for
while while
do while repeat until
function function
void function procedure
float power(float n, int expon) function power(n:real; expon:integer): real;
void swap(char& ch_1, char& ch_2) procedure swap(var ch_1:char; var ch_2:char);
functions may not be nested functions may be nested
no dynamic scoping -- local variables in a function are not visible within a function called from the first function

Hello World

C++ Pascal
//Hello world in C++

#include
void main()
{
//variables declared/defined here
cout << endl;
cout << "hello world";
cout << endl;
)
{Hello world in Pascal}
program hello_world(input, output);
{variables defined (declared?) here}
begin
writeln;
write('hello world');
writeln;
end

Notes:

  1. I don't recall why Pascal includes input and output as arguments (or what I would have called parameters)
  2. The C++ comments can also be C style -- /* (multiline) comment */

Keywords and Identifiers

C++ Pascal
keywords lower case lower case (or either??)
identifiers all varieties all varieties (except embedded underline??)
constants uppercase (recommended) ?

Some varieties:

  • total_amount
  • TOTAL_AMOUNT (preferred for constants)
  • Total_Amount
  • totalAmount (preferred??)
  • TotalAmount

Note: I cannot recall, but I had a problem for a while with Pascal (or was it PL/1??) -- IIRC, I wanted to have all the program keywords in lowercase, and the variable names like WikiWords -- I think what I wanted to do was allowed, but many people were promulgating a standard that called for keywords in uppercase and identifiers in lower case?. My own programs were done the way I preferred, but I always found it annoying to read code programmed according to the standard. To me the keywords were not the most important thing, the identifiers were. (I should clarify this (if I can wink ) -- if I'm scanning a long program, I'm looking for identifiers that I've defined (i.e., sort of the "business logic" as it is sometimes described today) -- only after I've narrowed down my search to a specific area might I be interested in the details of what is done to those identifiers (the keywords). In other words, keywords in caps emphasized the wrong thing (IMHO).

Variable Declarations

C++ Pascal
const float PI = 3.14;
const
pi = 3.14;
float radius, area;
var
radius, area:real

Note: Clearly C++ declarations (definitions?) could be on multiple lines, and Pascal declarations could be on a single line. I guess I (and maybe other Pascal programmers) commonly used the multiple line approach, and C++ programmers commonly don't (??) -- in any case, it just seems to fit my mindset better.

The authors make a point somewhere about here that (quoting Bjarne Stroustrup) "What you don't know won't hurt you", meaning that you can write a C++ program using what you do know, and it is likely to work, and not fail because of something you don't know. (That may be sort of off target -- the authors used it to support the statement "This means that a program written in C++ in the style of Pascal is an acceptable C++ program.")

Include Files

C++ Pascal
#include <iostream.h> for standard headers
#include "MyFile.c" for programmer defined files

In C++ (and C, AFAIK) you don't have to include the entire set of files (i.e., .c and .h files) for a standard library routine, but only what is known as the header file (.h).

I have a vague recollection of Pascal units which the author's make reference to -- I'd have to review a Pascal unit to understand what they are getting at.

Sources

  • (rhk) "Migrating from Pascal to C++"; Merritt, Susan M. and Allen Stix; New York : Springer, c1997.

Contributors

  • () RandyKramer - 08 Dec 2002
  • <If you edit this page: add your name here; move this to the next line; and include your comment marker (initials), if you have created one, in parenthesis before your WikiName.>

Page Ratings

Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2002-12-14 - RandyKramer
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WikiLearn? WebBottomBar">Send feedback
See TWiki's New Look