Cobol picture data

Eric Jacobsen <>
Wed, 22 Apr 1992 19:33:19 GMT

          From comp.compilers

Related articles
Re: Why is Cobol ignored in compiler textbooks? (1992-04-22)
Cobol picture data (Eric Jacobsen) (1992-04-22)
Re: Cobol picture data (1992-04-23)
Re: Cobol picture data md@sco.COM (1992-04-27)
| List of all articles for this month |

Newsgroups: comp.compilers
From: Eric Jacobsen <>
Keywords: Cobol
Organization: Compilers Central
References: 92-04-099
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.)


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.