Hello,
SWAP was proposed for f08, and was not accepted.
It was inflated to involve not only swaps, but also type-changing assignments.
The latter could not be optimized to the same degree as straight-forward swaps,
are more complicated, and little use could be found for them. Type changing swaps
are also harder to understand when reading the code, perhaps swap is the wrong word.
What does swap( real, complex) do? The proposal died.
The "need" for += et al. is substantially reduced by the associate construct,
whereby p => name1( i, j, k)% name2( more, stuff)% yet_another_name%( etc) can
be used to clarify a whole series of statements, not only the prototype <op>=.
And many modern programming editors will complete a name,
given the first few characters. There's always copy-and-paste, if, like me,
you don't always fall in love with the latest really-cool-editor-trick.
Lastly, it boiled down to the work-to-workers ratio. It just wasn't high enough
in priority to do with the people around the table. The f08 worklist was
getting longer than some wanted, and addressing parallelism was the highest priority
for many on the committees.
At any rate, that's how I recall it. :-)
On Jan 6, 2011, at 11:59 AM, Loren P Meissner wrote:
> Another operation, whose Fortran history I can’t remember, would be an intrinsic function “SWAP (A, B)” that “simultaneously” assigns A to B and B to A, subject to all the constraints and interpretations of assignment? Wouldn’t a compiler be able to optimize in some cases, as when one or both are in a register, and make it more efficient than “Temp = A; A = B; B = Temp”?
> Or spell it some other way like <=> ?
> Or is it there already?
> I seem to remember some language(s) that did it.
>
> Loren P Meissner
>
> “Truth depends on a quest to discover what’s really out there, what really happened. It isn’t given over to you by simply following a set of rules.” – Errol Morris
> “Math education is not something you can dictate. The way to make a tree grow is not to yank it upward by the branches. ” – Professor Hung-Hsi Wu, UC Berkeley
>
> -----Original Message-----
> From: Fortran 90 List [mailto:[log in to unmask]] On Behalf Of Bill Long
> Sent: Thursday, January 06, 2011 8:52 AM
> To: [log in to unmask]
> Subject: Re: Composite assignment operators in Fortran?
>
> Hi Alistair,
>
> This has been requested more than once. The operator "/=" already has a different meaning, but it is probably possible to work around that.
> People seem to mostly want += and *= anyway. The past arguments
> against the idea have been more stylistic than technical, and evolving programming habits (particularly multi-part derived type references) might tip the balance the next time around.
>
> Cheers,
> Bill
>
>
>
> On 1/6/11 4:05 AM, Alistair Hart wrote:
> > Hi,
> >
> > Is there a reason why C-style composite assignment operators (+= etc.) are not supported in Fortran?
> >
> > I've certainly spent a lot of time over the years looking for bugs in lines like:
> >
> > res_tmp(1:npoints,2,3) = res_tmp(1:npoints,2,3) +&
> > data_y_qqg_alg_basic(1:npoints) * tmp(1:npoints)
> >
> > where different slices of res_tmp were (mistakenly) specified on each side of the assignment. Using "+=" would also make the code more compact.
> >
> > Apologies if the answer is an old story - Googling for symbols is non-trivial.
> >
> > Thanks in anticipation,
> >
> > Alistair Hart.
>
> --
> Bill Long [log in to unmask]
> Fortran Technical Support & voice: 651-605-9024
> Bioinformatics Software Development fax: 651-605-9142
> Cray Inc./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
--
Cheers!
Dan Nagle
|