Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #86713 > unrolled thread

C++ comma operator ?

Started byLynn McGuire <lynnmcguire5@gmail.com>
First post2022-09-29 23:48 -0500
Last post2022-09-30 23:48 -0500
Articles 20 on this page of 22 — 9 participants

Back to article view | Back to comp.lang.c++


Contents

  C++ comma operator ? Lynn McGuire <lynnmcguire5@gmail.com> - 2022-09-29 23:48 -0500
    Re: C++ comma operator ? Lynn McGuire <lynnmcguire5@gmail.com> - 2022-09-30 00:01 -0500
      Re: C++ comma operator ? Lynn McGuire <lynnmcguire5@gmail.com> - 2022-09-30 00:03 -0500
    Re: C++ comma operator ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2022-09-30 01:05 -0400
      Re: C++ comma operator ? red floyd <no.spam.here@its.invalid> - 2022-09-29 22:45 -0700
        Re: C++ comma operator ? scott@slp53.sl.home (Scott Lurndal) - 2022-09-30 15:16 +0000
          Re: C++ comma operator ? Lynn McGuire <lynnmcguire5@gmail.com> - 2022-09-30 13:53 -0500
            Re: C++ comma operator ? Gawr Gura <gawrgura@mail.hololive.com> - 2022-09-30 13:17 -0700
            Re: C++ comma operator ? scott@slp53.sl.home (Scott Lurndal) - 2022-10-01 16:56 +0000
              Re: C++ comma operator ? Lynn McGuire <lynnmcguire5@gmail.com> - 2022-10-01 13:13 -0500
              Re: C++ comma operator ? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-10-03 02:32 -0700
                Re: C++ comma operator ? Juha Nieminen <nospam@thanks.invalid> - 2022-10-03 10:48 +0000
      Re: C++ comma operator ? Lynn McGuire <lynnmcguire5@gmail.com> - 2022-09-30 13:32 -0500
        Re: C++ comma operator ? Lynn McGuire <lynnmcguire5@gmail.com> - 2022-10-01 14:30 -0500
          Re: C++ comma operator ? James Kuyper <jameskuyper@alumni.caltech.edu> - 2022-10-02 16:08 -0400
      Re: C++ comma operator ? Manfred <noname@add.invalid> - 2022-10-01 01:03 +0200
        Re: C++ comma operator ? Lynn McGuire <lynnmcguire5@gmail.com> - 2022-09-30 23:09 -0500
    Re: C++ comma operator ? Gawr Gura <gawrgura@mail.hololive.com> - 2022-09-29 23:19 -0700
      Re: C++ comma operator ? Lynn McGuire <lynnmcguire5@gmail.com> - 2022-09-30 13:31 -0500
    Re: C++ comma operator ? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2022-09-30 12:41 -0700
      Re: C++ comma operator ? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-10-03 02:38 -0700
    Re: C++ comma operator ? Lynn McGuire <lynnmcguire5@gmail.com> - 2022-09-30 23:48 -0500

Page 1 of 2  [1] 2  Next page →


#86713 — C++ comma operator ?

FromLynn McGuire <lynnmcguire5@gmail.com>
Date2022-09-29 23:48 -0500
SubjectC++ comma operator ?
Message-ID<th5sej$tqvo$1@dont-email.me>
Is this C++ statement using the comma operator ?

       write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
         hkl(3, i), f_calc(1, i), f_calc(2, i);

There is a large open source template library supporting this statement 
from Fortran to C++ Fable software.

Thanks,
Lynn

[toc] | [next] | [standalone]


#86714

FromLynn McGuire <lynnmcguire5@gmail.com>
Date2022-09-30 00:01 -0500
Message-ID<th5t84$tqvo$2@dont-email.me>
In reply to#86713
On 9/29/2022 11:48 PM, Lynn McGuire wrote:
> Is this C++ statement using the comma operator ?
> 
>        write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>          hkl(3, i), f_calc(1, i), f_calc(2, i);
> 
> There is a large open source template library supporting this statement 
> from Fortran to C++ Fable software.
> 
> Thanks,
> Lynn

If interested, you can see the Fable FEM (Fortran Emulation) code at:
    https://cci.lbl.gov/fable/

Lynn


