Re: Member access of __gshared global object

2014-07-30 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 31 Jul 2014 02:03:35 + Puming via Digitalmars-d-learn napsáno: > Hi, > > I'm writing this global Config class, with an AA member: > > ```d > module my.config; > > class Config > { > Command[string] commands; > } > > __gshared Config CONFIG; > ``` > > and initialize it in anot

Re: A little of coordination for Rosettacode

2014-07-30 Thread safety0ff via Digitalmars-d-learn
On Tuesday, 12 February 2013 at 01:07:35 UTC, bearophile wrote: In practice at the moment I am maintaining all the D entries of Rosettacode. I modified the Hamming numbers code in a personal exercise. It now uses considerably less memory but is slower. I've posted the code here in case it

Member access of __gshared global object

2014-07-30 Thread Puming via Digitalmars-d-learn
Hi, I'm writing this global Config class, with an AA member: ```d module my.config; class Config { Command[string] commands; } __gshared Config CONFIG; ``` and initialize it in another module: ```d module my.app; import my.config; void main() { CONFIG = new Config(); CONFIG.command

Re: pointer array?

2014-07-30 Thread Daniel Kozak via Digitalmars-d-learn
V Wed, 30 Jul 2014 14:33:51 + seany via Digitalmars-d-learn napsáno: > In Ali's excllent book, somehow one thing has escaped my > attention, and that it the mentioning of pointer arrays. > > Can pointers of any type of pointed variable be inserted in an > int array? Using to!(int) perhaps?

Re: pointer array?

2014-07-30 Thread Leandro Motta Barros via Digitalmars-d-learn
Can't you call it directly? extern(C) { int add (int a, int b)'; } // ... auto ret = add(123, 456); LMB On Wed, Jul 30, 2014 at 2:55 PM, seany via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > > >> Can you post the signatures of some of the C functions you're tryin

Re: pointer array?

2014-07-30 Thread seany via Digitalmars-d-learn
Can you post the signatures of some of the C functions you're trying to interface with? let us take a simple function : int add (int a, int b)

Re: pointer array?

2014-07-30 Thread Justin Whear via Digitalmars-d-learn
On Wed, 30 Jul 2014 15:44:14 +, seany wrote: > However some code is in C, legacy code, and for speed resons. So in some > cases, I would like to send a bunch of variables , ints, dubles and > floats to an external C function. The thing is, I do not always know the > number of variables, so my

Re: It is a bug?

2014-07-30 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 30 July 2014 at 16:14:56 UTC, Jesse Phillips wrote: On Wednesday, 30 July 2014 at 07:08:17 UTC, Kozzi11 wrote: #main.d: import m.f; class A { //class main.A member m is not accessible //mixin(t!(typeof(this), "m")); void m() {}; //here is ok //mixin(t!(typeof(this),

Re: It is a bug?

2014-07-30 Thread Jesse Phillips via Digitalmars-d-learn
On Wednesday, 30 July 2014 at 07:08:17 UTC, Kozzi11 wrote: #main.d: import m.f; class A { //class main.A member m is not accessible //mixin(t!(typeof(this), "m")); void m() {}; //here is ok //mixin(t!(typeof(this), "m")); } The compiler is trying to construct type A. The fi

Re: pointer array?

2014-07-30 Thread seany via Digitalmars-d-learn
Actually, I am writing a climate simulation software, and I would love to use D for parts of it. However some code is in C, legacy code, and for speed resons. So in some cases, I would like to send a bunch of variables , ints, dubles and floats to an external C function. The thing is, I do no

Re: pointer array?

2014-07-30 Thread Leandro Motta Barros via Digitalmars-d-learn
Justin's answers seems correct to me, and I don't know anything about your specific use case, but I cannot resist to add: Think twice before doing this kind of things. I know that sometimes this is necessary or handy, but one of the great things about D is that it provides so many higher-level ab

Re: pointer array?

2014-07-30 Thread Justin Whear via Digitalmars-d-learn
On Wed, 30 Jul 2014 14:33:51 +, seany wrote: > In Ali's excllent book, somehow one thing has escaped my attention, and > that it the mentioning of pointer arrays. > > Can pointers of any type of pointed variable be inserted in an int > array? Using to!(int) perhaps? If not directly, then what

pointer array?

2014-07-30 Thread seany via Digitalmars-d-learn
In Ali's excllent book, somehow one thing has escaped my attention, and that it the mentioning of pointer arrays. Can pointers of any type of pointed variable be inserted in an int array? Using to!(int) perhaps? If not directly, then what else would achieve the same effect?

Re: Type deduction on templated constructor.

2014-07-30 Thread Philippe Sigaud via Digitalmars-d-learn
On Wed, Jul 30, 2014 at 11:46 AM, Philippe Sigaud wrote: >> I expected such an answer and I do understand the decisions behind it. Yet, >> you gave me a really GOOD news! Having to write cast(ubyte) 1 was way too >> much verbose for my liking, while the new ubyte(1) is reasonable enough. > > Why n

Re: Type deduction on templated constructor.

2014-07-30 Thread Philippe Sigaud via Digitalmars-d-learn
> I expected such an answer and I do understand the decisions behind it. Yet, > you gave me a really GOOD news! Having to write cast(ubyte) 1 was way too > much verbose for my liking, while the new ubyte(1) is reasonable enough. Why not use `1u`?

It is a bug?

2014-07-30 Thread Kozzi11 via Digitalmars-d-learn
#main.d: import m.f; class A { //class main.A member m is not accessible //mixin(t!(typeof(this), "m")); void m() {}; //here is ok //mixin(t!(typeof(this), "m")); } void main(string[] args){} #m.f module m.f; string t(alias cls, string method)() { import std.traits; s