Changeset 3b21c96


Ignore:
Timestamp:
Jan 16, 2025, 11:57:29 AM (2 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
f6f7b52
Parents:
7aa246cb
Message:

update comparison of C++ and Cforall I/O

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified doc/uC++toCFA/uC++toCFA.tex

    r7aa246cb r3b21c96  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Fri Nov 15 09:55:34 2024
    14 %% Update Count     : 6249
     13%% Last Modified On : Thu Jan 16 11:49:47 2025
     14%% Update Count     : 6281
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    197197
    198198
    199 \section{Stream I/O}
    200 
    201 \CFA output streams automatically separate values and insert a newline at the end of the print.
    202 \begin{cquote}
    203 \begin{tabular}{@{}l|l@{}}
    204 \begin{uC++}
    205 #include <@iostream@>
    206 using namespace std;
    207 int i;   double d;   char c;
    208 cin >> i >> d >> c;
    209 cout << i << ' ' << d << ' ' << c | endl;
    210 \end{uC++}
    211 &
    212 \begin{cfa}
    213 #include <@fstream.hfa@>
    214 
    215 int i;   double d;   char c;
    216 sin | i | d | c;
    217 sout | i | d | c
    218 \end{cfa}
    219 \end{tabular}
    220 \end{cquote}
    221 
    222 
    223199\section{Looping}
    224200
     
    240216for ( i; 0 @-@~ 10 ) { ... }
    241217\end{cfa}
    242 \\
    243 \hline
     218\end{tabular}
     219\end{cquote}
     220
     221\begin{cquote}
     222\begin{tabular}{@{}l|l@{}}
    244223\begin{uC++}
    245224int i = 0
     
    253232@else@ { ... } // i == 10
    254233\end{cfa}
    255 \\
    256 \hline
     234\end{tabular}
     235\end{cquote}
     236
     237\begin{cquote}
     238\begin{tabular}{@{}l|l@{}}
    257239\begin{uC++}
    258240@L1:@ for ( ;; ) {
     
    271253        }
    272254}
     255\end{cfa}
     256\end{tabular}
     257\end{cquote}
     258
     259
     260\section{Stream I/O}
     261
     262\CFA output streams automatically separate values and insert a newline at the end of the print.
     263\begin{cquote}
     264\begin{tabular}{@{}l|l@{}}
     265\begin{uC++}
     266#include <@iostream@>
     267using namespace std;
     268int i;   double d;   char c;
     269cin >> i >> d >> c;
     270cout << i << ' ' << d << ' ' << c << endl;
     271\end{uC++}
     272&
     273\begin{cfa}
     274#include <@fstream.hfa@>
     275
     276int i;   double d;   char c;
     277sin | i | d | c;
     278sout | i | d | c
     279\end{cfa}
     280\end{tabular}
     281\end{cquote}
     282To disable/enable automatic newline at the end of printing, use @nlOff@/@nlOn@ and @nl@.
     283\begin{cquote}
     284\begin{tabular}{@{}l|l@{}}
     285\begin{uC++}
     286
     287for ( int i = 0; i < 5; i += 1 ) cout << i << ' ';
     288cout << @endl@;
     289
     2900 1 2 3 4
     291\end{uC++}
     292&
     293\begin{cfa}
     294sout | @nlOff@; // disable auto nl
     295for ( i; 5 ) sout | i;
     296sout | @nl@;
     297sout | @nlOn@;  // reenable auto nl
     2980 1 2 3 4
     299\end{cfa}
     300\end{tabular}
     301\end{cquote}
     302Floating-point numbers without a fraction print with a decimal point, which can be disabled with @nodp@.
     303\begin{cquote}
     304\begin{tabular}{@{}l|l@{}}
     305\begin{uC++}
     306cout << 3.0 << ' ' << showpoint << setprecision(0) << 3.0 << endl;
     3073 3.
     308\end{uC++}
     309&
     310\begin{cfa}
     311sout | @nodp( 3.0 )@ | 3.0;
     3123 3.
    273313\end{cfa}
    274314\end{tabular}
     
    291331        if ( ... ) @_Throw@ E( /* initialization */ );
    292332                ...
    293 } @_CatchResume@( E & ) { ... // reference
    294 } catch( E & ) { ...
    295 } catch( ... ) { ... // catch any
    296 } _Finally { ...
    297 }
     333} @_CatchResume@( E & /* reference */ ) { ... }
     334  catch( E & ) { ... }
     335  catch( ... /* catch any */ ) { ... }
     336  _Finally { ... }
    298337\end{uC++}
    299338&
     
    308347        if ( ... ) @throw@ @ExceptionInst@( E, /* intialization */ );
    309348        ...
    310 } @catchResume@( E * ) { ... // pointer
    311 } catch( E * ) { ...
    312 } catch( exception_t * ) { ... // catch any
    313 } finally { ...
    314 }
     349} @catchResume@( E @*@ /* pointer */ ) { ... }
     350  catch( E * ) { ... }
     351  catch( exception_t @*@ /* catch any */ ) { ... }
     352  finally { ... }
    315353\end{cfa}
    316354\end{tabular}
     
    330368                        ... suspend(); ...
    331369                }
    332         } @_CatchResume@( E & ) { // reference
    333                 ...
    334         } catch( E & ) {
    335                 ...
    336         }
     370        } @_CatchResume@( E & /* reference */ ) { ... }
     371          catch( E & ) { ... }
    337372}
    338373\end{uC++}
     
    346381                ... suspendPoll ...
    347382                disable_ehm();
    348         } @catchResume@( E * ) { // pointer
    349                 ...
    350         } catch( E & ) {
    351                 ...
    352         }
     383        } @catchResume@( E * ) { ... }
     384          catch( E & ) { ... }
    353385}
    354386\end{cfa}
Note: See TracChangeset for help on using the changeset viewer.