[toc] | [prev] | [next] | [standalone]


#86715

FromLynn McGuire <lynnmcguire5@gmail.com>
Date2022-09-30 00:03 -0500
Message-ID<th5tan$tqvo$3@dont-email.me>
In reply to#86714
On 9/30/2022 12:01 AM, Lynn McGuire wrote:
> On 9/29/2022 11:48 PM, Lynn McGuire wrote:
>> Is this C++ statement using the comma operator ?
>>
>>        write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>>          hkl(3, i), f_calc(1, i), f_calc(2, i);
>>
>> There is a large open source template library supporting this 
>> statement from Fortran to C++ Fable software.
>>
>> Thanks,
>> Lynn
> 
> If interested, you can see the Fable FEM (Fortran Emulation) code at:
>     https://cci.lbl.gov/fable/
> 
> Lynn

Specifically at:
    https://cci.lbl.gov/fable/sources/fable/fem/

Lynn


[toc] | [prev] | [next] | [standalone]


#86716

FromJames Kuyper <jameskuyper@alumni.caltech.edu>
Date2022-09-30 01:05 -0400
Message-ID<th5tfi$u0ms$1@dont-email.me>
In reply to#86713
On 9/30/22 00:48, Lynn McGuire wrote:
> Is this C++ statement using the comma operator ?
> 
>        write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>          hkl(3, i), f_calc(1, i), f_calc(2, i);
> 
> There is a large open source template library supporting this statement 
> from Fortran to C++ Fable software.



If write, hkl, and f_calc are macros, you cannot be sure without
examining the macro definitions. However, if any of those three is an
ordinary function, it seems to me that this statement does unnecessarily
use the comma operator.

[toc] | [prev] | [next] | [standalone]


#86717

Fromred floyd <no.spam.here@its.invalid>
Date2022-09-29 22:45 -0700
Message-ID<th5vqf$u4b9$1@redfloyd.dont-email.me>
In reply to#86716
On 9/29/2022 10:05 PM, James Kuyper wrote:
> On 9/30/22 00:48, Lynn McGuire wrote:
>> Is this C++ statement using the comma operator ?
>>
>>         write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>>           hkl(3, i), f_calc(1, i), f_calc(2, i);
>>
>> There is a large open source template library supporting this statement
>> from Fortran to C++ Fable software.
> 
> 
> 
> If write, hkl, and f_calc are macros, you cannot be sure without
> examining the macro definitions. However, if any of those three is an
> ordinary function, it seems to me that this statement does unnecessarily
> use the comma operator.
> 

Not to mention that write() has an incorrect number of parameters,
assuming POSIX.

[toc] | [prev] | [next] | [standalone]


#86729

Fromscott@slp53.sl.home (Scott Lurndal)
Date2022-09-30 15:16 +0000
Message-ID<TKDZK.110060$tRy7.36805@fx36.iad>
In reply to#86717
red floyd <no.spam.here@its.invalid> writes:
>On 9/29/2022 10:05 PM, James Kuyper wrote:
>> On 9/30/22 00:48, Lynn McGuire wrote:
>>> Is this C++ statement using the comma operator ?
>>>
>>>         write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>>>           hkl(3, i), f_calc(1, i), f_calc(2, i);
>>>
>>> There is a large open source template library supporting this statement
>>> from Fortran to C++ Fable software.
>> 
>> 
>> 
>> If write, hkl, and f_calc are macros, you cannot be sure without
>> examining the macro definitions. However, if any of those three is an
>> ordinary function, it seems to me that this statement does unnecessarily
>> use the comma operator.
>> 
>
>Not to mention that write() has an incorrect number of parameters,
>assuming POSIX.
>

The write here is an analog of the fortran write,

   WRITE unit,format,iolist

And yes, it will conflict with the Unix (and POSIX) write function signature.

[toc] | [prev] | [next] | [standalone]


#86739

