From: | George Neuner <gneuner2@comcast.net> |
Newsgroups: | comp.compilers |
Date: | Thu, 06 Jan 2011 15:45:23 -0500 |
Organization: | A noiseless patient Spider |
References: | 10-12-040 10-12-052 10-12-057 10-12-065 11-01-004 <vcn5i6ptrfe19bs439e84uhjisgof61mhs@4ax.com> |
Keywords: | design, types |
Posted-Date: | 06 Jan 2011 15:50:11 EST |
On Tue, 04 Jan 2011 03:43:15 -0500, George Neuner
<gneuner2@comcast.net> wrote:
>On Fri, 31 Dec 2010 08:57:37 -0500, Robert A Duff
><bobduff@shell01.TheWorld.com> wrote:
>
>>George Neuner <gneuner2@comcast.net> writes:
>>
>>> The problem here, I think, is that everyone is fixated on Pascal's
>>> questionable implementation. IMNHO, Wirth royally screwed up by
>>> permitting programmer access to the tag field and by requiring the
>>> programmer to set it correctly ... particularly, in conjunction with
>>> permitting the new() function to accept alternation tag values and
>>> return differently sized blocks.
>>
>>Permitting access to the tag field is not the problem,
>>nor is using differently sized blocks.
>>Permitting the tag to be arbitrarily modified is the problem.
That's what I thought I said. The problem was that the tag could be
modified independently and so might not correspond to the layout
selected at allocation.
>>> I can't imagine why Ada chose to perpetuate these misfeatures.
>>
>>I can't imagine that either. ;-)
>>
>>Ada doesn't perpetuate the misfeatures of Pascal in this area.
>>In Ada, you can't change the tag fields (called "discriminants")
>>without filling in all the other fields. For ex: ...
Yes, I goofed in saying Ada ... I was thinking about the differences
between variant handling in Pascal's follow-ons Modula 2 and Ada, and
then I typed the wrong one.
Modula 2 handled tagged variants just as did Pascal and added the
untagged variant for bad measure. The compiler would complain if you
accessed a member not in the selected alternation, but it did not
enforce setting all the members.
I do agree that Ada made exposed tags safe(r). Even so, I personally
don't like tags to be exposed even if the compiler does enforce
modifying all the variant members together.
>>> To see good implementations of variant records, take a look at
>>> alternation (sum) types in the ML family of languages.
>>
>>Yes, the ML way is better than the Ada way, for most purposes.
>>One thing you can do in Ada is to control the bit-level
>>layout, which may be useful in interfacing to hardware
>>devices and the like.
Yes. ML wasn't designed with device control in mind and hidden tags
(for any purpose) create problems for overlaying a record schema on an
arbitrary address range. But that can be handled with a memory
management scheme that allows the tag(s) to be stored separately from
the record.
George
Return to the
comp.compilers page.
Search the
comp.compilers archives again.