Re: Octree implementation?

2016-02-09 Thread Marco Leise via Digitalmars-d-learn
Am Wed, 10 Feb 2016 05:41:24 + schrieb Tofu Ninja : > On Thursday, 4 February 2016 at 17:56:06 UTC, Marco Leise wrote: > > Am Mon, 01 Feb 2016 02:56:06 + > > schrieb Tofu Ninja : > > > >> Just out of curiosity, does anyone have an octree > >> implementation for D laying around? Just looki

Re: Printing a C "string" with write(f)ln

2016-02-09 Thread Jakob Ovrum via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 22:39:14 UTC, Gary Willoughby wrote: On Tuesday, 9 February 2016 at 17:02:28 UTC, Jakob Ovrum wrote: to!string behaving like that was a poor design choice[1]. Please use fromStringz. [1] https://github.com/D-Programming-Language/phobos/pull/1607 It's not a poor

Re: Octree implementation?

2016-02-09 Thread Tofu Ninja via Digitalmars-d-learn
On Thursday, 4 February 2016 at 17:56:06 UTC, Marco Leise wrote: Am Mon, 01 Feb 2016 02:56:06 + schrieb Tofu Ninja : Just out of curiosity, does anyone have an octree implementation for D laying around? Just looking to save some time. I have one written in Delphi that you could prune til

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-09 Thread Saurabh Das via Digitalmars-d-learn
On Wednesday, 10 February 2016 at 00:24:56 UTC, tsbockman wrote: [...] `Tuple.slice` is corrupting data *right now*. Some sort of short-term fix should be merged in the next release of D. +1

Re: algorithm's .filter!() by range key