FromLynn McGuire <lynnmcguire5@gmail.com>
Date2022-09-30 13:53 -0500
Message-ID<th7dva$3h5$1@gioia.aioe.org>
In reply to#86729
On 9/30/2022 10:16 AM, Scott Lurndal wrote:
> red floyd <no.spam.here@its.invalid> writes:
>> On 9/29/2022 10:05 PM, James Kuyper wrote:
>>> On 9/30/22 00:48, Lynn McGuire wrote:
>>>> Is this C++ statement using the comma operator ?
>>>>
>>>>          write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>>>>            hkl(3, i), f_calc(1, i), f_calc(2, i);
>>>>
>>>> There is a large open source template library supporting this statement
>>>> from Fortran to C++ Fable software.
>>>
>>>
>>>
>>> If write, hkl, and f_calc are macros, you cannot be sure without
>>> examining the macro definitions. However, if any of those three is an
>>> ordinary function, it seems to me that this statement does unnecessarily
>>> use the comma operator.
>>>
>>
>> Not to mention that write() has an incorrect number of parameters,
>> assuming POSIX.
>>
> 
> The write here is an analog of the fortran write,
> 
>     WRITE unit,format,iolist
> 
> And yes, it will conflict with the Unix (and POSIX) write function signature.

Yes, the Fortran write is "WRITE (unit, format) var1, var2, var3, etc..."
    https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vnbs/index.html

And yes, I am wondering if I will have to use the abhorrent "using 
namespace fem;" statement to make sure that I get the correct write 
function (which is no guarantee at all).  Or, if I will have to use 
"fem::write".

Thanks,
Lynn

[toc] | [prev] | [next] | [standalone]


#86742

FromGawr Gura <gawrgura@mail.hololive.com>
Date2022-09-30 13:17 -0700
Message-ID<th7iss$13ibe$1@dont-email.me>
In reply to#86739
> And yes, I am wondering if I will have to use the abhorrent "using 
> namespace fem;" statement to make sure that I get the correct write 
> function (which is no guarantee at all).  Or, if I will have to use 
> "fem::write".

The write symbol in the example program is an object of the type 
fem::common_writer (you can see the declaration on line 70). Obviously, 
you will have to name the type explicitly, provide a using declaration, 
or rely on type inference when you declare a value of that type. write 
is just the name of the object though so you could call it anything you 
like. Perhaps:

fem::common_writer gregory(cmn);

or

fem::common_writer louise(cmn);

If you want to be able to use the POSIX write function in the same 
program you could get it with ::write rather than just write.

[toc] | [prev] | [next] | [standalone]


#86753

Fromscott@slp53.sl.home (Scott Lurndal)
Date2022-10-01 16:56 +0000
Message-ID<aj_ZK.97605$chF5.65591@fx08.iad>
In reply to#86739
Lynn McGuire <lynnmcguire5@gmail.com> writes:
>On 9/30/2022 10:16 AM, Scott Lurndal wrote:
>> red floyd <no.spam.here@its.invalid> writes:
>>> On 9/29/2022 10:05 PM, James Kuyper wrote:
>>>> On 9/30/22 00:48, Lynn McGuire wrote:
>>>>> Is this C++ statement using the comma operator ?
>>>>>
>>>>>          write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>>>>>            hkl(3, i), f_calc(1, i), f_calc(2, i);
>>>>>
>>>>> There is a large open source template library supporting this statement
>>>>> from Fortran to C++ Fable software.
>>>>
>>>>
>>>>
>>>> If write, hkl, and f_calc are macros, you cannot be sure without
>>>> examining the macro definitions. However, if any of those three is an
>>>> ordinary function, it seems to me that this statement does unnecessarily
>>>> use the comma operator.
>>>>
>>>
>>> Not to mention that write() has an incorrect number of parameters,
>>> assuming POSIX.
>>>
>> 
>> The write here is an analog of the fortran write,
>> 
>>     WRITE unit,format,iolist
>> 
>> And yes, it will conflict with the Unix (and POSIX) write function signature.
>
>Yes, the Fortran write is "WRITE (unit, format) var1, var2, var3, etc..."
>    https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vnbs/index.html
>
>And yes, I am wondering if I will have to use the abhorrent "using 
>namespace fem;" statement to make sure that I get the correct write 
>function (which is no guarantee at all).  Or, if I will have to use 
>"fem::write".

Given C++ supports function signature overloads, I doubt you'll have
a problem with this in particular unless you only have a single element
iolist.   (note that in F77, there were no parentheses in the WRITE statement).

[toc] | [prev] | [next] | [standalone]


