iK4tsu/dlings

Support different compilers and extra arguments for each exercise

iK4tsu opened this issue · 0 comments

Only dmd is supported as the compiler to use for all exercises. Different compilers provide support for extra compilation flags. One example is --float-abi. This flag would be useful to create a reproducible exercise teaching to not rely on == for floating point comparisons.

Taken from Programming in D

import std.stdio;

void main() {
    float result = 0;

    // Adding 0.001 for a thousand times:
    int counter = 1;
    while (counter <= 1000) {
        result += 0.001;
        ++counter;
    }

    if (result == 1) {
        writeln("As expected: 1");

    } else {
        writeln("DIFFERENT: ", result); // this is the output
    }
}

Another example

float div(float a, float b) { return a / b; }

void main()
{
	float value = div(2, 25);
	writeln(value == 0.08); // false
}

Supporting extra arguments would also be useful independently of supporting other compilers: previews, compiling in release with some contracts, ...