On Monday, 30 November 2015 at 08:08:20 UTC, Meta wrote:
class WhiteKey
{
private immutable int halfStepsToNext;
private immutable int halfStepsToPrevious;
enum
{
A = new WhiteKey(2, 2),
B = new WhiteKey(2, 1),
C =
On Monday, 30 November 2015 at 08:08:20 UTC, Meta wrote:
This doesn't quite work in D; you'd have to make each WhiteKey
const (which is probably not a bad idea anyway if you're using
it like an enum). However, it's better to just do this with
plain old value-type structs. It's exactly the same
On Monday, 30 November 2015 at 07:54:49 UTC, Rikki Cattermole
wrote:
enums don't have to be integral, but for performance reasons it
is for the best.
enum Foo : string {
A = "a",
B = "b",
C = "d",
ERROR = "What are you talking about?"
}
void main() {
import std.stdio :
On Monday, 30 November 2015 at 07:48:37 UTC, Andrew LaChance
wrote:
Hello,
D has intrigued me for a while, and I thought I would finally
read up on it! I've been reading "Programming in D" by Ali
Çehreli and I've been thinking about how I can use the language
in a side project I'm working
On Monday, 30 November 2015 at 07:58:43 UTC, Andrew LaChance
wrote:
Oh interesting. So you are saying I could have a struct
WhiteKey {...} and then an enum that extends WhiteKey?
enums can't *extend* anything. You can do this:
struct WhiteKeyS {
immutable int halfStepsToPrevious;
On 30/11/15 8:58 PM, Andrew LaChance wrote:
On Monday, 30 November 2015 at 07:54:49 UTC, Rikki Cattermole wrote:
enums don't have to be integral, but for performance reasons it is for
the best.
enum Foo : string {
A = "a",
B = "b",
C = "d",
ERROR = "What are you talking about?"
On Monday, 30 November 2015 at 10:22:54 UTC, Marc Schütz wrote:
You're misinterpreting this:
enum X {
A = new Object,
B = new Object,
}
void main() {
import std.stdio;
writeln(cast(void*) X.A);
writeln(cast(void*) X.A);
}
# output:
Hello,
D has intrigued me for a while, and I thought I would finally
read up on it! I've been reading "Programming in D" by Ali
Çehreli and I've been thinking about how I can use the language
in a side project I'm working on, porting it from java to D. One
of the uncommonly-used features of
On 30/11/15 8:48 PM, Andrew LaChance wrote:
Hello,
D has intrigued me for a while, and I thought I would finally read up on
it! I've been reading "Programming in D" by Ali Çehreli and I've been
thinking about how I can use the language in a side project I'm working
on, porting it from java to