#86756

FromLynn McGuire <lynnmcguire5@gmail.com>
Date2022-10-01 13:13 -0500
Message-ID<tha00b$1dp2$1@gioia.aioe.org>
In reply to#86753
On 10/1/2022 11:56 AM, Scott Lurndal wrote:
> Lynn McGuire <lynnmcguire5@gmail.com> writes:
>> On 9/30/2022 10:16 AM, Scott Lurndal wrote:
>>> red floyd <no.spam.here@its.invalid> writes:
>>>> On 9/29/2022 10:05 PM, James Kuyper wrote:
>>>>> On 9/30/22 00:48, Lynn McGuire wrote:
>>>>>> Is this C++ statement using the comma operator ?
>>>>>>
>>>>>>           write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>>>>>>             hkl(3, i), f_calc(1, i), f_calc(2, i);
>>>>>>
>>>>>> There is a large open source template library supporting this statement
>>>>>> from Fortran to C++ Fable software.
>>>>>
>>>>>
>>>>>
>>>>> If write, hkl, and f_calc are macros, you cannot be sure without
>>>>> examining the macro definitions. However, if any of those three is an
>>>>> ordinary function, it seems to me that this statement does unnecessarily
>>>>> use the comma operator.
>>>>>
>>>>
>>>> Not to mention that write() has an incorrect number of parameters,
>>>> assuming POSIX.
>>>>
>>>
>>> The write here is an analog of the fortran write,
>>>
>>>      WRITE unit,format,iolist
>>>
>>> And yes, it will conflict with the Unix (and POSIX) write function signature.
>>
>> Yes, the Fortran write is "WRITE (unit, format) var1, var2, var3, etc..."
>>     https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vnbs/index.html
>>
>> And yes, I am wondering if I will have to use the abhorrent "using
>> namespace fem;" statement to make sure that I get the correct write
>> function (which is no guarantee at all).  Or, if I will have to use
>> "fem::write".
> 
> Given C++ supports function signature overloads, I doubt you'll have
> a problem with this in particular unless you only have a single element
> iolist.   (note that in F77, there were no parentheses in the WRITE statement).

I suspect that you are thinking of the Fortran PRINT statement.
    https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vnap/index.html

The Fortran WRITE statement has always had parenthesis for the i/o unit 
and the format.
    https://docs.oracle.com/cd/E19957-01/805-4939/6j4m0vnbs/index.html

Lynn

[toc] | [prev] | [next] | [standalone]


#86779

FromTim Rentsch <tr.17687@z991.linuxsc.com>
Date2022-10-03 02:32 -0700
Message-ID<86tu4li75w.fsf@linuxsc.com>
In reply to#86753
scott@slp53.sl.home (Scott Lurndal) writes:

> Given C++ supports function signature overloads,

What C++ supports is function name overloading (and also operator
overloading).  "Function signature overloads" is a meaningless
phrase.

[toc] | [prev] | [next] | [standalone]


#86782

FromJuha Nieminen <nospam@thanks.invalid>
Date2022-10-03 10:48 +0000
Message-ID<theeln$190g$1@gioia.aioe.org>
In reply to#86779
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
> scott@slp53.sl.home (Scott Lurndal) writes:
> 
>> Given C++ supports function signature overloads,
> 
> What C++ supports is function name overloading (and also operator
> overloading).  "Function signature overloads" is a meaningless
> phrase.

"Function signature overload" would imply that two functions with the
same signature (ie. not only the same name, but the same amount of
parameters, each being of the exact same type, and the same visibility
scope) could be someone "overloaded". Which is of course not possible.

(Technically speaking you could try that with inline functions, but
having more than one different implemenation for a particular inline
function signature is quite explicitly UB in the standard.)

[toc] | [prev] | [next] | [standalone]


#86738

FromLynn McGuire <lynnmcguire5@gmail.com>
Date2022-09-30 13:32 -0500
Message-ID<th7cnv$12qn3$2@dont-email.me>
In reply to#86716
On 9/30/2022 12:05 AM, James Kuyper wrote:
> On 9/30/22 00:48, Lynn McGuire wrote:
>> Is this C++ statement using the comma operator ?
>>
>>         write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>>           hkl(3, i), f_calc(1, i), f_calc(2, i);
>>
>> There is a large open source template library supporting this statement
>> from Fortran to C++ Fable software.
> 
> 
> 
> If write, hkl, and f_calc are macros, you cannot be sure without
> examining the macro definitions. However, if any of those three is an
> ordinary function, it seems to me that this statement does unnecessarily
> use the comma operator.

