On 09/02/2012 12:24 PM, Philippe Sigaud wrote:
> On Sun, Sep 2, 2012 at 8:50 PM, Ali Çehreli wrote:
>> On 09/02/2012 06:45 AM, monarch_dodra wrote:
>>
>>> Is there *any* scenario where one would choose the enum over the
>>> static immutable...?
>
> Due to Jonathan advice, I converted a part of my
On Sun, Sep 2, 2012 at 8:50 PM, Ali Çehreli wrote:
> On 09/02/2012 06:45 AM, monarch_dodra wrote:
>
>> Is there *any* scenario where one would choose the enum over the
>> static immutable...?
Due to Jonathan advice, I converted a part of my code (enum => static
this). At runtime, I got a 40% decr
On 09/02/2012 06:45 AM, monarch_dodra wrote:
> Is there *any* scenario where one would choose the enum over the
> static immutable...?
That's a good question. If Timon Gehr's example is the only difference,
I wonder whether the guidelines that I had come up with are still
valuable? I would app
On 09/02/2012 06:26 PM, monarch_dodra wrote:
On Sunday, 2 September 2012 at 16:20:16 UTC, Timon Gehr wrote:
On 09/02/2012 03:45 PM, monarch_dodra wrote:
FYI: I get the exact same behavior in Windows. Not that it
matters, but it sounded like you were asking.
I'm a bit confused now though: Why
On Sunday, 2 September 2012 at 16:20:16 UTC, Timon Gehr wrote:
On 09/02/2012 03:45 PM, monarch_dodra wrote:
FYI: I get the exact same behavior in Windows. Not that it
matters, but it sounded like you were asking.
I'm a bit confused now though: Why would someone want to use an
enum when they co
On 09/02/2012 03:45 PM, monarch_dodra wrote:
On Saturday, 1 September 2012 at 09:16:30 UTC, Jonathan M Davis
wrote:
[SNIP]
so it looks like not only do all instances of the same string enum use
the
same memory, but another enum with the same string literal shares it
as well.
So, only one is allo
On Saturday, 1 September 2012 at 09:16:30 UTC, Jonathan M Davis
wrote:
[SNIP]
so it looks like not only do all instances of the same string
enum use the
same memory, but another enum with the same string literal
shares it as well.
So, only one is allocated. And on Linux at least, as I
understa
On Saturday, September 01, 2012 11:10:17 Jonathan M Davis wrote:
> On Saturday, September 01, 2012 16:14:29 ixid wrote:
> > Those still have different addresses when made immutable too, is
> > this something that could be optimized for all immutable enums to
> > behave like strings or are there rea
On Saturday, September 01, 2012 16:14:29 ixid wrote:
> Those still have different addresses when made immutable too, is
> this something that could be optimized for all immutable enums to
> behave like strings or are there reasons to keep them unique at
> each instance?
The compiler has to got to
Those still have different addresses when made immutable too, is
this something that could be optimized for all immutable enums to
behave like strings or are there reasons to keep them unique at
each instance?
On Saturday, September 01, 2012 11:07:34 Philippe Sigaud wrote:
> > Using enum can be very useful, but I wouldn't use it for AAs at all, and
> > I'd be leery of using it for much in the way of arrays other than string
> > literals (since the string literals should avoid the memory allocations
> > t
> Using enum can be very useful, but I wouldn't use it for AAs at all, and I'd
> be leery of using it for much in the way of arrays other than string literals
> (since the string literals should avoid the memory allocations that other
> array literals get). It's fine most other stuff, but for those
On Saturday, September 01, 2012 09:39:04 Philippe Sigaud wrote:
> On Sat, Sep 1, 2012 at 12:21 AM, Jonathan M Davis
wrote:
> > Using an enum is particularly bad for an AA, since it's not exactly a
> > simple data type, and there's definitely some cost to constructing them.
>
> Yeah, my (nasty) b
On Sat, Sep 1, 2012 at 12:21 AM, Jonathan M Davis wrote:
> Using an enum is particularly bad for an AA, since it's not exactly a simple
> data type, and there's definitely some cost to constructing them.
Yeah, my (nasty) bad. I'm too used to put 'enum' everywhere.
Gosh, I confirm using static t
On Saturday, September 01, 2012 00:12:06 ixid wrote:
> Hmm, you mean if you call the same function it creates a new copy
> every time? I misunderstood you to mean it creates it once at
> each site in the code it's called.
enum values are basically copy-pasted everywhere that they're used. So, if y
Hmm, you mean if you call the same function it creates a new copy
every time? I misunderstood you to mean it creates it once at
each site in the code it's called.
Yep, I am aware of that, for my use it happens to be perfect but
I understand that having a bunch of copies all over the place
wouldn't be smart.
On Fri, Aug 31, 2012 at 10:34 PM, ixid wrote:
> Philippe suggested enum allowing this:
>
> enum dayNumbers = [ "Monday" : 0, "Tuesday" : 1, "Wednesday" : 2,
>
> "Thursday" : 3, "Friday" : 4, "Saturday" : 5,
> "Sunday" : 6 ];
>
> Why does this seem to avoid pointer issues? Is it creating a compil
On Fri, Aug 31, 2012 at 9:56 PM, Jonathan M Davis wrote:
> Except that that allocates a new AA every time that you use dayNumbers. So,
> that's probably a bad idea.
Oh! I keep forgetting that enums are replaced by their values. Then I
think I know where some problem I had came from.
Damn, just
Philippe suggested enum allowing this:
enum dayNumbers = [ "Monday" : 0, "Tuesday" : 1, "Wednesday" : 2,
"Thursday" : 3, "Friday" : 4, "Saturday" : 5,
"Sunday" : 6 ];
Why does this seem to avoid pointer issues? Is it creating a
compile-time associated array or run-time?
On Friday, August 31, 2012 20:24:27 Philippe Sigaud wrote:
> On Fri, Aug 31, 2012 at 7:04 PM, ixid wrote:
> > Thank you, that certainly makes sense.
>
> If you're certain you won't need to modify it, you can make it a
> compile-time constant:
>
> enum int[string] dayNumbers =
> [ "Monday" : 0, "
On Fri, Aug 31, 2012 at 7:04 PM, ixid wrote:
> Thank you, that certainly makes sense.
If you're certain you won't need to modify it, you can make it a
compile-time constant:
enum int[string] dayNumbers =
[ "Monday" : 0, "Tuesday" : 1, "Wednesday" : 2,
"Thursday" : 3, "Friday"
Thank you, that certainly makes sense.
On Friday, August 31, 2012 16:38:13 ixid wrote:
> Why does this not work:
>
> int[string] dayNumbers =
> [ "Monday" : 0, "Tuesday" : 1, "Wednesday" : 2,
> "Thursday" : 3, "Friday" : 4, "Saturday" : 5,
> "Sunday" : 6 ];
>
> void main() {
> //Stuff
> }
>
> With the error 'non-constant expression'?
On 9/1/2012 1:31 AM, Mike Parker wrote:
On 8/31/2012 11:38 PM, ixid wrote:
Why does this not work:
int[string] dayNumbers =
[ "Monday" : 0, "Tuesday" : 1, "Wednesday" : 2,
"Thursday" : 3, "Friday" : 4, "Saturday" : 5,
"Sunday" : 6 ];
void main() {
//St
On 8/31/2012 11:38 PM, ixid wrote:
Why does this not work:
int[string] dayNumbers =
[ "Monday" : 0, "Tuesday" : 1, "Wednesday" : 2,
"Thursday" : 3, "Friday" : 4, "Saturday" : 5,
"Sunday" : 6 ];
void main() {
//Stuff
}
With the error 'non-constant expre
Why does this not work:
int[string] dayNumbers =
[ "Monday" : 0, "Tuesday" : 1, "Wednesday" : 2,
"Thursday" : 3, "Friday" : 4, "Saturday" : 5,
"Sunday" : 6 ];
void main() {
//Stuff
}
With the error 'non-constant expression'? This error also seems
to preven
27 matches
Mail list logo