-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Frank Haferkorn edited this page Oct 20, 2020
·
3 revisions
This GITHUB-REPO is a testbed for a special kind of Modern C++ CORE LANGUAGE-extension.
- loop(N, ...){}
- typed_loop(type, N, ...)
- named_loop_up(id, N, ...){}
- named_loop_down(id, N, ..){}
With optional post-operation expressions. N should be of integral type. These new COMPOUNDs can be easily imlemented via the cpp-preprocessor.
more examples: https://github.com/F-Haferkorn/ogis-modern-cxx-future-cpp/tree/master/future-cpp-loop/ogis-cpp-loop.examples/examples
template<typename TPtr, typename TRowSize, typename TColSize, typename TStrideSize > TPtr matrix_copy( TPtr tgt, TPtr src, TRowSize nRows, TColSize nColumns, TStrideSize stride) { // compiler can mangled the loop-internal integral-types tgt and src in registers. loop(nRows, tgt+=stride, src+=stride) // apply strid eafter each row to tgt and src loop(nbofColumms, tgt++, src++) *tgt = *src; return tgt; }
Advantages:
- With recent compilers this gives not really a speed advantage, but is no way slower than a full for(;;){} iteration.
- It increases readability.
- It raises tachability. One of the first things learning C is the for(;;) Compound- statement.
- Assignment, Boolean Expressions and Increment are heavy stuff for the younger audience.
- Pupils can earn the principle of iteration (using loop) without knowing about boolean algebra and conditions.
- There are Assmembler Instruction sets like tDiguital Signal Processor TMS320, that allows Repetitions on a machjine code level.
Future C/C++ compilers
- can take advantage the reduced degree of freedom of the iteration and
- could make heavily use of ALU-register operation of DSP-Architectures formulated
- post-operations like in loop(N,src++, tgt++)