On 2018-01-20 00:16, rumbu wrote:
According to this
(https://dlang.org/spec/hash-map.html#static_initialization) this is
correct static initialization for AA:
immutable RoundingMode[string] ibmRounding =
[
">" : RoundingMode.towardPositive,
"<" : RoundingMode.towardNegative,
"0
On Friday, January 19, 2018 23:39:08 rumbu via Digitalmars-d-learn wrote:
> Thank you Adam, just figured out myself the same solution, but I
> didn't expect to have a static constructor in main.d. I thought
> static constructors are meant to be used in imported modules.
> Thanks again.
There reall
On Friday, 19 January 2018 at 23:27:06 UTC, Adam D. Ruppe wrote:
On Friday, 19 January 2018 at 23:16:19 UTC, rumbu wrote:
According to this
(https://dlang.org/spec/hash-map.html#static_initialization)
this is correct static initialization for AA:
That only works inside a function, and, ironic
On Friday, 19 January 2018 at 23:16:19 UTC, rumbu wrote:
According to this
(https://dlang.org/spec/hash-map.html#static_initialization)
this is correct static initialization for AA:
That only works inside a function, and, ironically, only if the
variable is not `static`...
I believe this is
According to this
(https://dlang.org/spec/hash-map.html#static_initialization) this
is correct static initialization for AA:
immutable RoundingMode[string] ibmRounding =
[
">" : RoundingMode.towardPositive,
"<" : RoundingMode.towardNegative,
"0" : RoundingMode.towardZero,
"=0":
Andrej Mitrovic Wrote:
> Bernard Helyer Wrote:
>
> > On Wed, 23 Jun 2010 00:41:45 -0700, Ali Ãehreli wrote:
> >
> > > Ali Ãehreli wrote:
> > >> dcoder wrote:
> > >>
> > >> > So, I moved the initialization to inside the main function, and now
> > >> it works.
> > >> > Great. I think we need
Bernard Helyer Wrote:
> On Wed, 23 Jun 2010 00:41:45 -0700, Ali Ãehreli wrote:
>
> > Ali Ãehreli wrote:
> >> dcoder wrote:
> >>
> >> > So, I moved the initialization to inside the main function, and now
> >> it works.
> >> > Great. I think we need to put this question in the FAQ.
> >>
> >>
On Wed, 23 Jun 2010 00:30:40 +0200, Ali Çehreli wrote:
dcoder wrote:
> So, I moved the initialization to inside the main function, and now
it works.
> Great. I think we need to put this question in the FAQ.
For future reference, if it really needs to be global:
uint[string] mywords;
s
On Wed, 23 Jun 2010 00:41:45 -0700, Ali Çehreli wrote:
> Ali Çehreli wrote:
>> dcoder wrote:
>>
>> > So, I moved the initialization to inside the main function, and now
>> it works.
>> > Great. I think we need to put this question in the FAQ.
>>
>> For future reference, if it really needs to
Ali Ãehreli:
> Could someone please verify whether the above is really necessary?
An initialization inside some runtime function/initializator is necessary
unless the AA is an enum.
> Is it
> actually a dmd bug that we need to use 'static this()' to initialize an
> associative array?
Accord
On 06/23/2010 09:41 AM, Ali Çehreli wrote:
Ali Çehreli wrote:
dcoder wrote:
> So, I moved the initialization to inside the main function, and now
it works.
> Great. I think we need to put this question in the FAQ.
For future reference, if it really needs to be global:
uint[string] mywords;
s
Ali Çehreli wrote:
dcoder wrote:
> So, I moved the initialization to inside the main function, and now
it works.
> Great. I think we need to put this question in the FAQ.
For future reference, if it really needs to be global:
uint[string] mywords;
static this()
{
mywords = [ "Hello"
dcoder wrote:
> So, I moved the initialization to inside the main function, and now
it works.
> Great. I think we need to put this question in the FAQ.
For future reference, if it really needs to be global:
uint[string] mywords;
static this()
{
mywords = [ "Hello" : 1, "World" : 1, "Cat
> > For the declaration:
> > uint[string] mywords = [ "Hello" : 1, "World" : 1,
> > "Cat" : 1, "Dog" : 1 ];
> >
> >
> > I get:
> >
> > $ dmd test_01.d
> > test_01.d(3): Error: non-constant expression
> > ["Hello":1u,"World":1u,"Cat":1u,"Dog":1u]
> AAs can't be assigned to at compile time (:[). You
Bernard Helyer:
> AAs can't be assigned to at compile time (:[).
You can define enum ones, this works:
import std.stdio;
enum int[string] aa = ["foo": 10];
void main() {
writeln(cast(bool)("foo" in aa));
writeln(aa["foo"]);
writeln(cast(bool)("hello" in aa));
}
But this code:
impor
On Tue, 22 Jun 2010 21:32:48 +, dcoder wrote:
> Sorry, I forgot to put some compiler output:
>
> For the declaration: uint[string] mywords = [ "Hello" : 1, "World" : 1,
> "Cat" : 1, "Dog" : 1 ];
>
>
> I get:
>
> $ dmd test_01.d
> test_01.d(3): Error: non-constant expression
> ["Hello":1u,"
Sorry, I forgot to put some compiler output:
For the declaration: uint[string] mywords = [ "Hello" : 1, "World" : 1, "Cat" :
1,
"Dog" : 1 ];
I get:
$ dmd test_01.d
test_01.d(3): Error: non-constant expression
["Hello":1u,"World":1u,"Cat":1u,"Dog":1u]
Hello. I have the following d code which fails to compile. All 3
initializations of mywords fail. What am I doing wrong?
thanks.
$ dmd --help
Digital Mars D Compiler v2.042
Copyright (c) 1999-2010 by Digital Mars written by Walter Bright
Documentation: http://www.digitalmars.com/d/2.0/index.h
18 matches
Mail list logo