On 11/2/21 6:49 PM, zjh wrote:
On Tuesday, 2 November 2021 at 23:02:42 UTC, Ali Çehreli wrote:
On 11/2/21 3:57 PM, Ali Çehreli wrote:
const x = readln.strip;
this is very interesting .`readln` then `strip;`,Very natural.
Yes, UFCS (universal function call syntax) makes code natural, c
On Tuesday, 2 November 2021 at 23:02:42 UTC, Ali Çehreli wrote:
On 11/2/21 3:57 PM, Ali Çehreli wrote:
const x = readln.strip;
this is very interesting .`readln` then `strip;`,Very natural.
On Tuesday, 2 November 2021 at 23:02:42 UTC, Ali Çehreli wrote:
On 11/2/21 3:57 PM, Ali Çehreli wrote:
Here is a more idiomatic version:
import std.stdio;
import std.string;
void main() {
const x = strip(readln());
writeln(x);
if (x == "hello world!") {
writeln("yes");
}
}
The fi
On Tuesday, 2 November 2021 at 22:57:14 UTC, Ali Çehreli wrote:
On 11/2/21 3:36 PM, pascal111 wrote:
can we keep the C style of it as it is
As you hint, this really is not D but still... :) I had to make
three changes:
import std.stdio;
// Ali - Importing stdin under a different name
// to
On 11/2/21 3:57 PM, Ali Çehreli wrote:
Here is a more idiomatic version:
import std.stdio;
import std.string;
void main() {
const x = strip(readln());
writeln(x);
if (x == "hello world!") {
writeln("yes");
}
}
The first line in main can be written with UFCS syntax as well:
cons
On 11/2/21 3:36 PM, pascal111 wrote:
can we keep the C style of it as it is
As you hint, this really is not D but still... :) I had to make three
changes:
import std.stdio;
// Ali - Importing stdin under a different name
// to prevent name conflict with std.stdio.stdin;
import core.stdc.stdi
In next program I intend it to be the D version of a C program,
but I found some troubles with it, can we keep the C style of it
as it is as we can and fix the must-be-fixed parts to make it
works under D compiler?
// D programming language
import std.stdio;
import core.stdc.stdio;
import cor