| SCOUG-Programming Mailing List ArchivesReturn to [ 26 | 
November | 
2006 ]
 
 
 
Content Type:   text/plain 
In PL/I and SL/I the element is king.  All (every) operations  occur on an element-by-element basis.  This allows us, for
 example, to initialize an array (aggregate):
 dcl a (3,10) fixed bin (15) signed static;
 a = 0;
 an element;
 dcl a fixed dec (7,2) static;
 a = 0;
 or a structure (aggregate):
 dcl 1 a,
 2 b fixed bin (31),
 2 c fixed dec (5,2),
 2 d,
 3 e char(5);
 a = 0;
 
 
This last example illustrates the strong typing of PL/I coupled  with default arithmetic to character conversion of 'e'.  It
 would have done the same in the reverse direction, character
 to arithmetic, if we had written "a = '0';" in each instance.
 
 
In the examples of the array and structure 'a' is a group name.   In all three assignment statement instances the operation
 occurs on an element-by-element basis whether aggregate or
 element expression.  In the structure example above 'a' and 'd'
 are group names (with 'd' a sub-group within a) and 'b', 'c',
 and 'e' are element names.
 
 
The importance of this lies in PL/I's consistency in following  the element-by-element processing whether element or
 aggregate, the respect for element boundaries.  Couple this
 with implicit, default conversions among arithmetic (binary,
 decimal, and real (float)) and string (bit and character) while
 otherwise adhering to strong typing.
 
 
COBOL on the other hand has one rule for a MOVE statement  involving elements and another involving group (structure)
 names.  It has no ability to MOVE array aggregates except an
 element at a time (the same restriction as C).
 
 
Moreover elements within an aggregate have have two  possible correspondence, position (order within an aggregate,
 array or structure) and name (structure only).  A COBOL MOVE
 with a group name assigns a source to a target field without
 concern for underlying element differences.  Thus it does not
 do a position-to-position (element-by-element) assignment as
 does PL/I.  Thus it becomes the programmer's responsibility to
 insure correctness.
 
 
COBOL has a MOVE CORRESPONDING which does a structure  assignment on element names within differing group names.
 PL/I does the same with the BY NAME clause in the assignment
 statement.  In COBOL the MOVE and MOVE CORRESPONDING on
 group names behave differently.  The "casual" reader on
 seeing CORRESPONDING has no clue as to which of position or
 name applies.
 
 
The point here is that PL/I has only one rule, an  element-by-element operation, regardless of the involvement
 of an element or group name in an expression.  You can in
 PL/I use a builtin function, 'string', applied to a group name
 that allows it to perform as the COBOL MOVE with a group
 name.  Notice that the 'string' builtin function allows the
 programmer to "override" PL/I's normal operation on group
 names by effectively requesting its treatment as an element
 name.  Even here the element-by-element operation applies.
 
 
PL/I also supports array cross-sections like rows and columns.   For example, consider "dcl able (3,10) fixed dec (7,2);".  We
 can initialize it to zero: "able = 0;".  Imagine that we use row
 one to store minor; two, intermediate; and three, major totals.
 When we get a minor "break" we can roll its totals into the
 intermediate: "able(2,*) += able(1,*);" and reset the totals in
 row one to zero; "able(1,*) = 0;".  When we get an
 intermediate break we can roll the minor totals and the
 intermediate totals into the major row:
 "able(3,*) = able(1,*) + able(2,*);".  And reset rows 1 and 2
 to zero: "able(1,*), able(2,*) = 0;".  The same cross section
 ability extends to all higher dimension arrays (3 or greater).
 
 
Then we can have arrays of structures and structures of  arrays or any combination thereof.  We have strong typing
 with default conversions between arithmetic types (binary,
 decimal, float, supporting both floating decimal and binary),
 between string types (character and bit, fixed and variable
 length), and between arithmetic and string, anyone of which
 the programmer can override with builtin functions.
 
 
Then finally we can have operations on elements and  aggregates in any combination in an expression.
 
 
 
===================================================== 
 
To unsubscribe from this list, send an email message to "steward@scoug.com". In the body of the message,
 put the command "unsubscribe scoug-programming".
 
 
For problems, contact the list owner at "postmaster@scoug.com".
 
 
===================================================== 
 
 
 
Return to [ 26 | 
November | 
2006 ] 
 
 
 The Southern California OS/2 User Group
 P.O. Box 26904
 Santa Ana, CA  92799-6904, USA
 Copyright 2001 the Southern California OS/2 User Group.  ALL RIGHTS 
RESERVED. 
 
SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of International 
Business Machines Corporation.
All other trademarks remain the property of their respective owners.
 |