Re: D / GtkD for SQL Server

2013-11-07 Thread Jacob Carlborg
On 2013-11-06 09:03, John J wrote: Sorry, I meant to say FreeTDS doesn't seem to support 64-bit Windows. Aha, that might be the case. Somehow I missed that you needed to run the application on Windows. FreeTDS is mainly to be able to connect to SQL Server on non-Windows platforms. Can't you

Re: How to iterate through all modules for use with the new getUnitTests trait?

2013-11-07 Thread Jacob Carlborg
On 2013-11-06 22:26, Dicebot wrote: You need only symbol name of your root compiled module which imports all others. All imported ones will be available in its member list, exactly what this snippet shows. That is the problem. One needs to import all other modules. That's not a good solution

Re: How to iterate through all modules for use with the new getUnitTests trait?

2013-11-07 Thread Jacob Carlborg
On 2013-11-06 23:33, Gary Willoughby wrote: foreach (module_; ModuleInfo) { auto func = module_.unitTest; func(); // run tests; } The above code retrieves all of the current project's modules and then grabs each module's unit test blocks. The only trouble is that the module's unit

Re: BinaryHeap

2013-11-07 Thread bearophile
Agustin: I'm trying to use BinaryHeap and i found out that i cannot use foreach(). My question is, there is any other way to do it?, can i iterate a BinaryHeap? Please show the code :-) Perhaps you need to look at the head, pop the head item, look at the head, etc. Bye, bearophile

Re: struct Unique(T)

2013-11-07 Thread Namespace
On Thursday, 7 November 2013 at 00:07:25 UTC, ChrisG wrote: Hi, I've been following the D language off and on for several years, have read Andrei's D book, but haven't ever posted here before. Mostly, I come from a C++ and C# background. Recently, I was playing with D using the derelict

Re: How to iterate through all modules for use with the new getUnitTests trait?

2013-11-07 Thread Sönke Ludwig
Am 07.11.2013 09:37, schrieb Jacob Carlborg: On 2013-11-06 22:26, Dicebot wrote: You need only symbol name of your root compiled module which imports all others. All imported ones will be available in its member list, exactly what this snippet shows. That is the problem. One needs to import

Thread termination conditions in dmd 2.064.2

2013-11-07 Thread Atila Neves
I had code that worked in 2.063 that crashes now (on Linux, on Windows it still works). I suspect I was doing something stupid and got lucky, but I'm posting here to make sure. Code: import std.concurrency; private void func() { auto done = false; while(!done) { receive(

Re: UFCS with constructors

2013-11-07 Thread bearophile
qznc: Operator precedence of . is higher than unary minus. You are right, I didn't know it, so Typedef and constructors are not to blame: double foo(in double x) { assert (x = 0); return x; } void main() { assert(-1.foo == -1); } Is this a good design of the operator

Re: Thread termination conditions in dmd 2.064.2

2013-11-07 Thread Atila Neves
Looking like a bug I think. Changed the code to this and it crashes again: import std.concurrency; private void threadWriter() { for(bool running = true; running;) { receive( (Tid i) { }, (OwnerTerminated trm) { running = false;

Multiple gtk installations

2013-11-07 Thread Benjamin Thaut
I'm wondering what's the correct way to handle multiple gtk installations on windows? When developing I most likely will have at least two at all times, the 32-bit version and the 64-bit version. When they are both added to the PATH they will obviously conflict. Googeling this issue doesn't

Re: Thread termination conditions in dmd 2.064.2

2013-11-07 Thread Sönke Ludwig
Am 07.11.2013 11:28, schrieb Atila Neves: Looking like a bug I think. Changed the code to this and it crashes again: import std.concurrency; private void threadWriter() { for(bool running = true; running;) { receive( (Tid i) { },

Re: How to iterate through all modules for use with the new getUnitTests trait?

2013-11-07 Thread Dicebot
On Thursday, 7 November 2013 at 10:04:57 UTC, Sönke Ludwig wrote: Can't you do something like this? Or is the unit test framework supposed to provide its own root/main module? ... void runTests(string root_module = __MODULE__)() { // start recursion from root_module } --- Only issue is

Re: BinaryHeap

2013-11-07 Thread Agustin
On Thursday, 7 November 2013 at 09:00:11 UTC, bearophile wrote: Agustin: I'm trying to use BinaryHeap and i found out that i cannot use foreach(). My question is, there is any other way to do it?, can i iterate a BinaryHeap? Please show the code :-) Perhaps you need to look at the head,

Re: How to iterate through all modules for use with the new getUnitTests trait?

2013-11-07 Thread Dicebot
On Thursday, 7 November 2013 at 12:07:40 UTC, Dicebot wrote: Only issue is .di file usage - you can't access implementation declarations when importing those via compile-time reflection. Other than that I don't see any possible failure sources. As there is also an issue of having modules a

Re: How to iterate through all modules for use with the new getUnitTests trait?

2013-11-07 Thread Dicebot
On Thursday, 7 November 2013 at 08:37:02 UTC, Jacob Carlborg wrote: That is the problem. One needs to import all other modules. That's not a good solution when creating a unit test framework. One would basically have to scan a directory for all D files. Then generate a new file that imports

Re: BinaryHeap

2013-11-07 Thread Agustin
On Thursday, 7 November 2013 at 12:14:22 UTC, Agustin wrote: On Thursday, 7 November 2013 at 09:00:11 UTC, bearophile wrote: Agustin: I'm trying to use BinaryHeap and i found out that i cannot use foreach(). My question is, there is any other way to do it?, can i iterate a BinaryHeap?

Re: BinaryHeap

2013-11-07 Thread bearophile
Agustin: no property 'popFront' for type 'BinaryHeap!(uint[])' Try to use front and removeFront (I don't know why there is removeFront instead of popFront). Bye, bearophile

Re: BinaryHeap

2013-11-07 Thread Agustin
On Thursday, 7 November 2013 at 12:29:44 UTC, bearophile wrote: Agustin: no property 'popFront' for type 'BinaryHeap!(uint[])' Try to use front and removeFront (I don't know why there is removeFront instead of popFront). Bye, bearophile Saddly i had to do this auto clone =

Re: BinaryHeap

2013-11-07 Thread Agustin
On Thursday, 7 November 2013 at 12:45:11 UTC, Agustin wrote: On Thursday, 7 November 2013 at 12:29:44 UTC, bearophile wrote: Agustin: no property 'popFront' for type 'BinaryHeap!(uint[])' Try to use front and removeFront (I don't know why there is removeFront instead of popFront). Bye,

Re: How to compile and test samples under Windows?

2013-11-07 Thread Adam Ryczkowski
Is this simple enough to explain me what I need to do? I'm new to the D language.

Re: BinaryHeap

2013-11-07 Thread Agustin
On Thursday, 7 November 2013 at 12:29:44 UTC, bearophile wrote: Agustin: no property 'popFront' for type 'BinaryHeap!(uint[])' Try to use front and removeFront (I don't know why there is removeFront instead of popFront). Bye, bearophile I had to implement a custom IterableBinaryHeap

Re: Multiple gtk installations

2013-11-07 Thread Jacob Carlborg
On 2013-11-07 11:45, Benjamin Thaut wrote: I'm wondering what's the correct way to handle multiple gtk installations on windows? When developing I most likely will have at least two at all times, the 32-bit version and the 64-bit version. When they are both added to the PATH they will obviously

Re: How to iterate through all modules for use with the new getUnitTests trait?

2013-11-07 Thread Jacob Carlborg
On 2013-11-07 13:22, Dicebot wrote: I don't see this much an issue as expect good testing framework to be coupled with a build system anyway. Also in really _lot_ of programs simply adding mixin to your `app.d` / `main.d` is enough as everything else is transitively imported from there. That

Re: How to iterate through all modules for use with the new getUnitTests trait?

2013-11-07 Thread Dicebot
On Thursday, 7 November 2013 at 15:03:40 UTC, Jacob Carlborg wrote: That doesn't work with libraries. You can have a library consisting of two separate files that doesn't import each other. I also prefer to put my tests in its own files, in a separate directory. They are not imported by any

Re: Multiple gtk installations

2013-11-07 Thread Benjamin Thaut
Am 07.11.2013 15:58, schrieb Jacob Carlborg: On 2013-11-07 11:45, Benjamin Thaut wrote: I'm wondering what's the correct way to handle multiple gtk installations on windows? When developing I most likely will have at least two at all times, the 32-bit version and the 64-bit version. When they

Re: Limiting template functions to template instantiations of a struct

2013-11-07 Thread Marco Leise
Am Wed, 06 Nov 2013 14:22:13 +0100 schrieb simendsjo simend...@gmail.com: template isFoo(T) { static if(is(T:Foo!U, int U)) enum isFoo = true; else enum isFoo = false; } enum isFoo(T) = is(T:Foo!U, int U); correct ? -- Marco

Re: How to re-initialise an associative array.

2013-11-07 Thread Marco Leise
Am Wed, 06 Nov 2013 18:14:54 +0100 schrieb Gary Willoughby d...@nomad.so: I'm not taking the chance and currently using: x = (int[string]).init; x = null; is shorter. Just saying ;) -- Marco

Re: Small troubles with private

2013-11-07 Thread Jesse Phillips
On Tuesday, 5 November 2013 at 16:00:43 UTC, bearophile wrote: How to solve such little troubles? A possible idea is to add to D another attribute, a kind of private private that is enforced inside the same module. It could be named super private because D has the super keyword :-) But this

Re: Limiting template functions to template instantiations of a struct

2013-11-07 Thread simendsjo
On Thursday, 7 November 2013 at 15:46:53 UTC, Marco Leise wrote: Am Wed, 06 Nov 2013 14:22:13 +0100 schrieb simendsjo simend...@gmail.com: template isFoo(T) { static if(is(T:Foo!U, int U)) enum isFoo = true; else enum isFoo = false; }

Unexpected OPTLINK Termination at EIP=000000000

2013-11-07 Thread Agustin
I'm getting Unexpected OPTLINK Termination at EIP = 0 and assembly register values when compiling the follow code. I'm doing something wrong? class MyClass { void opCall() { } } public void main(string[] arguments) { MyClass clazz = new MyClass(); TaskPool pool = new

Re: Multiple gtk installations

2013-11-07 Thread Benjamin Thaut
Am 07.11.2013 16:58, schrieb Alexandr Druzhinin: 07.11.2013 22:53, Alexandr Druzhinin пишет: 07.11.2013 22:12, Benjamin Thaut пишет: Am 07.11.2013 15:58, schrieb Jacob Carlborg: On 2013-11-07 11:45, Benjamin Thaut wrote: I'm wondering what's the correct way to handle multiple gtk

Re: Limiting template functions to template instantiations of a struct

2013-11-07 Thread Timon Gehr
On 11/07/2013 12:07 AM, H. S. Teoh wrote: // This is possibly the single nastiest bit of syntax in all of D: static if (is(func X == __parameters)) { // Quick, without looking at the docs: what does X refer // to? Nothing.

Re: struct Unique(T)

2013-11-07 Thread ChrisG
On Thursday, 7 November 2013 at 01:09:45 UTC, Chris Cain wrote: On Thursday, 7 November 2013 at 00:07:25 UTC, ChrisG wrote: My question is: what's the status of D's struct Unique? It looks like struct RefCounted is current, but I can't tell with Unique. There's several comments in the source

Re: Source code of a method.

2013-11-07 Thread Baz
On Thursday, 7 November 2013 at 17:31:45 UTC, Baz wrote: On Monday, 4 November 2013 at 19:50:22 UTC, Baz wrote: On Monday, 4 November 2013 at 18:00:17 UTC, Baz wrote: On Monday, 4 November 2013 at 16:42:42 UTC, Jacob Carlborg wrote: On 2013-11-04 16:09, Baz wrote: On Saturday, 26 October 2013

Re: Multiple gtk installations

2013-11-07 Thread Mike Wey
On 11/07/2013 06:16 PM, Benjamin Thaut wrote: Am 07.11.2013 16:58, schrieb Alexandr Druzhinin: 07.11.2013 22:53, Alexandr Druzhinin пишет: 07.11.2013 22:12, Benjamin Thaut пишет: Am 07.11.2013 15:58, schrieb Jacob Carlborg: On 2013-11-07 11:45, Benjamin Thaut wrote: I'm wondering what's the

Re: struct Unique(T)

2013-11-07 Thread Namespace
On Thursday, 7 November 2013 at 18:19:35 UTC, ChrisG wrote: On Thursday, 7 November 2013 at 09:51:38 UTC, Namespace wrote: Dgame use the SDL also and needed therefore (as you do) shared and unique pointers (mostly shared). So I wrote my own versions and like to share them with you, maybe it

Re: Multiple gtk installations

2013-11-07 Thread Benjamin Thaut
Am 07.11.2013 20:28, schrieb Mike Wey: On 11/07/2013 06:16 PM, Benjamin Thaut wrote: I don't know how other apps do this, but afaik giving each app there own private copy can still cause problems. If a dll with the same name as the one you are trying to load is already in memory, Windows will

Re: Multiple gtk installations

2013-11-07 Thread Benjamin Thaut
Am 07.11.2013 20:15, schrieb Mike Wey: On 11/07/2013 11:45 AM, Benjamin Thaut wrote: Having both the 32 and 64 bits versions of GTK in your PATH doesn't seem to be causing any problems for me. Well it is for me. As the dlls are named the same the 64-bit executable attempts to load the

Re: Multiple gtk installations

2013-11-07 Thread Jacob Carlborg
On 2013-11-07 16:12, Benjamin Thaut wrote: Woudln't it be necessary to copy the other gtk assets there too? Like the fonts etc? I have no idea. Just give it a try and copy the DLL's. In any case, wouldn't the assets be the same for 32 and 64bit if they are the same version. -- /Jacob

Re: Multiple gtk installations

2013-11-07 Thread Jacob Carlborg
On 2013-11-07 21:03, Benjamin Thaut wrote: Well it is for me. As the dlls are named the same the 64-bit executable attempts to load the 32-bit dll first (because its the first one to be found in the PATH) No flag available for ignoring DLL's of the wrong architecture? -- /Jacob Carlborg

Re: Multiple gtk installations

2013-11-07 Thread Mike Wey
On 11/07/2013 09:02 PM, Benjamin Thaut wrote: Am 07.11.2013 20:28, schrieb Mike Wey: On 11/07/2013 06:16 PM, Benjamin Thaut wrote: I don't know how other apps do this, but afaik giving each app there own private copy can still cause problems. If a dll with the same name as the one you are

File IO: C# streams VS iterators?

2013-11-07 Thread DDD
I was watching a dconf talk about porting C# code to D. One thing that came up was there isn't anything like C# streams for D. Walter said he thinks iterators (unless I remember wrong) is superior. The speaker agreed but said it isn't a drop in replacement so that is an issue if you want to

Template class with dispatched properties

2013-11-07 Thread Ross Hays
I have been playing around with a vector implementation that I am trying to write in D, and have been having problems getting something to work (it probably isn't even possible). My end goal is to be able to instantiate a vector with a syntax like... `Vector!(2, float) vec = new Vector!(2,

Re: Template class with dispatched properties

2013-11-07 Thread Chris Cain
On Friday, 8 November 2013 at 02:13:01 UTC, Ross Hays wrote: My end goal is to be able to instantiate a vector with a syntax like... `Vector!(2, float) vec = new Vector!(2, float)();` ... Any suggestions? Greetings, This works: --- import std.stdio; struct Vector(int N, T) if (N = 3) {

Re: Template class with dispatched properties

2013-11-07 Thread Chris Cain
On Friday, 8 November 2013 at 02:48:31 UTC, Chris Cain wrote: Minor tweaks might be necessary, but that should get you started. Actually, I refactored it a little bit to make it better (original code was just a bit too messy for my taste): --- struct Vector(int N, T) if (N = 3) { private

Re: File IO: C# streams VS iterators?

2013-11-07 Thread Lionello Lunesu
On 11/8/13, 8:57, DDD wrote: I was watching a dconf talk about porting C# code to D. One thing that came up was there isn't anything like C# streams for D. Walter said he thinks iterators (unless I remember wrong) is superior. The speaker agreed but said it isn't a drop in replacement so that is

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
Awesome that seems to do what I was going for. I had tried a similar approach with @property dispatch and the subtraction of 'x', but I had left out the static if and had the opDispatch returning a ref of the entry in the array (so there would just be the one @property still) but that resulted

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
I am actually a little curious why my original approach did not work at all. Using some of what you provided and some of what I had I get the following: import std.stdio; import std.string; class Vector(int N, T) if (N = 3) { T[N] data; this() { data[] = 0; }

Re: Template class with dispatched properties

2013-11-07 Thread Chris Cain
On Friday, 8 November 2013 at 03:42:12 UTC, Ross Hays wrote: I am actually a little curious why my original approach did not work at all. Using some of what you provided and some of what I had I get the following: import std.stdio; import std.string; class Vector(int N, T) if (N = 3) {

Re: Template class with dispatched properties

2013-11-07 Thread Chris Cain
On Friday, 8 November 2013 at 04:06:22 UTC, Chris Cain wrote: So fix 2 and 3 and it works for getting x. Also, define `toOffset` in the template constraint.

Re: Operator Precedence and Associativity

2013-11-07 Thread Tyro[17]
On 11/5/13, 11:36 PM, Jonathan M Davis wrote: On Tuesday, November 05, 2013 22:34:49 Tyro[17] wrote: I’m sure the following table is missing a few items but am unclear what they are. For starters these , =, , , !, != belong on the table but I’m not sure where. I'm not quite sure where they

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
Strange. I'm getting a different error, but I'm still running 2.063.2. The error I get is `Error: cannot resolve type for t.opDispatch!(x)` What version are you running? I just updated to 2.064.2 In any case, the reason apparently is multifold: 1. Apparently the proper error message isn't

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
On Friday, 8 November 2013 at 04:28:31 UTC, Ross Hays wrote: Strange. I'm getting a different error, but I'm still running 2.063.2. The error I get is `Error: cannot resolve type for t.opDispatch!(x)` What version are you running? I just updated to 2.064.2 In any case, the reason apparently

Re: Template class with dispatched properties

2013-11-07 Thread Chris Cain
On Friday, 8 November 2013 at 04:28:31 UTC, Ross Hays wrote: class Vector(int N, T) if (N = 3) { T[N] data; this() { data[] = 0; } @property ref T opDispatch(string fieldName, Args ...)(Args args) if (Args.length 2 fieldName.length == 1

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
Sorry, I forgot to mention in that post that you have toOffset in your template constraint, which means it will also never match. You'll have to define it or replace it with `fieldName[0] - 'x';` Also, you might not want to do `fieldName[0 .. 1]` because that's a slice (which is just another

Re: Template class with dispatched properties

2013-11-07 Thread Chris Cain
On Friday, 8 November 2013 at 04:38:23 UTC, Ross Hays wrote: Thank you No problem. I'm glad we're making progress on it. And don't feel bad about mistakes while learning. They happen. Embrace them because they happen to all of us at first especially when we're juggling learning new syntaxes

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
Boom, that last few were the issues. I elected to just move the return for the setter onto a separate line, mostly because the idea of auto returning different types seem foreign to me... I have used auto plenty in C++11, but never like that and it just throws me off. But fixing those other

Re: Template class with dispatched properties

2013-11-07 Thread Ross Hays
Okay here is something I was hoping for some general clarification on related to this and maybe you can help me sort some things out. The opDispatch method has a template parameter of string fieldName. In C++, templates are actually compiled so each different use of a template class is

spurious gc allocation

2013-11-07 Thread Ellery Newcomer
hello all. I have a class member function that essentially looks like this: ThisNode* _InsertAllBut(int value) { ThisNode* node = MallocAllocator.allocate!(ThisNode)(1); node.value = value; node_count++; return node; } I compile it on x86_64 and the compiler inserts a gc

What does func!thing mean?

2013-11-07 Thread ProgrammingGhost
I'm a D noob. .map!(a = a.length) seems like the lambda is passed into the template. .map!split just confuses me. What is split? I thought only types can be after !. I would guess split is a standard function but then shouldn't it be map!(split)? const wordCount = file.byLine()

Re: Template class with dispatched properties

2013-11-07 Thread Philippe Sigaud
On Fri, Nov 8, 2013 at 5:55 AM, Ross Hays throwa...@email.net wrote: And let me say that I really do like that this works in D. I can't imagine doing anything like this in C++ (which is what I used primarily in the past). The only reason I joke about it being useless is it really only

Re: spurious gc allocation

2013-11-07 Thread Benjamin Thaut
Am 08.11.2013 06:19, schrieb Ellery Newcomer: hello all. I have a class member function that essentially looks like this: ThisNode* _InsertAllBut(int value) { ThisNode* node = MallocAllocator.allocate!(ThisNode)(1); node.value = value; node_count++; return node; } I

Re: What does func!thing mean?

2013-11-07 Thread qznc
On Friday, 8 November 2013 at 05:46:29 UTC, ProgrammingGhost wrote: I'm a D noob. .map!(a = a.length) seems like the lambda is passed into the template. .map!split just confuses me. What is split? I thought only types can be after !. I would guess split is a standard function but then

Re: What does func!thing mean?

2013-11-07 Thread Philippe Sigaud
When a template argument is only one token long (ie: one number, one type, one string, one name), the parenthesis are optional and can be omitted.

Re: Template class with dispatched properties

2013-11-07 Thread Chris Cain
On Friday, 8 November 2013 at 05:10:57 UTC, Ross Hays wrote: Okay here is something I was hoping for some general clarification on related to this and maybe you can help me sort some things out. The opDispatch method has a template parameter of string fieldName. In C++, templates are

Re: File IO: C# streams VS iterators?

2013-11-07 Thread Jacob Carlborg
On 2013-11-08 01:57, DDD wrote: I was watching a dconf talk about porting C# code to D. One thing that came up was there isn't anything like C# streams for D. Walter said he thinks iterators (unless I remember wrong) is superior. The speaker agreed but said it isn't a drop in replacement so that

Re: File IO: C# streams VS iterators?

2013-11-07 Thread Jacob Carlborg
On 2013-11-08 04:22, Lionello Lunesu wrote: However, sometimes it's useful to have polymorphism for accessing streams, especially when porting C#/java code to D. In that case it would be pretty trivial to port the base classes to D and implement them using the D ranges. For that, there's