hkl and f_calc are two dimensioned arrayed objects.

Thanks,
Lynn

[toc] | [prev] | [next] | [standalone]


#86757

FromLynn McGuire <lynnmcguire5@gmail.com>
Date2022-10-01 14:30 -0500
Message-ID<tha4ft$18hq$1@gioia.aioe.org>
In reply to#86738
On 9/30/2022 1:32 PM, Lynn McGuire wrote:
> On 9/30/2022 12:05 AM, James Kuyper wrote:
>> On 9/30/22 00:48, Lynn McGuire wrote:
>>> Is this C++ statement using the comma operator ?
>>>
>>>         write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>>>           hkl(3, i), f_calc(1, i), f_calc(2, i);
>>>
>>> There is a large open source template library supporting this statement
>>> from Fortran to C++ Fable software.
>>
>>
>>
>> If write, hkl, and f_calc are macros, you cannot be sure without
>> examining the macro definitions. However, if any of those three is an
>> ordinary function, it seems to me that this statement does unnecessarily
>> use the comma operator.
> 
> hkl and f_calc are two dimensioned arrayed objects.
> 
> Thanks,
> Lynn

 > Subscripted using hkl(3,i)? I thought this was supposed to be C++ 
code, not Fortran?

They are C++ objects acting like Fortran arrays.

Lynn

[toc] | [prev] | [next] | [standalone]


#86770

FromJames Kuyper <jameskuyper@alumni.caltech.edu>
Date2022-10-02 16:08 -0400
Message-ID<thcr4l$1qk6k$1@dont-email.me>
In reply to#86757
On 10/1/22 15:30, Lynn McGuire wrote:
> On 9/30/2022 1:32 PM, Lynn McGuire wrote:
>> On 9/30/2022 12:05 AM, James Kuyper wrote:
>>> On 9/30/22 00:48, Lynn McGuire wrote:
>>>> Is this C++ statement using the comma operator ?
>>>>
>>>>         write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>>>>           hkl(3, i), f_calc(1, i), f_calc(2, i);
>>>>
>>>> There is a large open source template library supporting this statement
>>>> from Fortran to C++ Fable software.
>>>
>>>
>>>
>>> If write, hkl, and f_calc are macros, you cannot be sure without
>>> examining the macro definitions. However, if any of those three is an
>>> ordinary function, it seems to me that this statement does unnecessarily
>>> use the comma operator.
>>
>> hkl and f_calc are two dimensioned arrayed objects.
>>
>> Thanks,
>> Lynn
> 
>  > Subscripted using hkl(3,i)? I thought this was supposed to be C++ 
> code, not Fortran?
> 
> They are C++ objects acting like Fortran arrays.

They have an object type with an operator() overload that takes the
indices for the array access? If so, I think that describing them as
"arrayed objects" is a bit misleading.

[toc] | [prev] | [next] | [standalone]


#86743

FromManfred <noname@add.invalid>
Date2022-10-01 01:03 +0200
Message-ID<th7skd$1rh2$1@gioia.aioe.org>
In reply to#86716
On 9/30/2022 7:05 AM, James Kuyper wrote:
> On 9/30/22 00:48, Lynn McGuire wrote:
>> Is this C++ statement using the comma operator ?
>>
>>         write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>>           hkl(3, i), f_calc(1, i), f_calc(2, i);
>>
>> There is a large open source template library supporting this statement
>> from Fortran to C++ Fable software.
> 
> 
> 
> If write, hkl, and f_calc are macros, you cannot be sure without
> examining the macro definitions. However, if any of those three is an
> ordinary function, it seems to me that this statement does unnecessarily
> use the comma operator.
> 

"unnecessarily" is not necessarily true here: others have mentioned an 
overloaded comma operator.
/If/ this is what is actually going on here, then you might need to keep 
the sequence of commas in place, or go through some nontrivial rewrite.