2016-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/09/2016 12:54 PM, Charles wrote: On Tuesday, 9 February 2016 at 20:48:01 UTC, Steven Schveighoffer wrote: On 2/9/16 3:40 PM, Charles wrote: This seems to be true of any range function really... is there a way to access the key within my range? Example of what I want to do: auto x = [1,2

Re: Automatic range creation for class or struct?

2016-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/09/2016 04:22 PM, cym13 wrote: On Wednesday, 10 February 2016 at 00:05:36 UTC, Peka wrote: Hi! I have class (or struct) which realises .length() and .opIndex(size_t) methods. It is possible to create from this class some sort of range using template from std? (I mean that internal counte

Re: Automatic range creation for class or struct?

2016-02-09 Thread cym13 via Digitalmars-d-learn
On Wednesday, 10 February 2016 at 00:27:54 UTC, Peka wrote: I don't think anything like that exists in phobos I need definitive answer. I need a precise answer. (sorry, google translator :з) "Definitive" is good, maybe even better in the context. I should have been clearer, sorry. When I

Re: Automatic range creation for class or struct?

2016-02-09 Thread Peka via Digitalmars-d-learn
I don't think anything like that exists in phobos I need definitive answer. I need a precise answer. (sorry, google translator :з)

Re: Automatic range creation for class or struct?

2016-02-09 Thread Peka via Digitalmars-d-learn
On Wednesday, 10 February 2016 at 00:22:46 UTC, cym13 wrote: On Wednesday, 10 February 2016 at 00:05:36 UTC, Peka wrote: Hi! I have class (or struct) which realises .length() and .opIndex(size_t) methods. It is possible to create from this class some sort of range using template from std? (

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-09 Thread tsbockman via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 09:05:58 UTC, Ola Fosheim Grøstad wrote: I suggest lobbying for proper builtin tuple support. Built-in tuple support would be great (although to my mind, mostly because the current syntax is clunky). But that is a long-term goal, and `Tuple.slice` is corrupting

Re: Automatic range creation for class or struct?

2016-02-09 Thread cym13 via Digitalmars-d-learn
On Wednesday, 10 February 2016 at 00:05:36 UTC, Peka wrote: Hi! I have class (or struct) which realises .length() and .opIndex(size_t) methods. It is possible to create from this class some sort of range using template from std? (I mean that internal counter, .popFront(), .empty() etc metho

Automatic range creation for class or struct?

2016-02-09 Thread Peka via Digitalmars-d-learn
Hi! I have class (or struct) which realises .length() and .opIndex(size_t) methods. It is possible to create from this class some sort of range using template from std? (I mean that internal counter, .popFront(), .empty() etc methods should be added by template.)

Re: why mkdir can't create tree of dirs?

2016-02-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 09, 2016 20:20:59 Suliman via Digitalmars-d-learn wrote: > It's look like that I can only create one nesting level sub > folder, for example there is exists dir: D:\foo > I can't create dir D:\foo\bar\baz I can only create D:\foo\bar > > D:\foo\bar > > Is it's rational limit or

Re: Printing a C "string" with write(f)ln

2016-02-09 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 17:02:28 UTC, Jakob Ovrum wrote: to!string behaving like that was a poor design choice[1]. Please use fromStringz. [1] https://github.com/D-Programming-Language/phobos/pull/1607 It's not a poor design choice. It ensures the string is handled by the D GC instead

Re: Printing a C "string" with write(f)ln

2016-02-09 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 16:58:03 UTC, Daniel Kozak wrote: Or use `to` like this: import std.conv; writefln("%s", pString.to!(string)); this will allocate new string which can be performance problem. Which is good in most cases. It's better to have the GC take care of the D string ins

Re: UFCS on Enum in Member Function

2016-02-09 Thread anonymous via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 21:05:50 UTC, jmh530 wrote: For instance, in the code below, I could use Baz but not Caz. It seems to work when I use the alternate version of Caz calling a non-member function. Bug? No bug; works as intended. UFCS can only be used with free functions, not wit

Re: why mkdir can't create tree of dirs?

2016-02-09 Thread Wyatt via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 20:20:59 UTC, Suliman wrote: It's look like that I can only create one nesting level sub folder, for example there is exists dir: D:\foo I can't create dir D:\foo\bar\baz I can only create D:\foo\bar http://dlang.org/phobos/std_file.html#.mkdirRecurse -Wyatt

UFCS on Enum in Member Function

2016-02-09 Thread jmh530 via Digitalmars-d-learn
I have been working with some C error codes that are organized in an enum. I noticed that if I tried to write a function that processes these error codes within a struct, then I could not use a UFCS-style call. For instance, in the code below, I could use Baz but not Caz. It seems to work whe

Re: why mkdir can't create tree of dirs?

2016-02-09 Thread anonymous via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 20:20:59 UTC, Suliman wrote: It's look like that I can only create one nesting level sub folder, for example there is exists dir: D:\foo I can't create dir D:\foo\bar\baz I can only create D:\foo\bar http://dlang.org/phobos/std_file.html#.mkdirRecurse td.window

Re: algorithm's .filter!() by range key

2016-02-09 Thread Charles via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 20:48:01 UTC, Steven Schveighoffer wrote: On 2/9/16 3:40 PM, Charles wrote: This seems to be true of any range function really... is there a way to access the key within my range? Example of what I want to do: auto x = [1,2,3,4,5]; x.filter( x_key % 2 == 1 ).sum

Re: algorithm's .filter!() by range key

2016-02-09 Thread Charles via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 20:44:34 UTC, cym13 wrote: On Tuesday, 9 February 2016 at 20:40:44 UTC, Charles wrote: This seems to be true of any range function really... is there a way to access the key within my range? Example of what I want to do: auto x = [1,2,3,4,5]; x.filter( x_key % 2

Re: algorithm's .filter!() by range key

2016-02-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/9/16 3:40 PM, Charles wrote: This seems to be true of any range function really... is there a way to access the key within my range? Example of what I want to do: auto x = [1,2,3,4,5]; x.filter( x_key % 2 == 1 ).sum(); // sum odd elements in array An array is not an indexed range. It onl

Re: algorithm's .filter!() by range key

2016-02-09 Thread cym13 via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 20:40:44 UTC, Charles wrote: This seems to be true of any range function really... is there a way to access the key within my range? Example of what I want to do: auto x = [1,2,3,4,5]; x.filter( x_key % 2 == 1 ).sum(); // sum odd elements in array x.filter!(x_k

algorithm's .filter!() by range key

2016-02-09 Thread Charles via Digitalmars-d-learn
This seems to be true of any range function really... is there a way to access the key within my range? Example of what I want to do: auto x = [1,2,3,4,5]; x.filter( x_key % 2 == 1 ).sum(); // sum odd elements in array

why mkdir can't create tree of dirs?

2016-02-09 Thread Suliman via Digitalmars-d-learn
It's look like that I can only create one nesting level sub folder, for example there is exists dir: D:\foo I can't create dir D:\foo\bar\baz I can only create D:\foo\bar D:\foo\bar Is it's rational limit or it is bug? Here is error when I tried to folder in folder thet do not exists. It's n

Re: How to warn of unused imports?

2016-02-09 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 17:54:30 UTC, Basile B. wrote: On Tuesday, 9 February 2016 at 15:21:59 UTC, Basile B. wrote: On Monday, 8 February 2016 at 20:48:29 UTC, cy wrote: On Monday, 8 February 2016 at 18:57:52 UTC, Basile B. wrote: Otherwise, it sounds like a decent enhancement request

Re: How to warn of unused imports?

2016-02-09 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 15:21:59 UTC, Basile B. wrote: On Monday, 8 February 2016 at 20:48:29 UTC, cy wrote: On Monday, 8 February 2016 at 18:57:52 UTC, Basile B. wrote: Otherwise, it sounds like a decent enhancement request for DMD. I know other compilers who do this warning. It defi

Re: Things that keep D from evolving?

2016-02-09 Thread NX via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 14:35:48 UTC, Ola Fosheim Grøstad wrote: Not incredibly high level abstraction... But I get what you mean. It is fairly high level for a low level language. Coming from C#, it looks amazing but probably not that incredible when coming from C++. So you want th

Re: Things that keep D from evolving?

2016-02-09 Thread Chris Wright via Digitalmars-d-learn
On Tue, 09 Feb 2016 14:35:48 +, Ola Fosheim Grøstad wrote: > On Tuesday, 9 February 2016 at 13:41:30 UTC, NX wrote: >> There are several reasons I want to use D rather than C# / Go / >> something else: >> - Interfacing with native API without jumping through hoops > > Well, but the hoops are

Re: Printing a C "string" with write(f)ln

2016-02-09 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 16:58:03 UTC, Daniel Kozak wrote: On Tuesday, 9 February 2016 at 16:52:09 UTC, Gary Willoughby wrote: On Tuesday, 9 February 2016 at 12:50:27 UTC, Jakob Ovrum wrote: writefln et al sensibly does *not* assume that a pointer to char is a C string, for memory safety

Re: Printing a C "string" with write(f)ln

2016-02-09 Thread Jakob Ovrum via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 16:52:09 UTC, Gary Willoughby wrote: On Tuesday, 9 February 2016 at 12:50:27 UTC, Jakob Ovrum wrote: writefln et al sensibly does *not* assume that a pointer to char is a C string, for memory safety purposes. Print the result of std.string.fromStringz[1] instead:

Re: Printing a C "string" with write(f)ln

2016-02-09 Thread Daniel Kozak via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 16:52:09 UTC, Gary Willoughby wrote: On Tuesday, 9 February 2016 at 12:50:27 UTC, Jakob Ovrum wrote: writefln et al sensibly does *not* assume that a pointer to char is a C string, for memory safety purposes. Print the result of std.string.fromStringz[1] instead:

Re: Printing a C "string" with write(f)ln

2016-02-09 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 12:50:27 UTC, Jakob Ovrum wrote: writefln et al sensibly does *not* assume that a pointer to char is a C string, for memory safety purposes. Print the result of std.string.fromStringz[1] instead: writeln(fromStringz(pString)); writefln("%s", fromStringz(pString))

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-09 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 16:00:09 UTC, Marc Schütz wrote: 2. Tuples use structural typing, not nominal typing. This has no relevance for the question at hand. It does if you allow casting and to use tuples a types in aggregates. The language becomes less strongly typed. 3. They are i

Re: std.concurrency: ownerTid vs thisTid

2016-02-09 Thread Daniel Kozak via Digitalmars-d-learn
https://github.com/D-Programming-Language/phobos/blob/v2.070.0/std/concurrency.d#L340 formattedWrite(sink, "Tid(%x)", &mbox); should be: formattedWrite(sink, "Tid(%x)", cast(void *)mbox); On Tue, Feb 9, 2016 at 5:25 PM, Daniel Kozak wrote: > You are right: > import std.stdio, std.concurrency;

Re: std.concurrency: ownerTid vs thisTid

2016-02-09 Thread Daniel Kozak via Digitalmars-d-learn
You are right: import std.stdio, std.concurrency; import std.concurrency : MessageBox; struct MyTid { MessageBox mbox; } static void f1() { auto tT = cast(MyTid)thisTid; auto oT = cast(MyTid)ownerTid; writeln("F1:worker: ", cast(void*)tT.mbox); writeln("F1:owner: ", cast(void*

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-09 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 14:28:35 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 9 February 2016 at 13:43:16 UTC, Marc Schütz wrote: So what? Using that argument, you could just as well forbid taking the address of any variable. What's so special about tuples, in contrast to structs and arra

Re: std.concurrency: ownerTid vs thisTid

2016-02-09 Thread miazo via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 15:55:34 UTC, Ali Çehreli wrote: On 02/09/2016 07:52 AM, Daniel Kozak via Digitalmars-d-learn wrote: It is OK, I guess the output is just mixed Yes, that's an important point but it is not the reason. (Just tested.) I think this is just an issue with how Tid o

Re: std.concurrency: ownerTid vs thisTid

2016-02-09 Thread Daniel Kozak via Digitalmars-d-learn
OK it seems wierd On Tue, Feb 9, 2016 at 4:52 PM, Daniel Kozak wrote: > It is OK, I guess the output is just mixed > > On Tue, Feb 9, 2016 at 4:35 PM, miazo via Digitalmars-d-learn < > digitalmars-d-learn@puremagic.com> wrote: > >> Hi, >> >> The following simple program: >> >> import std.stdio,

Re: std.concurrency: ownerTid vs thisTid

2016-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/09/2016 07:52 AM, Daniel Kozak via Digitalmars-d-learn wrote: It is OK, I guess the output is just mixed Yes, that's an important point but it is not the reason. (Just tested.) I think this is just an issue with how Tid objects are printed. Otherwise, everything works as expected and al

Re: std.concurrency: ownerTid vs thisTid

2016-02-09 Thread Daniel Kozak via Digitalmars-d-learn
It is OK, I guess the output is just mixed On Tue, Feb 9, 2016 at 4:35 PM, miazo via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Hi, > > The following simple program: > > import std.stdio, std.concurrency; > > void f1() { > writeln("owner: ", ownerTid); > writeln("wo

std.concurrency: ownerTid vs thisTid

2016-02-09 Thread miazo via Digitalmars-d-learn
Hi, The following simple program: import std.stdio, std.concurrency; void f1() { writeln("owner: ", ownerTid); writeln("worker: ", thisTid); } void main() { writeln("owner: ", thisTid); writeln("worker: ", spawn(&f1)); } Gives me the following result: owner: Tid(18fd58) worke

Re: How to warn of unused imports?

2016-02-09 Thread Basile B. via Digitalmars-d-learn
On Monday, 8 February 2016 at 20:48:29 UTC, cy wrote: On Monday, 8 February 2016 at 18:57:52 UTC, Basile B. wrote: Otherwise, it sounds like a decent enhancement request for DMD. I know other compilers who do this warning. It definitely does sound like a decent enhancement request. I didn't

Re: Things that keep D from evolving?

2016-02-09 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 13:01:29 UTC, NX wrote: Well, GC being better than it used to be doesn't change the fact it's still the > worst of it's kind. I don't know if this[1] work actually got released or merged but looks like it's abandoned. Pretty sad as it seemed very promising. [1] h

Re: How do you reference variables in an AA of Variants?

2016-02-09 Thread Wyatt via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 03:49:11 UTC, Enjoys Math wrote: This: double b = 1.0; Variant[string] aa = ["b": &b]; writeln(aa["b"]); fails with: Error: cannot implicitly convert expression(["b":&b]) of type double*[string] to VariantN!20u[string] Helps please!

Re: Things that keep D from evolving?

2016-02-09 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 13:41:30 UTC, NX wrote: There are several reasons I want to use D rather than C# / Go / something else: - Interfacing with native API without jumping through hoops Well, but the hoops are there to get safe and fast GC. - Incredibly high abstraction and meta-pro

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-09 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 13:43:16 UTC, Marc Schütz wrote: So what? Using that argument, you could just as well forbid taking the address of any variable. What's so special about tuples, in contrast to structs and arrays? Some key common qualities for a tuple: 1. They are primarily used

Re: Things that keep D from evolving?

2016-02-09 Thread Laeeth Isharc via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 13:01:29 UTC, NX wrote: On Monday, 8 February 2016 at 22:21:50 UTC, Laeeth Isharc wrote: The GC itself may still be far from perfect but its much better than it was, and there are more options now. I have found emsi containers (built on top of Andrei's allocator)

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-09 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 11:38:14 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 9 February 2016 at 10:54:42 UTC, Marc Schütz wrote: No need to restrict the language here, there's nothing stopping a decent compiler from storing tuples (actually _anything_) in registers, in some cases even if

Re: Things that keep D from evolving?

2016-02-09 Thread NX via Digitalmars-d-learn
On Monday, 8 February 2016 at 17:51:02 UTC, Ola Fosheim Grøstad wrote: C++ compilers have lots of optional warnings/errors, so it is quite possible. But I suppose those that want it would rather use Go, C# or some other GC language than can do ahead of time compilation. There are several reas

Re: Things that keep D from evolving?

2016-02-09 Thread NX via Digitalmars-d-learn
On Monday, 8 February 2016 at 22:21:50 UTC, Laeeth Isharc wrote: The GC itself may still be far from perfect but its much better than it was, and there are more options now. I have found emsi containers (built on top of Andrei's allocator) pretty nice myself for my own use. Well, GC being be

Re: Printing a C "string" with write(f)ln

2016-02-09 Thread y via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 12:46:59 UTC, Whirlpool wrote: Hello, When you are using a C function (from an external library) that returns a pointer on char which is the beginning of a string (I know that C does not have a string type, that they are just arrays of chars ended by '\0'), is t

Re: Printing a C "string" with write(f)ln

2016-02-09 Thread Jakob Ovrum via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 12:46:59 UTC, Whirlpool wrote: Hello, When you are using a C function (from an external library) that returns a pointer on char which is the beginning of a string (I know that C does not have a string type, that they are just arrays of chars ended by '\0'), is t

Re: Printing a C "string" with write(f)ln

2016-02-09 Thread Daniel Kozak via Digitalmars-d-learn
V Tue, 09 Feb 2016 12:46:59 + Whirlpool via Digitalmars-d-learn napsáno: > Hello, > > When you are using a C function (from an external library) that > returns a pointer on char which is the beginning of a string (I > know that C does not have a string type, that they are just > arrays of

Printing a C "string" with write(f)ln

2016-02-09 Thread Whirlpool via Digitalmars-d-learn
Hello, When you are using a C function (from an external library) that returns a pointer on char which is the beginning of a string (I know that C does not have a string type, that they are just arrays of chars ended by '\0'), is there a simple way to print that string with D's write(f)ln, sh

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-09 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 10:54:42 UTC, Marc Schütz wrote: No need to restrict the language here, there's nothing stopping a decent compiler from storing tuples (actually _anything_) in registers, in some cases even if references are taken. I'm pretty sure LLVM can handle this. If you do

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-09 Thread Marc Schütz via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 09:05:58 UTC, Ola Fosheim Grøstad wrote: IMO one shouldn't be able to take the reference of a tuple, to ensure that it can be kept in registers. No need to restrict the language here, there's nothing stopping a decent compiler from storing tuples (actually _anyth

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-09 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 08:35:21 UTC, tsbockman wrote: When faced with a judgment call like this, we really ought to err on the side of maintaining backwards compatibility - especially since this does not preclude adding a separate by-value version of `Tuple.slice`, as well. It was going

Re: Is this a bug in std.typecons.Tuple.slice?

2016-02-09 Thread tsbockman via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 06:22:55 UTC, Marco Leise wrote: As mentioned I never used the feature myself and wont vote for one or the other. Three people with no source code to exemplify current use of .slice! is indeed not much to base decisions on... The mere fact that all I had to do t