Re: dchar literals?

2013-11-12 Thread Kenji Hara
On Monday, 11 November 2013 at 13:20:04 UTC, bearophile wrote: Philippe Sigaud: And I agree with you than character literals should default to dchar. It's a perpetual source of friction for me. 99% of my char literals need to be of type char. On the other hand once you have suffixes to

Re: dchar literals?

2013-11-12 Thread Jonathan M Davis
On Tuesday, November 12, 2013 09:14:54 Kenji Hara wrote: On Monday, 11 November 2013 at 13:20:04 UTC, bearophile wrote: Philippe Sigaud: And I agree with you than character literals should default to dchar. It's a perpetual source of friction for me. 99% of my char literals need to

Re: bidirectional map

2013-11-12 Thread Andrea Fontana
On Tuesday, 12 November 2013 at 01:14:47 UTC, bioinfornatics wrote: Dear, I am looking for a bidirectional map i.e http://en.wikipedia.org/wiki/Bidirectional_map My seach into D documentation seem to said to me that this structure is not implemented. Something like (for primary idea):

Re: dchar literals?

2013-11-12 Thread bearophile
Kenji Hara: Or, uniform construction for built-in types would be another better way. auto c = char('a'); auto w = wchar('a'); auto d = dchar('a'); auto x = char('à'); // compile-time error Yes, uniform construction syntax for all types seems a good idea. But the suffixes for chars, as

how use lowerBound with just sorting key, not complete values

2013-11-12 Thread Daniel Davidson
The following code works for finding the lower bound based on needle. But I have to create a needle which I don't want to do. How can I use lowerBound with just the sortKey, date in this case? So I want to do something like the following - but it won't work. Is there a way to search an array

Re: bidirectional map

2013-11-12 Thread bioinfornatics
On Tuesday, 12 November 2013 at 09:10:07 UTC, Andrea Fontana wrote: On Tuesday, 12 November 2013 at 01:14:47 UTC, bioinfornatics wrote: Dear, I am looking for a bidirectional map i.e http://en.wikipedia.org/wiki/Bidirectional_map My seach into D documentation seem to said to me that this

Re: how use lowerBound with just sorting key, not complete values

