|Re: Why is Cobol ignored in compiler textbooks? firstname.lastname@example.org (1992-04-22)|
|Cobol picture data email@example.com (Eric Jacobsen) (1992-04-22)|
|Re: Cobol picture data firstname.lastname@example.org (1992-04-23)|
|Re: Cobol picture data md@sco.COM (1992-04-27)|
|From:||Eric Jacobsen <email@example.com>|
|Date:||Wed, 22 Apr 1992 19:33:19 GMT|
> [One issue I haven't seen addressed is Cobol picture data, which has a
> numeric value in a numeric context and a string value in a string context.
> Do you keep two copies, one copy and convert on demand, or what? -John]
In a language I use, numbers are represented externally (stored in the
data base) as strings. When you use the variables in a numeric context
(i.e. X = X * 5), the strings are converted to numbers internally. When
used in a string context, they are converted back to a numeric format.
Internally, the interpreter uses a structure with a 'type' code, for the
current type, and a union for the current value. It converts values on
Keeping two values at all times would be (more) inefficient, since you
would have to convert after each operation. Instead, you could perform
the check, and convert if needed prior to each operation. The language is
a byte-code interpreter, so there isn't any code bloat by these checks.
(Say what you will about efficiency, but it's a language for data base
operations. I/O is the bottleneck. Although for non-I/O-bound
operations, it's reeaalllyyy ssllooww.)
Return to the
Search the comp.compilers archives again.