[toc] | [prev] | [next] | [standalone]


#86746

FromLynn McGuire <lynnmcguire5@gmail.com>
Date2022-09-30 23:09 -0500
Message-ID<th8ehj$18shn$1@dont-email.me>
In reply to#86743
On 9/30/2022 6:03 PM, Manfred wrote:
> On 9/30/2022 7:05 AM, James Kuyper wrote:
>> On 9/30/22 00:48, Lynn McGuire wrote:
>>> Is this C++ statement using the comma operator ?
>>>
>>>         write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>>>           hkl(3, i), f_calc(1, i), f_calc(2, i);
>>>
>>> There is a large open source template library supporting this statement
>>> from Fortran to C++ Fable software.
>>
>>
>>
>> If write, hkl, and f_calc are macros, you cannot be sure without
>> examining the macro definitions. However, if any of those three is an
>> ordinary function, it seems to me that this statement does unnecessarily
>> use the comma operator.
>>
> 
> "unnecessarily" is not necessarily true here: others have mentioned an 
> overloaded comma operator.
> /If/ this is what is actually going on here, then you might need to keep 
> the sequence of commas in place, or go through some nontrivial rewrite.

As time goes on, some of these write statements will be rewritten in 
conventional c++ code but for now, the Fortran like expression will be 
good enough.

Thanks,
Lynn

[toc] | [prev] | [next] | [standalone]


#86718

FromGawr Gura <gawrgura@mail.hololive.com>
Date2022-09-29 23:19 -0700
Message-ID<th61pm$ufja$1@dont-email.me>
In reply to#86713
> Is this C++ statement using the comma operator ?
> 
>        write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>          hkl(3, i), f_calc(1, i), f_calc(2, i);
> 
> There is a large open source template library supporting this statement 
> from Fortran to C++ Fable software.
> 
> Thanks,
> Lynn

Assuming you're looking at the same example file on the fable web page
as I am (sf.cpp at line 113) then I think the answer is yes. I believe
this is a series of calls to fem::write_loop::operator,()

[toc] | [prev] | [next] | [standalone]


#86737

FromLynn McGuire <lynnmcguire5@gmail.com>
Date2022-09-30 13:31 -0500
Message-ID<th7cm8$12qn3$1@dont-email.me>
In reply to#86718
On 9/30/2022 1:19 AM, Gawr Gura wrote:
>> Is this C++ statement using the comma operator ?
>>
>>        write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>>          hkl(3, i), f_calc(1, i), f_calc(2, i);
>>
>> There is a large open source template library supporting this 
>> statement from Fortran to C++ Fable software.
>>
>> Thanks,
>> Lynn
> 
> Assuming you're looking at the same example file on the fable web page
> as I am (sf.cpp at line 113) then I think the answer is yes. I believe
> this is a series of calls to fem::write_loop::operator,()

Yes, that does seem to be true.

Thanks,
Lynn

[toc] | [prev] | [next] | [standalone]


#86741

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2022-09-30 12:41 -0700
Message-ID<871qrsmyyl.fsf@nosuchdomain.example.com>
In reply to#86713
Lynn McGuire <lynnmcguire5@gmail.com> writes:
> Is this C++ statement using the comma operator ?
>
>       write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
>         hkl(3, i), f_calc(1, i), f_calc(2, i);

Yes, five of them, easily seen by reformatting the code:

    write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"),
    hkl(1, i),
    hkl(2, i),
    hkl(3, i),
    f_calc(1, i),
    f_calc(2, i);

Assuming there's no macro funny business going on, that's 6 function
calls (or macro invocations?) separated by comma operators.  (The commas
separating function arguments are of course not comma operators.)

Replacing the comma at the end of each line by a semicolon (and possibly
surrounding the whole thing with curly braces) yields equivalent code.
The braces are needed if the context is something like:

    if (condition)
        write(6, "(3(1x,i3),1x,f12.6,1x,f12.6)"), hkl(1, i), hkl(2, i),
        hkl(3, i), f_calc(1, i), f_calc(2, i);

Things might change if any of write, hkl, and f_calc is a macro.  If
they're well behaved macros, it shouldn't matter.

> There is a large open source template library supporting this
> statement from Fortran to C++ Fable software.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.c++


csiph-web