We talk about the "lexical structure" of a programming language as if programmers are specialists in linguistics. This is not necessarily the case. Lexical analysis informally relates to "parts of speech", or more generally, parts of sentences. In this case, we are analysing "sentences" in the C# programming language.
Taking a "lexical view" of C# is an interesting exercise and helps to explain programming to semiotics majors, for example.
Take the simple assignment: double pi = 3.14159;
Analysing this lexically we can say:
1. double is an "abstract noun". An abstract noun refers to a concept or idea. In this case, the idea is of a 64-bit floating point value.
2. pi is a "proper noun". A proper noun can refer to a place, object or name of a person. In the above case, it is the name we have given to a specific realisation of the concept, double.
3. the value 3.14159 is a "concrete noun" that refers to the physical object.
The acronym to remember this language of nouns is APC (Abstract, Proper, Concrete).
Language also has the concept of collective nouns. A List of doubles is one example; similar to a gaggle of geese or a flight of swallows or even "a troop of kangaroos".
Taking a "lexical view" of C# is an interesting exercise and helps to explain programming to semiotics majors, for example.
Take the simple assignment: double pi = 3.14159;
Analysing this lexically we can say:
1. double is an "abstract noun". An abstract noun refers to a concept or idea. In this case, the idea is of a 64-bit floating point value.
2. pi is a "proper noun". A proper noun can refer to a place, object or name of a person. In the above case, it is the name we have given to a specific realisation of the concept, double.
3. the value 3.14159 is a "concrete noun" that refers to the physical object.
The acronym to remember this language of nouns is APC (Abstract, Proper, Concrete).
Language also has the concept of collective nouns. A List of doubles is one example; similar to a gaggle of geese or a flight of swallows or even "a troop of kangaroos".
No comments:
Post a Comment