2013-11-12 Thread bearophile
Daniel Davidson: Is there a way to search an array I know is ordered by date by only supplying date? You can use a map to perform a projection: import std.stdio, std.range, std.datetime, std.algorithm, std.array; struct S { Date date; string foo; } void main() { auto

Re: how use lowerBound with just sorting key, not complete values

2013-11-12 Thread Daniel Davidson
On Tuesday, 12 November 2013 at 15:51:53 UTC, bearophile wrote: Daniel Davidson: Is there a way to search an array I know is ordered by date by only supplying date? You can use a map to perform a projection: import std.stdio, std.range, std.datetime, std.algorithm, std.array;

Re: how use lowerBound with just sorting key, not complete values

2013-11-12 Thread bearophile
Daniel Davidson: Yes, but that is only giving the dates. I want the actual array elements. Suppose S is a large object with lots of extra fields in addition to `string foo`. There should be a way to pull out the lower bound based on a date without creating a needle (S). Maybe lowerBound is

Re: how use lowerBound with just sorting key, not complete values

2013-11-12 Thread Daniel Davidson
On Tuesday, 12 November 2013 at 16:34:30 UTC, bearophile wrote: Daniel Davidson: Yes, but that is only giving the dates. I want the actual array elements. Suppose S is a large object with lots of extra fields in addition to `string foo`. There should be a way to pull out the lower bound

Re: Unexpected behavior when misusing inline assembly

2013-11-12 Thread Noah
Just realized I forgot to delete the 7 and the x from inside the function calls. Question is the same, though. On Tuesday, 12 November 2013 at 18:22:46 UTC, Noah wrote: When running the following code: __gshared void* return_ptr; __gshared void* injected_fn = fn; void main() { buffer(7);

Unexpected behavior when misusing inline assembly

2013-11-12 Thread Noah
When running the following code: __gshared void* return_ptr; __gshared void* injected_fn = fn; void main() { buffer(7); printf(End main\n); } void buffer() { test(x); printf(End buffer\n); } void test() { printf(This is a test!\n); inject(); printf(End of the

Re: Unexpected behavior when misusing inline assembly

2013-11-12 Thread Noah
Of course after I post this I realize the answer. The function only works when the surrounding function has at least one argument. Probably has something to do with the way the compiler emits no-argument functions, I'll have to look at some disassembly.

__gshared immutable array of immutable elements

2013-11-12 Thread Nicolas Sicard
In this declaration (tango.io.Console.d from Tango2): __gshared immutable immutable(char)[] Eol = \r\n; Aren't the two `immutable` keywords redundant? Why would `__gshared` be necessary for such an immutable type? Thanks

Re: __gshared immutable array of immutable elements

2013-11-12 Thread Martin Drašar
Dne 12.11.2013 19:49, Nicolas Sicard napsal(a): In this declaration (tango.io.Console.d from Tango2): __gshared immutable immutable(char)[] Eol = \r\n; Aren't the two `immutable` keywords redundant? Why would `__gshared` be necessary for such an immutable type? Thanks Hi, this declaration

Object destruction versus finalization

2013-11-12 Thread Florian
I played around a little and figured out, that destructors in D work quite similarily to destructors in C++. They are invoked, after the members of the instance being destructed have been destroyed themselfes (or at least have been brought into an invalid state). Therefore, these members

Re: __gshared immutable array of immutable elements

2013-11-12 Thread Dicebot
On Tuesday, 12 November 2013 at 20:09:57 UTC, Martin Drašar wrote: Those two immutables are not redundant, because it is an array of immutable chars (string), that is itself immutable. It is redundant because immutable is transitive. immutable char[] is equivalent. But Tango has lot of

Re: Object destruction versus finalization

2013-11-12 Thread Dicebot
On Tuesday, 12 November 2013 at 20:15:02 UTC, Florian wrote: I played around a little and figured out, that destructors in D work quite similarily to destructors in C++. They are invoked, after the members of the instance being destructed have been destroyed themselfes (or at least have been

opCmp on a struct keyed by an array of bytes

2013-11-12 Thread Charles Hixson
Is there any better way to write the method than: (cmp doesn't seem to work, and byte arrays don't have an opCmp method.) int opCmp(ref const B24 b) const {for(int i = 0;i 24;i++) {if(bytes[i] b.bytes[i])return-1; if(bytes[i] b.bytes[i])

Re: opCmp on a struct keyed by an array of bytes

2013-11-12 Thread Ali Çehreli
On 11/12/2013 01:06 PM, Charles Hixson wrote: Is there any better way to write the method than: (cmp doesn't seem to work, and byte arrays don't have an opCmp method.) int opCmp(ref const B24 b) const {for(int i = 0;i 24;i++) {if(bytes[i] b.bytes[i])return

Re: [Font] Getting font folder on all platforms

2013-11-12 Thread Xavier Bigand
Le 08/11/2013 21:05, Flamaros a écrit : On Tuesday, 15 October 2013 at 23:10:32 UTC, Flamaros wrote: On Friday, 6 September 2013 at 20:54:53 UTC, Flamaros wrote: On Friday, 6 September 2013 at 16:05:43 UTC, Tourist wrote: On Thursday, 5 September 2013 at 19:48:07 UTC, Flamaros wrote: I am

Re: Object destruction versus finalization

2013-11-12 Thread Florian
On Tuesday, 12 November 2013 at 20:29:13 UTC, Dicebot wrote: On Tuesday, 12 November 2013 at 20:15:02 UTC, Florian wrote: I played around a little and figured out, that destructors in D work quite similarily to destructors in C++. They are invoked, after the members of the instance being

Re: __gshared immutable array of immutable elements

2013-11-12 Thread Nicolas Sicard
On Tuesday, 12 November 2013 at 20:16:31 UTC, Dicebot wrote: On Tuesday, 12 November 2013 at 20:09:57 UTC, Martin Drašar wrote: Those two immutables are not redundant, because it is an array of immutable chars (string), that is itself immutable. It is redundant because immutable is

Re: opCmp on a struct keyed by an array of bytes

2013-11-12 Thread bearophile
Ali Çehreli: int opCmp(ref const B24 b) const { return bytes[].cmp(b.bytes[]); Few months ago I have written a small rant about that. That little [] at the end of those arrays is not innocuous, it essentially throws away a very precious compile-time amount of information:

Re: Object destruction versus finalization

2013-11-12 Thread Jonathan M Davis
On Tuesday, November 12, 2013 23:40:24 Florian wrote: it would be possible to move the shutdown() sequence into the destructor of the Connection class. Classes in D do not have destructors. Only structs to. ~this is a destructor in a struct, but it's a finalizer in a class. Finalizers are not

Re: Object destruction versus finalization

2013-11-12 Thread Florian
I understood very well, that the garbage collector is not guaranteed to run. However, it does not explain the segmentation fault in my example, does it?

Re: Object destruction versus finalization

2013-11-12 Thread Jonathan M Davis
On Wednesday, November 13, 2013 00:07:12 Florian wrote: I understood very well, that the garbage collector is not guaranteed to run. However, it does not explain the segmentation fault in my example, does it? You're getting a segfault, because you're using something which is on the GC heap -

Re: Object destruction versus finalization

2013-11-12 Thread Dicebot
On Tuesday, 12 November 2013 at 23:18:11 UTC, Jonathan M Davis wrote: You can't do that in finalizer, because the GC can choose to free it before the finalizer even runs (this avoids issues with circular references). Ah, damn, have forgotten about it. Disregard previous post.

Re: Object destruction versus finalization

2013-11-12 Thread Dicebot
On Tuesday, 12 November 2013 at 22:40:26 UTC, Florian wrote: The example below prints the following output: ~Connection ~Session segmentation fault Same example prints this for me (no segfault): ~Session shutdown ~Connection 2.064.2 @ linux-64 What is your system / compiler?

Re: Odd compiler complaints with import declarations

2013-11-12 Thread Orfeo
See also http://d.puremagic.com/issues/show_bug.cgi?id=11451

Re: opCmp on a struct keyed by an array of bytes

2013-11-12 Thread Charles Hixson
On 11/12/2013 01:38 PM, Ali Çehreli wrote: On 11/12/2013 01:06 PM, Charles Hixson wrote: Is there any better way to write the method than: (cmp doesn't seem to work, and byte arrays don't have an opCmp method.) int opCmp(ref const B24 b) const {for(int i = 0;i 24;i++)

Re: opCmp on a struct keyed by an array of bytes

2013-11-12 Thread bearophile
Charles Hixson: I had tried return bytes.cmp(b.bytes); , but it didn't occur to me that the error meant I should have used a copy? Does this syntax mean that what's being compared is a dynamic array copy of the original static array? They are not copies, just slices. In case of doubts take

Re: bidirectional map

2013-11-12 Thread Ellery Newcomer
On 11/11/2013 05:14 PM, bioinfornatics wrote: Dear, I am looking for a bidirectional map i.e http://en.wikipedia.org/wiki/Bidirectional_map My seach into D documentation seem to said to me that this structure is not implemented. Something like (for primary idea): struct

Re: Simple immutable example doesn't work - why???

2013-11-12 Thread Louis Berube
Thanks to both TFF and Kenji for their excellent explanations. I think my head is going to explode ;). So, as I understand it, there are two sorts of immutable entities in D. The first is probably the one most familiar to the majority of us, which is an entity with immutable contents but

cannot infer argument types

2013-11-12 Thread bioinfornatics
Hi, I have this error message ( i.e title ) and i do not see where i am wrong: this( in ubyte wordLength, in string sequence ){ kMer = wordLength; bytePerChar = cast(ubyte)(T.sizeof / kMer); char[ubyte] toCharTmp; ubyte[char] toNumTmp; foreach(

Re: cannot infer argument types

2013-11-12 Thread Jonathan M Davis
On Wednesday, November 13, 2013 03:43:40 bioinfornatics wrote: Hi, I have this error message ( i.e title ) and i do not see where i am wrong: this( in ubyte wordLength, in string sequence ){ kMer = wordLength; bytePerChar = cast(ubyte)(T.sizeof / kMer);

ddoc - modules with same name

2013-11-12 Thread rumbu
Let's suppose I have a module structure: - package.module1.core - package.module2.core Building documentation with dmd will generate a sigle core.html file with content related only to package.module2.core, overwriting the first one. Is there any way that dmd can recreate directory