January 2020
Intermediate to advanced
532 pages
13h 31m
English
When a function is called, the type of its arguments are known and then the function is compiled with the exact data types from its arguments. This is called specialization. What exactly is a barrier function? It simply exploits Julia's function specialization to stabilize the type of variable as part of a function call. We will continue the preceding example to illustrate the technique.
First, let's create a simple function that makes use of the type unstable function, as mentioned earlier:
function double_sum_of_random_data(n) data = random_data(n) total = 0 for v in data total += 2 * v end return totalend
The double_sum_of_random_data function is just a simple function that returns the sum of doubled random ...
Read now
Unlock full access