Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Laeeth Isharc via Digitalmars-d-learn
On Thursday, 1 January 2015 at 18:58:04 UTC, Andrej Mitrovic via Digitalmars-d-learn wrote: On 1/1/15, Tobias Pankrath via Digitalmars-d-learn wrote: You could implement an OrderedMap!(Key, Value) via RedBlackTree!(Tuple!(Key, Value), (a,b) => a[0] < b[0]). We could add this as an alias into

Re: Scoped external function declaration

2015-01-01 Thread ketmar via Digitalmars-d-learn
On Thu, 01 Jan 2015 17:51:45 + novice2 via Digitalmars-d-learn wrote: > I want to use external or C function. > It used only one time from one D function. > I want do declare C function inside D function. > I don't want to declare C function in global scope. > > Is my wish correct? > Reduced

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread ketmar via Digitalmars-d-learn
On Thu, 01 Jan 2015 12:32:33 + Idan Arye via Digitalmars-d-learn wrote: > If I have an associative array and I only modify it's values, > without changing the keys, can I assume that the order won't > change? please, don't: this is implementation-specific. druntime code can change (for exam

Re: Initialization of nested struct fields

2015-01-01 Thread Peter Alexander via Digitalmars-d-learn
On Friday, 2 January 2015 at 00:08:02 UTC, anonymous wrote: Apparently dmd thinks that the result of f must be a nested struct. I.e. it needs a context pointer. And I guess hell would break loose if you'd use a nested struct with a null context pointer. At least when the context pointer is actu

Re: Initialization of nested struct fields

2015-01-01 Thread anonymous via Digitalmars-d-learn
On Thursday, 1 January 2015 at 23:06:30 UTC, Peter Alexander wrote: Can someone please explain this behaviour? I find it totally bizarre. auto f(T)(T x) { struct S { T y; this(int) { } } return S(0); } void main() { f(f(0)); } E

Re: How to create instance of class that get data from 2 another instance?

2015-01-01 Thread anonymous via Digitalmars-d-learn
On Thursday, 1 January 2015 at 22:15:52 UTC, Suliman wrote: I have instance of class, that need data from 2 another classes. So I decided that I need to create it only after I get the data from both instance. auto mysql = new MySQL(parseconfig, seismoDownload); // the problem is here! (LOC 17

Initialization of nested struct fields

2015-01-01 Thread Peter Alexander via Digitalmars-d-learn
Can someone please explain this behaviour? I find it totally bizarre. auto f(T)(T x) { struct S { T y; this(int) { } } return S(0); } void main() { f(f(0)); } Error: constructor f376.f!(S).f.S.this field y must be initialized in

Re: Is it possible to use an UDA to generate a struct inside a class ?

2015-01-01 Thread Basile Burg via Digitalmars-d-learn
On Thursday, 1 January 2015 at 21:15:27 UTC, Ali Çehreli wrote: On 01/01/2015 09:35 AM, Basile Burg wrote: > On Tuesday, 30 December 2014 at 19:18:41 UTC, Basile Burg wrote: > an ICE (every > compiler crash is an ICE right ?), Yes, the compiler should never crash but produce an error message.

How to create instance of class that get data from 2 another instance?

2015-01-01 Thread Suliman via Digitalmars-d-learn
I have instance of class, that need data from 2 another classes. So I decided that I need to create it only after I get the data from both instance. auto mysql = new MySQL(parseconfig, seismoDownload); // the problem is here! (LOC 170) mysql need settings form parseconfig, and link from inst

Re: "function ... is not callable using argument types"

2015-01-01 Thread Ali Çehreli via Digitalmars-d-learn
On 01/01/2015 05:09 AM, Suliman wrote: But why variant: static const int PGSQL_UNITTEST_PORT = 5432; do not require of implicit convert to!short() at connection string? Walter Bright explains the reasons in his "Value Range Propagation" article: http://www.drdobbs.com/tools/value-range-prop

Re: Is it possible to use an UDA to generate a struct inside a class ?

