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
On 19/03/2017 1:22 AM, Oleg B wrote:
Hello. I found strange behavior while casting enum array and immutable
array.
import std.stdio;
void main()
{
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;
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
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?
On 31 May 2014 09:33, Andrej Mitrovic via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com> wrote:
> This has been asked so many
This has been asked so many times, is this info not on the website? We
should have an article on the site explaining this in depth. OT: Sorry for
top-quoting and over-quoting.
On Friday, May 30, 2014, monarch_dodra via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com> wrote:
> On Friday, 30
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 { YELLOW, PINK, BLUE };
Internally, each
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.
On Fri, 30 May 2014 13:34:38 -0400, Philippe Sigaud via
Digitalmars-d-learn wrote:
On Fri, May 30, 2014 at 7:28 PM, Ali Çehreli
wrote:
On 05/30/2014 08:30 AM, Russel Winder via Digitalmars-d-learn wrote:
enum double p0 = 0.0045;
As others have already said, p0 is a manifest con
On Fri, May 30, 2014 at 7:28 PM, Ali Çehreli
wrote:
> On 05/30/2014 08:30 AM, Russel Winder via Digitalmars-d-learn wrote:
>
>> enum double p0 = 0.0045;
>
> As others have already said, p0 is a manifest constant. Interestingly, it
> can be thought of like a C macro, being pasted inside so
On 05/30/2014 08:30 AM, Russel Winder via Digitalmars-d-learn wrote:
> enum double p0 = 0.0045;
As others have already said, p0 is a manifest constant. Interestingly,
it can be thought of like a C macro, being pasted inside source code.
Avoid enums for arrays and associative arrays a
A good use of 'static immutable', sadly not voted into the language.
:-)
But you're right, and I remember being tripped by this.
On Fri, May 30, 2014 at 07:17:15PM +0200, Philippe Sigaud via
Digitalmars-d-learn wrote:
> > In D enum can be used to define manifest constants. This means
> > constants known at compile time. In practice for a double there
> > isn't a lot of difference. In general you can't take the address of
>
> In D enum can be used to define manifest constants. This means constants
> known at compile time. In practice for a double there isn't a lot of
> difference. In general you can't take the address of a manifest constant,
> unlike immutables.
Because they do not exist as 'variables' or symbol in t
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;
Now I would have written:
immutable double p0 =
Russel Winder:
For me, enum means create an enumerated type. Thus "enum
double" to define a single value is just a contradiction.
Enlightenment required…
In D enum can be used to define manifest constants. This means
constants known at compile time. In practice for a double there
isn't a l
On Mon, Mar 16, 2009 at 2:53 PM, Nicholas Jordan wrote:
> Oops, I missed the note about enums.
>
> enums in other languages sound to me to be a great idea, but when I first
> started coding I noted that the machine was
> placing them at the beginning of the file and I eventually figured out that
24 matches
Mail list logo