On Monday, 24 November 2014 at 22:50:33 UTC, bearophile wrote:
In some D programs I'm using this coding pattern:
You can see an example of this pattern that I've used here:
http://rosettacode.org/wiki/Solve_a_Hopido_puzzle#D
Bye,
bearophile
Awesome gist and great pattern ! Sometimes your
On Monday, 24 November 2014 at 22:50:33 UTC, bearophile wrote:
And the @disable this() assures that a struct is correctly
initialized by the constructor.
In the statement: @disable this()
May I understand that you're disabling the default
constructor of the struct to use your own constructor?
MattCoder:
May I understand that you're disabling the default
constructor of the struct to use your own constructor?
Right. So the instance data of the struct is more likely correct
when you call its methods.
Bye,
bearophile
That's a neat trick, although if preconditions were able to be
run at compile time when possible you wouldn't have to resort to
using enum to force CTFE (you've talked a bit about this before I
remember). Thinking about something like a good ranged number
implementation, we can now get almost
On Tuesday, 25 November 2014 at 13:56:23 UTC, bearophile wrote:
Right. So the instance data of the struct is more likely
correct when you call its methods.
Thanks. - Well I'd like to see more of these tips. My current
code in D looks like C++ and of course I sure that I'm not
extracting the
void main() {
// Created at compile-time.
enum something = .Foo;
I don't think we should encourage UFCS with typenames or
uppercase names. If anything, it does not provide any benefit in
this case and Foo(.) is much more clearer without any
syntactical overhead.
On 11/25/2014 01:51 AM, matovitch wrote:
On Monday, 24 November 2014 at 22:50:33 UTC, bearophile wrote:
Sometimes your forum post doesn't get
any answers but you can be sure I read and enjoy them all (and I'm sure
I am not alone). Keep it up ! :)
Same here! Thank you, bearophile! :)
An
In some D programs I'm using this coding pattern:
struct Foo {
// Instance fields here.
@disable this();
this(in string[] data) pure @safe
in {
// Many pre-conditions here.
} out(result) {
// Some post-conditions here.
} body {
// ...
}