2015-01-01 Thread Ali Çehreli via Digitalmars-d-learn
On 01/01/2015 09:35 AM, Basile Burg wrote: > On Tuesday, 30 December 2014 at 19:18:41 UTC, Basile Burg wrote: > an ICE (every > compiler crash is an ICE right ?), Yes, the compiler should never crash but produce an error message. Please report it preferably with a reduced code sample: http

Re: "function ... is not callable using argument types"

2015-01-01 Thread bearophile via Digitalmars-d-learn
Suliman: But why variant: static const int PGSQL_UNITTEST_PORT = 5432; do not require of implicit convert to!short() at connection string? Because value range analysis now propagates the range even across expressions if they are const. It's a recent improvement to make the D compile a bit

Re: Scoped external function declaration

2015-01-01 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 1 January 2015 at 17:51:46 UTC, novice2 wrote: I want to use external or C function. It used only one time from one D function. I want do declare C function inside D function. I don't want to declare C function in global scope. Is my wish correct? Reduced code: extern (C) int get

Re: Fastest Way to Append Multiple Elements to an Array

2015-01-01 Thread Nordlöw
On Wednesday, 31 December 2014 at 00:36:36 UTC, Damian wrote: Append and Prepend would be very useful additions to Phobos it's quite surprising there not already there? In any case would love to see some pull requests :) Do we really need Append and Prepend (along with append and prepend) here

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 1/1/15, Tobias Pankrath via Digitalmars-d-learn wrote: > You could implement an OrderedMap!(Key, Value) via > RedBlackTree!(Tuple!(Key, Value), (a,b) => a[0] < b[0]). We could add this as an alias into Phobos or perhaps as just a documentation line on the website.

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Tobias Pankrath via Digitalmars-d-learn
On Thursday, 1 January 2015 at 18:08:52 UTC, Andrej Mitrovic via Digitalmars-d-learn wrote: On 1/1/15, H. S. Teoh via Digitalmars-d-learn wrote: If you need consistent ordering of values, you probably want a different data structure, like an ordered map This one works nicely on D1, I'd imagi

Re: Call of rmdir in destructor causes InvalidMemoryOperationError

2015-01-01 Thread Timo Gransch via Digitalmars-d-learn
Am Thu, 01 Jan 2015 16:07:06 + schrieb "thedeemon" : > Solution in this case: call rmdir not from destructor. Thanks (also to Daniel Kozak) for the information. I moved the functionality to an explicitly called method. Best regards, Timo

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 1/1/15, H. S. Teoh via Digitalmars-d-learn wrote: > If you need consistent ordering of values, you probably want a different > data structure, like an ordered map This one works nicely on D1, I'd imagine the D2 port works just the same: https://github.com/SiegeLord/Tango-D2/blob/d2port/tango/

Scoped external function declaration

2015-01-01 Thread novice2 via Digitalmars-d-learn
I want to use external or C function. It used only one time from one D function. I want do declare C function inside D function. I don't want to declare C function in global scope. Is my wish correct? Reduced code: extern (C) int getch(); void main() { getch(); } //compiled OK void main()

Re: Is it possible to use an UDA to generate a struct inside a class ?

