Examples of using Compile-time in English and their translations into Serbian
{-}
-
Colloquial
-
Ecclesiastic
-
Computer
-
Latin
-
Cyrillic
In both cases,work is moved to compile-time.
This enables compile-time checking of proper return and return value from the procedure.
Modern compilers offer IPO as an option at compile-time.
A macro, which is also a compile-time language feature, generates code in-line using text manipulation and substitution.
The actual class of the object being referenced is impossible to predict at compile-time.
LLVM can also generate relocatable machine code at compile-time or link-time or even binary machine code at run-time.
Lazy evaluation allows control structures to be defined normally, andnot as primitives or compile-time techniques.
This approach provides compile-time polymorphism that is often more efficient than traditional run-time polymorphism.
Advantages provided bycompiler-specified type systems include: Optimization- Static type-checking may provide useful compile-time information.
Some other languages support similar, if not more powerful, compile-time facilities(such as Lisp macros), but those are outside the scope of this article.
Compile-time garbage collection is a form of static analysis allowing memory to be reused and reclaimed based on invariants known during compilation.
Dependency injection is a design pattern that allows the removal of hard-coded dependencies andmakes it possible to change them, whether at run-time or compile-time.
What exactly"programming at compile-time" means can be illustrated with an example of a factorial function, which in non-template C++ can be written using recursion as follows.
The choice of browser is determined by the optional browser argument if one is provided,by the$BROWSER environment variable, or by a compile-time default if that is unset(usually lynx).
As another, more significant,example of compile-time loop unrolling, template metaprogramming can be used to create length-n vector classes(where n is known at compile time).
Domain-specific languages which are implemented using programming language macro systems, and which are converted orexpanded into a host general purpose language at compile-time or read-time.
This is done using a compile-time analysis to determine whether an object allocated within a function is not accessible outside of it(i.e. escape) to other functions or threads.
Although a time-space trade-off occurs(i.e., space used is speed gained), this differs from some other optimizations that involve time-space trade-off, such as strength reduction,in that memoization is a run-time rather than compile-time optimization.
In both cases,the inlined function body can then undergo further compile-time optimizations by the compiler, including constant folding, which may move some computations to compile time.
Compile-time versus execution-time tradeoff If a great deal of template metaprogramming is used, compilation may become slow; section 14.7.1 of the current standard defines the circumstances under which templates are implicitly instantiated.
For example, a memory-safe language will, or else statically guarantee(i.e., at compile time before execution)that array accesses out of the array boundaries will cause compile-time and perhaps runtime errors.
In some languages,classes are only a compile-time feature(new classes cannot be declared at runtime), while in other languages classes are first-class citizens, and are generally themselves objects typically of type Class or s.
Some common reasons to use templates are to implement generic programming(avoiding sections of code which are similar except for some minor variations) orto perform automatic compile-time optimization such as doing something once at compile time rather than every time the program is run- for instance, by having the compiler unroll loops to eliminate jumps and loop count decrements whenever the program is executed.
Macro systems often have limited compile-time process flow abilities and usually lack awareness of the semantics and type system of their companion language(an exception should be made with Lisp's macros, which are written in Lisp itself and involve manipulation and substitution of Lisp code represented as data structures as opposed to text).
The factorial example above is one example of compile-time code optimization in that all factorials used by the program are pre-compiled and injected as numeric constants at compilation, saving both run-time overhead and memory footprint.
What exactly"programming at compile-time" means can be illustrated with an example of a factorial function, which in non-template C++ can be written using recursion as follows: unsigned int factorial(unsigned int n){ return n== 0? 1: n* factorial(n- 1);}// Usage examples:// factorial(0) would yield 1;// factorial(4) would yield 24.