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 2 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 2 of 2 — ← Prev page 1 [2]


#86780

FromTim Rentsch <tr.17687@z991.linuxsc.com>
Date2022-10-03 02:38 -0700
Message-ID<86pmf9i6vi.fsf@linuxsc.com>
In reply to#86741
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> 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.

In C++ that rule does not hold, because of the possibility of an
overloaded operator,().  Indeed in this case it appears that
there is an operator,() overload, and that is what makes this
statement work;  changing the statement to be a series of
semicolon-terminated statements wouldn't work at all.

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


#86748

FromLynn McGuire <lynnmcguire5@gmail.com>
Date2022-09-30 23:48 -0500
Message-ID<th8gq8$19289$1@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

I just noted that f2c is using the comma operator in translated 
expressions also, original fortran code:

       test = abs( sienth(1) - vdy(adia_sienth_ptr+i) )

New C/C++ code:

       test = (d__1 = sienth[1] - vdyn1.vdy[adia_sienth_ptr + i - 1], 
abs(d__1));

Interesting.  Can abs() under C/C++ not handle the expression inside it 
?  That does not make sense.

Thanks,
Lynn

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

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


csiph-web