View Single Post
  #7 (permalink)  
Old January 10th, 2009, 11:13 AM
DrPurdum DrPurdum is offline
Friend of Wrox
Points: 1,166, Level: 13
Points: 1,166, Level: 13 Points: 1,166, Level: 13 Points: 1,166, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Sep 2008
Location: Indianapolis, IN, USA.
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default Define vs declare

Not a problem. While you understand the difference, one of my pet peeves is that most programmers treat the words define and declare as synonyms, which they are not. From page 83 of my book:

A variable is defined if, and only if, the lvalue column for that variable in the symbol table has a memory address assigned to it. When you declare a variable, the lvalue column is the symbol table for that variable does not contain a memory address.

This is consistent with the K&R distinction of the terms in their pivotal book. A data declaration is like the C function prototype statements--the purpose of which is to give the compiler an attribute list for type-checking purposes. (An extern data type in C is a good example--the actual memory allocation is done elsewhere in the program, but the statement allows the compiler to type-check its use in the current file.) The real problem is that the distinction is lost on a huge segment of the programming community. Indeed, all of Microsoft's documentation seems to make no distinction between the two terms. If all programmers used define and declare correctly, newcomers like Mr. Hkyoon would have a much easier time of it and that's really my ultimate goal--to make Mr. Hkyoon's learning experience as easy and enjoyable as possible.
Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)