On Sunday, 17 April 2022 at 18:25:32 UTC, Bastiaan Veelo wrote:
The reason is in [17.1.5](https://dlang.org/spec/enum.html):
“EnumBaseType types cannot be implicitly cast to an enum type.”
Thy. That's the anchor in the specs preventing Enums to be
integral types.
On Tuesday, 19 April 2022 at 13:20:21 UTC, Bastiaan Veelo wrote:
There is nothing that requires enum values to be unique, though:
```d
import std;
void main()
{
enum E {Zero = 0, One = 0, Two = 0}
writeln(E.Two); // Zero!
}
```
True, but if you want it be useful they really need to be
On Tuesday, 19 April 2022 at 01:25:13 UTC, Era Scarecrow wrote:
The 'integral' or numeric value is used for uniqueness, […]
There is nothing that requires enum values to be unique, though:
```d
import std;
void main()
{
enum E {Zero = 0, One = 0, Two = 0}
writeln(E.Two); // Zero!
}
```
On Sunday, 17 April 2022 at 18:25:32 UTC, Bastiaan Veelo wrote:
On Saturday, 16 April 2022 at 11:39:01 UTC, Manfred Nowak wrote:
In the specs(17) about enums the word "integral" has no match.
But because the default basetype is `int`, which is an
integral type, enums might be inte
On Saturday, 16 April 2022 at 11:39:01 UTC, Manfred Nowak wrote:
In the specs(17) about enums the word "integral" has no match.
But because the default basetype is `int`, which is an integral
type, enums might be integral types whenever their basetype is
an integral type.
On the
In the specs(17) about enums the word "integral" has no match.
But because the default basetype is `int`, which is an integral
type, enums might be integral types whenever their basetype is an
integral type.
On the other hand the specs(7.6.5.3) about types say
| A bool value can be
On Tuesday, 28 December 2021 at 00:57:27 UTC, Paul Backus wrote:
```d
enum instantiate(string type, string expr) = type ~ "(" ~
expr ~ ")";
pragma(msg, instantiate!("RVector!(SEXPTYPE.REALSXP)", "x"));
```
One possibility is to generate a collection of compile time
strings that denote the
On Tuesday, 28 December 2021 at 00:42:18 UTC, data pulverizer
wrote:
On Tuesday, 28 December 2021 at 00:32:03 UTC, Paul Backus wrote:
In this case, the simplest solution is to have your code
generator accept a string as its input, rather than a type.
For example:
```d
enum instantiate(string
On Tuesday, 28 December 2021 at 00:32:03 UTC, Paul Backus wrote:
The result of `.stringof` is completely implementation-defined,
may change arbitrarily between compiler releases, and is not
even guaranteed to be valid D code in the first place.
Wow, I didn't know this.
In this case, the simpl
On Tuesday, 28 December 2021 at 00:13:13 UTC, data pulverizer
wrote:
There are various requirements, sometimes I have to cast or
type convert, so I **need** the type to paste correctly and
explicitly.
You almost never actually need types as strings. I'm almost
certain there's a better way for
On Tuesday, 28 December 2021 at 00:13:13 UTC, data pulverizer
wrote:
The types I'm generating are a template type I've constructed
for R's SEXP, so that my wrapped numeric vector (struct) type
is denoted `RVector!(REALSXP)`. But `alias REALSXP =
SEXPTYPE.REALSXP` where `SEXPTYPE` is an `enum`.
On Monday, 27 December 2021 at 23:04:40 UTC, Adam Ruppe wrote:
On Monday, 27 December 2021 at 21:21:30 UTC, data pulverizer
wrote:
alias T = MyType!(INTEGER);
What is MyType?
enum code = "writeln(\"instance: \", adder(" ~
T.stringof ~ "(), " ~ U.stringof ~ "()" ~ "));";
A
On Monday, 27 December 2021 at 21:21:30 UTC, data pulverizer
wrote:
alias T = MyType!(INTEGER);
What is MyType?
enum code = "writeln(\"instance: \", adder(" ~
T.stringof ~ "(), " ~ U.stringof ~ "()" ~ "));";
And why is this a string mixin instead of a plain simple function
On Monday, 27 December 2021 at 22:52:58 UTC, data pulverizer
wrote:
I think the only thing to do for now is probably for me to
construct a template that creates a proper string for this type.
It would look something like this:
```
enum safe_stringof(T) = T.stringof;
template safe_stringof(T: M
On Monday, 27 December 2021 at 21:31:03 UTC, Adam Ruppe wrote:
if you can paste teh code where you generate this I can prolly
show you a much easier way to do it. stringof sucks really hard.
I think the only thing to do for now is probably for me to
construct a template that creates a proper s
On Monday, 27 December 2021 at 21:31:03 UTC, Adam Ruppe wrote:
if you can paste teh code where you generate this I can prolly
show you a much easier way to do it. stringof sucks really hard.
Will the above `mixin` example suffice? It expands to the code
that I described.
On Monday, 27 December 2021 at 21:05:51 UTC, data pulverizer
wrote:
adder(MyType!MyEnum.INTEGER(), MyType!MyEnum.STRING());
The rule for !(args) is of you leave the parenthesis off, it only
uses the next single token as the argument. So it will never
include a dot; it is like you wrote `MyTyp
On Monday, 27 December 2021 at 21:05:51 UTC, data pulverizer
wrote:
Hello, ...
... an equivalent mixin error would be
```
//...
alias DOUBLE = MyEnum.DOUBLE;
alias STRING = MyEnum.STRING;
alias INTEGER = MyEnum.INTEGER;
void main()
{
alias T = MyType!(INTEGER);
alias U = MyType!(STRING)
Hello,
I'm generating code using mixins and one of my mixins expands to
something like this:
```
adder(MyType!MyEnum.INTEGER(), MyType!MyEnum.STRING());
```
`MyType!MyEnum.STRING` is generated with `T.stringof `. I get the
error:
```
Error: template instance `MyType!(MyEnum)` does not matc
hard to
disagree with.
So, perhaps the better solution would be to make isBoolean and
isSomeChar (and
perhaps other functions that I didn't think of) return false for
enums?
As a side note, isSomeChar returning true for enums is also what
causes the
behavior demonstrated in Issue 2163
On Sunday, 14 March 2021 at 16:09:39 UTC, Imperatorn wrote:
On Sunday, 14 March 2021 at 10:42:17 UTC, wolframw wrote:
enum BoolEnum : bool { TestBool = false }
enum CharEnum : char { TestChar = 'A' }
enum StringEnum : string { TestString = "Hello" }
pragma(msg, isBoolean!BoolEnum);
rEnum); // true
pragma(msg, isSomeString!StringEnum); // false
Why does isSomeString not return true for an enum with base
type string while
other isX functions return true for enums with an according
base type X?
Regarding whether enums should be considered by these
functions, I can see
// false
Why does isSomeString not return true for an enum with base type
string while
other isX functions return true for enums with an according base
type X?
Regarding whether enums should be considered by these functions,
I can see the
case being made one of both ways (personally, I'd
I got compilers errors from this:
enum E {
@("foo")
A,
@("baa")
B
}
I got:
Error: basic type expected, not @
Error: no identifier for declarator _error_
Error: type only allowed if anonymous enum and no enum type
Error: if type, there must be an initializer
Er
On Monday, 1 January 2018 at 17:15:24 UTC, Marc wrote:
I got compilers errors from this:
enum E {
@("foo")
A,
@("baa")
B
}
I got:
Error: basic type expected, not @
Error: no identifier for declarator _error_
Error: type only allowed if anonymous enum and no e
enum
{
a = "foo",
b = "bar",
c = "baz";
}
is identical to
enum a = "foo";
enum b = "bar";
enum c = "baz";
Thanks Jonathan I think that changes my point of perspective.
And Jacob Carlborg I like the third option a lot with aliases
good to know that
enum Foo : string
{
KErde
On 2017-12-17 20:45, Jonathan M Davis wrote:
That's pretty much just declaring manifest constants with braces so that you
don't repeat the keyword enum a bunch of times.
Anonymous enum is what the spec calls it and was available before
manifest constants.
--
/Jacob Carlborg
On Sunday, December 17, 2017 12:47:26 kerdemdemir via Digitalmars-d-learn
wrote:
> What I meant with anonymous enums was:
> https://dlang.org/spec/enum.html#anonymous_enums. Maybe I
> couldn't explain well but I believe D have anonymous enums. I am
> sorry I have forgotten to rem
s and be able to call
functions with different enumarations. Or is there any other way to call
named enums without type name ?
You have three options:
* Specify "string" as the type of the parameter for the ReturnCoolNess
function. Note that this will allow any string to be passed t
What I meant with anonymous enums was:
https://dlang.org/spec/enum.html#anonymous_enums. Maybe I
couldn't explain well but I believe D have anonymous enums. I am
sorry I have forgotten to remove " :string" in my example from
the "enum : string". Please stretch out &q
e Ali:
> {
> return 100.0;
> }
> case Salih:
> {
> return 100.0;
> }
> // etc..
>}
> }
>
> Is there any way I still keep my enum anonymous and be able to
> call functions with different enumarations. Or is there any other
> way to call named enums
ymous and be able to
call functions with different enumarations. Or is there any other
way to call named enums without type name ?
On Sunday, 30 April 2017 at 22:03:02 UTC, Kevin Balbas wrote:
On Sunday, 30 April 2017 at 21:31:22 UTC, jkpl wrote:
On Sunday, 30 April 2017 at 21:13:07 UTC, Kevin Balbas wrote:
On Sunday, 30 April 2017 at 20:58:36 UTC, jkpl wrote:
On Sunday, 30 April 2017 at 20:05:59 UTC, Kevin Balbas wrote:
On Sunday, 30 April 2017 at 21:31:22 UTC, jkpl wrote:
On Sunday, 30 April 2017 at 21:13:07 UTC, Kevin Balbas wrote:
On Sunday, 30 April 2017 at 20:58:36 UTC, jkpl wrote:
On Sunday, 30 April 2017 at 20:05:59 UTC, Kevin Balbas wrote:
Strangely enough, it does work fine in the test snippet,
As
On Sunday, 30 April 2017 at 21:13:07 UTC, Kevin Balbas wrote:
On Sunday, 30 April 2017 at 20:58:36 UTC, jkpl wrote:
On Sunday, 30 April 2017 at 20:05:59 UTC, Kevin Balbas wrote:
Strangely enough, it does work fine in the test snippet,
As well if you import the snippet in another module. That'
On Sunday, 30 April 2017 at 20:58:36 UTC, jkpl wrote:
On Sunday, 30 April 2017 at 20:05:59 UTC, Kevin Balbas wrote:
I've got the following code snippet, which almost does what I
want.
struct TaggedType {}
@TaggedType
struct Foo {}
@TaggedType
struct Bar {}
string GenerateTypeEnum()
{
st
On Sunday, 30 April 2017 at 20:05:59 UTC, Kevin Balbas wrote:
I've got the following code snippet, which almost does what I
want.
struct TaggedType {}
@TaggedType
struct Foo {}
@TaggedType
struct Bar {}
string GenerateTypeEnum()
{
string enumString = "enum TypeEnum {";
foreach (name;
I've got the following code snippet, which almost does what I
want.
struct TaggedType {}
@TaggedType
struct Foo {}
@TaggedType
struct Bar {}
string GenerateTypeEnum()
{
string enumString = "enum TypeEnum {";
foreach (name; __traits(allMembers, mixin(__MODULE__)))
{
import
On 03/18/2017 01:22 PM, Oleg B wrote:
enum arr = cast(ubyte[])[0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4];
auto arr1 = cast(void[])arr;
immutable arr2 = cast(immutable(void)[])arr;
enum arr3 = cast(void[])arr;
Aside: The casts here do nothing to affect the outcome.
writeln(cast(ush
ation of enums by compiler as #define.
It's right? It's behavior by design?
It took me a bit but what I thinking happening is 1 and 2 are being
casted at runtime where as 3 is at CT.
At CT its per value of the enum array, at RT its per x bytes from array.
Which sort of makes sense a
;
writeln(cast(ushort[])arr1); // [0, 256, 0, 512, 0, 768, 0,
1024]
writeln(cast(ushort[])arr2); // [0, 256, 0, 512, 0, 768, 0,
1024]
writeln(cast(ushort[])arr3); // [0, 0, 0, 1, 0, 0, 0, 2, 0,
0, 0, 3, 0, 0, 0, 4]
}
I think it's related to representation of enums by compiler as
#d
On Thursday, 19 January 2017 at 03:47:34 UTC, Ignacious wrote:
On Thursday, 19 January 2017 at 02:59:04 UTC, Ignacious wrote:
I have the need to create an enum flag like structure to
specify certain properties of a type easily.
e.g.,
enum properties
{
Red,
Blue,
Hot,
Sexy,
Acti
On Thursday, 19 January 2017 at 02:59:04 UTC, Ignacious wrote:
I have the need to create an enum flag like structure to
specify certain properties of a type easily.
e.g.,
enum properties
{
Red,
Blue,
Hot,
Sexy,
Active,
...
}
But some properties will be mutually exclusive. I
I have the need to create an enum flag like structure to specify
certain properties of a type easily.
e.g.,
enum properties
{
Red,
Blue,
Hot,
Sexy,
Active,
...
}
But some properties will be mutually exclusive. I would like to
contain all those rules for in the enum itself fo
On Friday, 8 April 2016 at 14:56:51 UTC, Adam D. Ruppe wrote:
On Friday, 8 April 2016 at 14:38:10 UTC, Andre wrote:
Therefore I use std.conv.text to convert the string enum? to
string.
That converts the *name* of the enum to string, not the
contents. (BTW, I think the name of the enum is actu
On Friday, 8 April 2016 at 14:38:10 UTC, Andre wrote:
Therefore I use std.conv.text to convert the string enum? to
string.
That converts the *name* of the enum to string, not the contents.
(BTW, I think the name of the enum is actually the more useful
behavior.)
Use cast(string) if you want
Hi,
I have some issues with enums. Please have a look at the last 3
assertions.
It is annoying that I cannot directly use my StringEnum for
startsWith.
Therefore I use std.conv.text to convert the string enum? to
string.
But then the assertion fails, that is very strange, it fails only
for
On Saturday, 27 February 2016 at 04:37:24 UTC, Øivind wrote:
Should I file a ticket for this?
It is already known, just nobody has fixed it yet (and probably
won't for a long time still)
On Saturday, 27 February 2016 at 04:35:41 UTC, Adam D. Ruppe
wrote:
It just isn't implemented in the compiler. Instead, you can
declare it outside and set it in a static module constructor:
That was quick! Thank you.
Should I file a ticket for this?
On Saturday, 27 February 2016 at 04:15:06 UTC, Øivind wrote:
Shouldn't this work? According to "Static Initialization of
AAs" on this page, it should:
https://dlang.org/spec/hash-map.html
It just isn't implemented in the compiler. Instead, you can
declare it outside and set it in a static mod
Shouldn't this work? According to "Static Initialization of AAs"
on this page, it should: https://dlang.org/spec/hash-map.html
enum DevicePropDataType {
dString,
dDateTime
}
enum DevicePropValType {
property,
miscDate
}
immutable DevicePropDataType[DevicePropValType] propDType =
[
On Tuesday, 1 December 2015 at 10:50:04 UTC, Rikki Cattermole
wrote:
On 01/12/15 11:44 PM, Ozan wrote:
Hi
Let's say we have an enum like
enum SomethingAboutChristmas {
SantaClaus,
Angel,
Tree
}
and want to use it in a function like
void goingChristmas(SomethingAboutChristmas enum
On Tuesday, 1 December 2015 at 13:03:37 UTC, tcak wrote:
On Tuesday, 1 December 2015 at 10:50:04 UTC, Rikki Cattermole
wrote:
[...]
This is like: Q) I want to write an OS. How? A) Write in
assembly.
What Ozan says is logical. Compiler should assume it in that
way normally. I have thorough
V Tue, 01 Dec 2015 10:44:06 +
Ozan via Digitalmars-d-learn
napsáno:
> Hi
>
> Let's say we have an enum like
>
> enum SomethingAboutChristmas {
>SantaClaus,
>Angel,
>Tree
> }
>
> and want to use it in a function like
>
>void goingChristmas(SomethingAboutChristmas enumvalue)
On 01/12/15 11:44 PM, Ozan wrote:
Hi
Let's say we have an enum like
enum SomethingAboutChristmas {
SantaClaus,
Angel,
Tree
}
and want to use it in a function like
void goingChristmas(SomethingAboutChristmas enumvalue)
it works fine like following
goingChristmas(SomethingAbout
Hi
Let's say we have an enum like
enum SomethingAboutChristmas {
SantaClaus,
Angel,
Tree
}
and want to use it in a function like
void goingChristmas(SomethingAboutChristmas enumvalue)
it works fine like following
goingChristmas(SomethingAboutChristmas.Tree)
I prefer to use a short
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
utput:
470910
470910
You're print the address of `f` and `n` on the stack, not the
reference they're pointing to.
But it's true that enums of mutable _arrays_ do create a new
instance every time they're used:
enum X {
A = [1,2,3],
B = [4,5,6],
}
voi
u're print the address of `f` and `n` on the stack, not the
reference they're pointing to.
But it's true that enums of mutable _arrays_ do create a new
instance every time they're used:
enum X {
A = [1,2,3],
B = [4,5,6],
}
void main() {
oject I'm working on, porting it from java to D.
One of the uncommonly-used features of java that I like is how
enums can be full classes (though I don't like that there's no
option to use enums as e.g. regular ints). This allows several
benefits, such as the ability to use them
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",
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 halfStepsToPre
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?&qu
porting it from java to D. One of the uncommonly-used features of
java that I like is how enums can be full classes (though I don't like
that there's no option to use enums as e.g. regular ints). This allows
several benefits, such as the ability to use them in switch statements
like reg
commonly-used features of java that I like is how enums
can be full classes (though I don't like that there's no option
to use enums as e.g. regular ints). This allows several
benefits, such as the ability to use them in switch statements
like regular enums, the full set of obj
{ foo, bar, baz };
align(1) struct TwoEnums(E0, E1) if (is(E0 == enum) && is(E1 ==
enum)) {
private import std.string : format;
static assert(E0.min >= 0 && E1.min >= 0 && E0.max < 256 &&
E1.max < 256 && E0.max+E1.max < 256, "enu
I stumbled upon this interesting programming challenge [0], which
imho should be possible to implement in D. Maybe someone here
wants to try.
Task: Given two enums with less than 256 states, pack them into
one byte and provide convenient accessor functions.
Something like this:
enum X { A
On Monday, 29 June 2015 at 22:05:47 UTC, qznc wrote:
I stumbled upon this interesting programming challenge [0],
which imho should be possible to implement in D. Maybe someone
here wants to try.
Task: Given two enums with less than 256 states, pack them into
one byte and provide convenient
On 2015-05-15 17:26:50 +, Ali Çehreli said:
On 05/15/2015 09:45 AM, Robert M. Münch wrote:
> Is there a way I can build an ENUM from within the FOREACH? What I want
> to achive is, that I would like to use:
>
> final switch (myEnum) ...
Sorry, I don't understand your question. :(
Do y
On 05/15/2015 09:45 AM, Robert M. Münch wrote:
> On 2015-05-04 18:22:17 +, Ali Çehreli said:
>> TypeTuple is great because it enables "compile-time foreach"
>> (unfortunately, implicitly):
>>
>> foreach (m; __traits(allMembers, A)) {
>> // This body is repeated for each member
On 2015-05-04 18:22:17 +, Ali Çehreli said:
There are many different kinds of tuples in D, only two of which I can handle:
1) Tuple from std.typecons, which are ordinarily created at run time
2) TypeTuple from std.typetuple, which are compile-time entities
The documentation is not clear t
On 2015-05-04 22:22:51 +, ketmar said:
as i said, `typeid` is runtime feature, so you can't print it with pragma.
and tuples aren't exist in runtime, it's compile-time only.
i think you are even more confused now. ;-) sorry.
No, that makes it much more clearer for me. The compiler should
On Mon, 04 May 2015 20:07:27 +0200, Robert M. Münch wrote:
>
> Gives this:
>
> (string, string, string)
> playground.d(9): Error: no type for typeid(members1)
> playground.d(9):while evaluating pragma(msg, typeid(members1))
`typeid` is runtime thing, you can't use it in compile-time.
On 05/04/2015 11:07 AM, Robert M. Münch wrote:
> enum A {a, b, c};
>
> enum members1 = __traits(allMembers, A);
> auto members2 = __traits(allMembers, A);
>
> 1. So the (string, string, string) output is based on the expression of
> members1? Meaning, the right-hand-side.
There are many differe
constants", and that constants has the
corresponding type, they aren't enums.
Hmm... Ok, I understand that these seems to be two different things.
Not sure if I now understand this correct then:
enum A {a, b, c};
enum members1 = __traits(allMembers, A);
auto members2 = __traits(allMe
nstructed.
that's due to `enum` keyword abusing. "enum type" is something like this:
enum MyEnum { A, B }
and
enum val = false;
is a compile-time boolean constant, which will be inlined on using. i.e.
compiler will inline such "enum constants", and that constants has the
corresponding type, they aren't enums.
signature.asc
Description: PGP signature
I find this a bit strange:
// get all rules that start with p...
enum BolRules = StaticFilter!(beginsWithP, __traits(allMembers,BolSource));
static assert(is(BolRules == enum));
Compiling using dmd...
source/app.d(114): Error: static assert (is(BolRules == enum)) is false
I'm trying to constru
On Tuesday, October 28, 2014 16:58:50 Gary Willoughby via Digitalmars-d-learn
wrote:
> On Tuesday, 28 October 2014 at 00:51:17 UTC, Jonathan M Davis via
> Digitalmars-d-learn
>
> > The
> > thing that's been done in Phobos in this type of situation is
> > to put an
> > underscore on the end of the
On Tuesday, 28 October 2014 at 00:51:17 UTC, Jonathan M Davis via
Digitalmars-d-learn
The
thing that's been done in Phobos in this type of situation is
to put an
underscore on the end of the keyword, so you'd get
enum CrudOps { read, write, delete_ }
and while that may not be what you want, i
On 10/27/14 8:31 PM, Domingo wrote:
Hello !
I'm not sure if I'm missing something here but for a tagged enum it
doesn't seem to make sense to forbid reserved keywords like:
enum CrudOps {read, write, delete}
The dmd compiler are complaining:
--
cte.d(4): Error: basic type expected, not del
On 2014-10-28 01:51, Jonathan M Davis via Digitalmars-d-learn wrote:
And I've never seen a language where it did (though one may exist out there
somewhere)
Ruby:
class Foo
end
Foo == Foo.new.class # perfectly legal
You always need to have a receiver when calling the "class" method. This
i
On Tue, Oct 28, 2014 at 12:31:43AM +, Domingo via Digitalmars-d-learn wrote:
> Hello !
>
> I'm not sure if I'm missing something here but for a tagged enum it
> doesn't seem to make sense to forbid reserved keywords like:
>
> enum CrudOps {read, write, delete}
>
> The dmd compiler are compla
On Tue, 28 Oct 2014 00:31:43 +
Domingo via Digitalmars-d-learn
wrote:
> Hello !
>
> I'm not sure if I'm missing something here but for a tagged enum
> it doesn't seem to make sense to forbid reserved keywords like:
>
> enum CrudOps {read, write, delete}
>
> The dmd compiler are complainin
On Tuesday, October 28, 2014 00:31:43 Domingo via Digitalmars-d-learn wrote:
> Hello !
>
> I'm not sure if I'm missing something here but for a tagged enum
> it doesn't seem to make sense to forbid reserved keywords like:
>
> enum CrudOps {read, write, delete}
>
> The dmd compiler are complaining:
Hello !
I'm not sure if I'm missing something here but for a tagged enum
it doesn't seem to make sense to forbid reserved keywords like:
enum CrudOps {read, write, delete}
The dmd compiler are complaining:
--
cte.d(4): Error: basic type expected, not delete
cte.d(4): Error: no identifier
On Saturday, 31 May 2014 at 22:45:32 UTC, bearophile wrote:
Chris Nicholson-Sauls:
Good... I was starting to fear I was the only one.
In general you can't fix the names in a language because you
always find someone that likes the ones present :) I think
"enum" is a bad name for the purpose
On Sat, May 31, 2014 at 10:14 PM, bearophile via Digitalmars-d-learn
wrote:
>> In contrast to those two examples where immutable can be used at compile
>> time, what are some other cases where it is necessary to use enum instead
>> of immutable?
>
>
> By default use enum if you define a compile-t
Chris Nicholson-Sauls:
Good... I was starting to fear I was the only one.
In general you can't fix the names in a language because you
always find someone that likes the ones present :) I think "enum"
is a bad name for the purpose of defining manifest constants, but
I don't think this will
On Saturday, 31 May 2014 at 22:13:35 UTC, monarch_dodra wrote:
On Saturday, 31 May 2014 at 21:21:59 UTC, Paul D Anderson wrote:
'enum' as a manifest constant keyword has been an unpopular
decision from its introduction. "Everybody" agrees that it
should be changed. Everybody but Walter
I find
On Saturday, 31 May 2014 at 21:21:59 UTC, Paul D Anderson wrote:
'enum' as a manifest constant keyword has been an unpopular
decision from its introduction. "Everybody" agrees that it
should be changed. Everybody but Walter
I find enum makes sense.
On 05/31/2014 11:21 PM, Paul D Anderson wrote:
On Saturday, 31 May 2014 at 20:14:59 UTC, bearophile wrote:
Miles Stoudenmire:
In contrast to those two examples where immutable can be used at compile
time, what are some other cases where it is necessary to use enum
instead of immutable?
By de
Paul D Anderson:
'enum' as a manifest constant keyword has been an unpopular
decision from its introduction.
I agree, I too asked for a better name.
Bye,
bearophile
On Saturday, 31 May 2014 at 20:14:59 UTC, bearophile wrote:
Miles Stoudenmire:
In contrast to those two examples where immutable can be used
at compile
time, what are some other cases where it is necessary to use
enum instead of immutable?
By default use enum if you define a compile-time-kno
Miles Stoudenmire:
In contrast to those two examples where immutable can be used
at compile
time, what are some other cases where it is necessary to use
enum instead of immutable?
By default use enum if you define a compile-time-known value,
unless it's composed data like an array, etc.
By
te:
> > On Friday, 30 May 2014 at 15:30:15 UTC, Russel Winder via
> Digitalmars-d-learn wrote:
> >>
> >> I think I have no idea what D enums are about.
> >>
> >> Bearophile's example of some code in an email on another thread
On Friday, 30 May 2014 at 15:30:15 UTC, Russel Winder via
Digitalmars-d-learn wrote:
>>
>> I think I have no idea what D enums are about.
>>
>> Bearophile's example of some code in an email on another thread uses:
>>
>> enum double p0 = 0.0045;
>&
Some explanation how the seemingly different concepts "enumerated
value" and "manifest constant" are actually related:
Let's start with the "classical" enums as they're known from
C/C++. They are used to create lists of symbolic names:
enum Color {
On Fri, May 30, 2014 at 7:56 PM, Steven Schveighoffer wrote:
> You can as long as the value is known at compile time:
>
> http://dpaste.dzfl.pl/5a710bd80ab0
Oh wow.
And that works for static if also:
http://dpaste.dzfl.pl/f87321a47834
Man. That opens some new possibilities.
constant. Interestingly,
it
can be thought of like a C macro, being pasted inside source code.
Avoid enums for arrays and associative arrays as they are hidden
performance
sinks. The constant gets regenerated at runtime every time it is used
in an
expression.
I guess that, in an ideal world
, being pasted inside source code.
>
> Avoid enums for arrays and associative arrays as they are hidden performance
> sinks. The constant gets regenerated at runtime every time it is used in an
> expression.
I guess that, in an ideal world, immutable variables could be use at
compile-t
1 - 100 of 221 matches
Mail list logo