bestbarcoder.com

REPRESENTATION AND ABSTRACTION in .NET Generate Data Matrix in .NET REPRESENTATION AND ABSTRACTION

CHAPTER 2. REPRESENTATION AND ABSTRACTION generate, create barcode data matrix none on .net projects VB.NET Exhibit 2.17. A LISP Visual Studio .

NET data matrix barcodes function call with poor coherence. The following literal function is written in the primitive LISP syntax. It takes two parameters, x, and y.

It returns their product plus their di erence. It is being called with the arguments 3.5 and a + 2.

Note that the parameter declarations and matching arguments are widely separated. ((lambda ( x (+ (* x (- x 3.5 (+ a 2) y ) y) y) )) ).

This lack of lexical coherence makes it awkward and error prone for a human to match up the names with the values, as shown in Exhibit 2.17. The eye swims when interpreting this function call, even though it is simple and the code section is short.

Newer versions of LISP, for example Common LISP, 4 o er an improved syntax with the same semantics but better lexical coherence. Using the let syntax, dummy parameter names and actual values are written in pairs at the top, followed by the code. This syntax is shown at the bottom of Exhibit 2.

16, and an example of its use is shown in Exhibit 2.18. A third, and extreme, example of poor lexical coherence is provided by the syntax for function de nitions in SNOBOL.

A SNOBOL IV function is de ned by a function header of the following form: ( name ( parameter list ) local variable name list , entry label ) The code that de nes the action of the subroutine can be anywhere within the program module, and it starts at the line labeled entry label . It does not even need to be all in the same place,. Kessler[1988], p. 59. Exhibit 2.18. A LISP function call with good coherence.

The following function call is written in LISP using the extended let syntax. It is semantically equivalent to the call in Exhibit 2.17.

(let ((x 3.5) (y (+ a 2) )) ((+ (* x y) (- x y)) )) Compare the ease of matching up parameter names and corresponding arguments here, with the di culty in Exhibit 2.17.

The lexically coherent syntax is clearly better.. 2.3. LANGUAGE DESIGN Exhibit 2.19. Poor le xical coherence in SNOBOL.

SNOBOL has such poor lexical coherence that semantically unrelated lines can be interleaved, and no clear indication exists of the beginning or end of any program segment. This program converts English to Pig Latin. It is annotated below.

1. 2. 3.

4. 5. 6.

7. 8. 9.

PROC MAIN PIG1 LOOP DEFINE( PIG(X) Y, Z , PIG1 ) OUTPUT = PIG(IN) IN = INPUT PIG = NULL X SPAN( ) = X BREAK( ) . Y SPAN( ) = Y LEN(1) . Z = PIG = PIG Y Z AY OUTPUT = .

:(MAIN) :F(END) S(PROC) :F(RETURN) :F(RETURN) :(LOOP). Program Notes. The ma data matrix barcodes for .NET in program begins on line 1, with the declaration of a header for a subroutine named PIG.

Line 1 directs that execution is to continue on the line named MAIN. The subroutine declaration says that the subroutine PIG has one parameter, X, and two local variables, Y and Z. The subroutine code starts on the line with the label PIG1 .

Lines 2, 3, and 9 belong to the main program. They read a series of messages, translate each to Pig Latin, write them out, and quit when a zero-length string is entered. Lines 4 through 8 belong to the subroutine PIG.

Line 4 initializes the answer to the null string. Line 5 strips leading blanks o the parameter, X. Line 6 isolates the next word in X (if any), and line 7 isolates its rst letter.

Finally, line 8 glues this word onto the output string with its letters in a di erent order and loops back to line 6.. since each of its lin es may be attached to the next by a GOTO. Thus a main program and several subroutines could be interleaved. (We do admit that a sane programmer would never do such a thing.

) Exhibit 2.19 shows a SNOBOL program, with subroutine, that translates an English sentence into Pig Latin. The line numbers are not part of the program but are used to key it to the program notes that follow.

Principle of Distinct Representation Each separate semantic object should be represented by a separate syntactic item. Where a single syntactic item in the program is used for multiple semantic purposes, con icts are bound to occur, and one or both sets of semantics will be compromised. The line numbers in a BASIC program provide a good example.

BASIC was the very rst interactive programming language. It combined an on-line editor, a le system, and an interpreter to make a language in which simple problems could be programmed.
Copyright © bestbarcoder.com . All rights reserved.