Related articles |
---|
Re: Why is Cobol ignored in compiler textbooks? preston@dawn.cs.rice.edu (1992-04-22) |
Cobol picture data ericj@csn.org (Eric Jacobsen) (1992-04-22) |
Re: Cobol picture data reid@csgrad.cs.vt.edu (1992-04-23) |
Re: Cobol picture data md@sco.COM (1992-04-27) |
Newsgroups: | comp.compilers |
From: | Eric Jacobsen <ericj@csn.org> |
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
demand.
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.)
Eric
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.