Adding UNION/MAP -- Feedback and tips pls!

N.M. Maclaren nmm1@cam.ac.uk
Mon Mar 4 20:34:00 GMT 2013


On Mar 4 2013, Russell Brennan wrote:
>>>
>>> Forgive my ignorance, what is an unchecked union?  Also, what do you
>>> mean by preservation of overlaid data?
>> One where you can assign one member of the union and read another.
>
>Isn't that the definition of a union?  ie, all unions are unchecked?

No, but this is not the place to have that discussion.  Algol 68 ones
and standard Fortran CLASS are checked.

>> Er, have you seen the specification of DEC UNION?  I suggest getting
>> hold of a copy before implementing it!  It's better to read it than
>> for me to play Chinese whispers.
>
>Let's not get snarky!  Didn't you previously state that you yourself
>could not find a specification?  I'm going off of this:
>http://wwwth.mpp.mpg.de/members/hahn/decfortman.html#359 and I think
>the idea behind union/map is pretty straightforward.

No - that was Cray pointers.  DEC UNION was always well-specified,
but horrible.  And the overlaying feature is in that morass of mangled
HTML: "However, if you overlay one variable with another smaller variable,
that portion of the initial variable is retained that is not overlaid.
Depending on the application, the retained portion of an overlaid variable
may or may not contain meaningful data and can be utilized at a later
point in the program."

If you implement an undocumented variant of DEC UNION, you will definitely
be harming gfortran.

>Perhaps from an academic standpoint unions have no place.  In practice
>though, they can be quite useful and imo make the developer's intent
>much more clear.  I find them to be a more clear construct than
>equivalence, for instance.

Just as GOTO spaghetti is clearer than writing directly to the program
counter.  I suggest that you check out my credentials before making silly
remarks.

>  That being said, my sole interest in
>adding the extension is to facilitate compilation of legacy code in
>which refactoring is not going to happen.  I'm sure there is plenty of
>code out there besides mine that use the extension, and could benefit
>from not having to purchase a closed-source compiler.

Even if that it is the case, it is still no argument for enabling it by
default.


Regards,
Nick Maclaren.



More information about the Fortran mailing list