This README is currently under construction.
ik4tsu / dlings Goto Github PK
View Code? Open in Web Editor NEWA rustlings clone designed to teach you how to program in D
A rustlings clone designed to teach you how to program in D
First of all thanks for dlings :) Very good idea to have something like this for dlang.
I am running on osx and replaced in your source the calls to dmd with
Exercise.Type.compile: ["rdmd"],
Exercise.Type.test: ["rdmd", "-unittest", "-main"],
as rdmd is available for the dmd as well as for the ldc compiler distribution.
This worked nicely for me, but then I saw, that the output after a filechange is blocked until I press enter in the interactive watchmode.
I tried to fix this, but did not manage. One problem could be, that the stderr on osx with ldc at the moment dumps a lot of text like this line
ld: warning: no platform load command found in '/Users/xxxx/dlang/ldc-1.35.0/lib/libdruntime-ldc.a[160](sections_darwin_64.o)', assuming: macOS
which might block on stderr for the execute call.
Currently, all exercises are added in source/info.d
. Although they are read at compile time, it also means the project needs to compile to update any changes (addition or removal of an exercise, order swap, any data relative to their properties). Adding the exercises in an external file read at runtime would allow modifications to be made a lot easier. Using a toml
or yaml
format makes this possible, it's easy to parse, and maintains the nice readability.
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, ...
In case of an error, the program should not return successfully.
Maybe the toolchain requirements can be added to dub.json to warn from using older compilers
I just tried to run it with a somewhat recent dmd version (v2.099.1) and it doesn't compile:
source/util.d(40,26): Error: => shortened method not enabled, compile with compiler switch -preview=shortenedMethods source/util.d(41,24): Error: => shortened method not enabled, compile with compiler switch -preview=shortenedMethods source/util.d(126,31): Error: => shortened method not enabled, compile with compiler switch -preview=shortenedMethods source/util.d(127,31): Error: => shortened method not enabled, compile with compiler switch -preview=shortenedMethods
source/tutor.d(12,8): Error: module
std.functionalimport bind not found
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.