2015-01-01 Thread Basile Burg via Digitalmars-d-learn
On Tuesday, 30 December 2014 at 19:18:41 UTC, Basile Burg wrote: On Tuesday, 30 December 2014 at 19:05:23 UTC, Ali Çehreli wrote: On 12/30/2014 09:42 AM, Basile Burg wrote: Ok, thx. I see the trick: mixin (propertyInjections!C); Introspection inside each class. I don't find this solution u

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Jan 01, 2015 at 04:17:39PM +, Idan Arye via Digitalmars-d-learn wrote: [...] > My use case is that I have a large AA where the values are numbers and > the keys are strings, and I need to send it over network again and > again. The values constantly change but the keys should remain th

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 1/1/15, Peter Alexander via Digitalmars-d-learn wrote: > The order is unspecified, but an iteration must iterate in *some* > order. The question (if I've understood it correctly), is whether > that order of iteration changes when the keys aren't changed. Hmm yeah, that definitely wasn't ever s

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Idan Arye via Digitalmars-d-learn
On Thursday, 1 January 2015 at 13:39:57 UTC, Peter Alexander wrote: On Thursday, 1 January 2015 at 13:13:10 UTC, Andrej Mitrovic via Digitalmars-d-learn wrote: On 1/1/15, Idan Arye via Digitalmars-d-learn wrote: If I have an associative array and I only modify it's values, without changing the

Re: Call of rmdir in destructor causes InvalidMemoryOperationError

2015-01-01 Thread thedeemon via Digitalmars-d-learn
On Thursday, 1 January 2015 at 15:14:41 UTC, Timo Gransch wrote: Hi, I have a class which unzips an archive into a temporary directory below the system temp folder. I want to delete this temporary directory in the class's destructor, but when I call rmdir there, I get an core.exception.Inva

Re: Call of rmdir in destructor causes InvalidMemoryOperationError

2015-01-01 Thread Daniel Kozak via Digitalmars-d-learn
Timo Gransch via Digitalmars-d-learn píše v Čt 01. 01. 2015 v 16:14 +0100: > Hi, > > I have a class which unzips an archive into a temporary directory below the > system temp folder. I want to delete this temporary directory in the class's > destructor, but when I call rmdir there, I get an > >

Call of rmdir in destructor causes InvalidMemoryOperationError

2015-01-01 Thread Timo Gransch via Digitalmars-d-learn
Hi, I have a class which unzips an archive into a temporary directory below the system temp folder. I want to delete this temporary directory in the class's destructor, but when I call rmdir there, I get an core.exception.InvalidMemoryOperationError@(0) The effect is not limited to this specia

Re: Passing string literals to C

2015-01-01 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 31 December 2014 at 11:19:36 UTC, Laeeth Isharc wrote: Argh - no way to edit. What's best practice here? D strings are not null-terminated. === cpling.c char* cpling(char *s) { s[0]='!'; return s; } === dcaller.d extern(C) char* cpling(char* s); void callC() { writefln("%

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Peter Alexander via Digitalmars-d-learn
On Thursday, 1 January 2015 at 13:13:10 UTC, Andrej Mitrovic via Digitalmars-d-learn wrote: On 1/1/15, Idan Arye via Digitalmars-d-learn wrote: If I have an associative array and I only modify it's values, without changing the keys, can I assume that the order won't change? Associative arrays

Re: "function ... is not callable using argument types"

2015-01-01 Thread Tobias Pankrath via Digitalmars-d-learn
On Thursday, 1 January 2015 at 13:09:21 UTC, Suliman wrote: But why variant: static const int PGSQL_UNITTEST_PORT = 5432; do not require of implicit convert to!short() at connection string? As I said the compiler infers that 5432 is between short.min and short.max. Try it with something out

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Andrej Mitrovic via Digitalmars-d-learn
On 1/1/15, Idan Arye via Digitalmars-d-learn wrote: > If I have an associative array and I only modify it's values, > without changing the keys, can I assume that the order won't > change? Associative arrays are not ordered at all. See the first note here: http://dlang.org/hash-map.html

Re: "function ... is not callable using argument types"

2015-01-01 Thread Suliman via Digitalmars-d-learn
But why variant: static const int PGSQL_UNITTEST_PORT = 5432; do not require of implicit convert to!short() at connection string?

Re: "function ... is not callable using argument types"

2015-01-01 Thread Tobias Pankrath via Digitalmars-d-learn
So it's look like that it can accept strings and ints without problem. And I really can't understand why it's accept only "static const string" constructions... int does not implicitly convert to short. It does in the hardcoded version, because the compi

Can the order in associative array change when keys are not midified?

2015-01-01 Thread Idan Arye via Digitalmars-d-learn
If I have an associative array and I only modify it's values, without changing the keys, can I assume that the order won't change?

"function ... is not callable using argument types"

2015-01-01 Thread Suliman via Digitalmars-d-learn
I need to pass some config to ddbc driver. When I use static const all work ok. static const string PGSQL_UNITTEST_HOST = "localhost"; static const intPGSQL_UNITTEST_PORT = 5432; static const string PGSQL_UNITTEST_USER = "postgres"; static const string PGSQL_UNITTEST_PASSWORD = "Infinity8"