Re: D / GtkD for SQL Server

2013-11-06 Thread John J
On 11/06/2013 02:36 AM, Jacob Carlborg wrote: On 2013-11-06 08:28, John J wrote: Thanks Jacob, I guess I have to compile and distribute a FreeTDS.dll, and it only works for win32 FreeTDS works on Posix platforms. I wrote that code on Mac OS X. We use FreeTDS in production, running servers

How to compile and test samples under Windows?

2013-11-06 Thread Adam Ryczkowski
I installed the DMD32 D Compiler v2.063.2 into C:\ I try to complie and test the dserver.d sample specifically, but when I run build.bat in the dmd2\samples\d directory, I've got the following errors. C:\D\dmd2\samples\d..\..\windows\bin\shell all.sh shell 1.05 ..\..\windows\bin\dmd d2html

Re: Small troubles with private

2013-11-06 Thread Gary Willoughby
On Wednesday, 6 November 2013 at 07:46:00 UTC, Jacob Carlborg wrote: Which other languages? private in Ruby and Java is not the same. The one's which implement private as meaning accessible to the class only.

Re: Small troubles with private

2013-11-06 Thread Gary Willoughby
On Wednesday, 6 November 2013 at 07:46:00 UTC, Jacob Carlborg wrote: Which other languages? private in Ruby and Java is not the same. The one's which implement private as meaning accessible to the class only.

Re: How to compile and test samples under Windows?

2013-11-06 Thread evilrat
On Wednesday, 6 November 2013 at 09:02:57 UTC, Adam Ryczkowski wrote: I installed the DMD32 D Compiler v2.063.2 into C:\ I try to complie and test the dserver.d sample specifically, but when I run build.bat in the dmd2\samples\d directory, I've got the following errors.

Re: Module or Dictionary corrupt

2013-11-06 Thread Namespace
On Wednesday, 6 November 2013 at 01:04:10 UTC, Jonathan M Davis wrote: On Wednesday, November 06, 2013 00:22:13 Namespace wrote: OPTLINK (R) for Win32 Release 8.00.13 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html Debug\Foo.obj Offset

UFCS with constructors

2013-11-06 Thread bearophile
import std.typecons: Typedef; alias Foo = Typedef!double; void main() { auto a1 = Foo(1); pragma(msg, typeof(a1)); auto a2 = 1.Foo; pragma(msg, typeof(a2)); auto a3 = Foo(-1); pragma(msg, typeof(a3)); auto a4 = -1.Foo; pragma(msg, typeof(a4)); } It prints:

Re: How to compile and test samples under Windows?

2013-11-06 Thread Adam Ryczkowski
Thank you for the answer. This is the contents of the build.bat, which is shipped with the D instalation: ..\..\windows\bin\shell all.sh Can you tell me, what is outdated?

Re: Module or Dictionary corrupt

2013-11-06 Thread evilrat
On Wednesday, 6 November 2013 at 10:13:07 UTC, Namespace wrote: Should I open a bug for this? you should fix ur sc.ini first to use visual studio linker for x64 and optlink for x86, you can use dmd 2.064.2 installer now to do so automatically.

Re: UFCS with constructors

2013-11-06 Thread qznc
On Wednesday, 6 November 2013 at 11:04:05 UTC, bearophile wrote: import std.typecons: Typedef; alias Foo = Typedef!double; void main() { auto a1 = Foo(1); pragma(msg, typeof(a1)); auto a2 = 1.Foo; pragma(msg, typeof(a2)); auto a3 = Foo(-1); pragma(msg, typeof(a3));

Limiting template functions to template instantiations of a struct

2013-11-06 Thread Atila Neves
The title isn't very clear but I wasn't sure how to phrase it without code. Basically what I want to do is this (won't compile): struct Foo(int N) { } void func(T)(T obj) if(is(T:Foo)) { } void func(T)(T obj) if(!is(T:Foo)) { } Foo by itself isn't a type, but I don't want to limit func

Re: Small troubles with private

2013-11-06 Thread Regan Heath
On Tue, 05 Nov 2013 16:00:41 -, bearophile bearophileh...@lycos.com wrote: 1) I usually write more than one class or struct inside each D module, unlike in Java. But sometimes when I move that class or struct elsewhere (during refactoring, or in other situations) I get access errors to

Re: Limiting template functions to template instantiations of a struct

2013-11-06 Thread simendsjo
On Wednesday, 6 November 2013 at 13:00:17 UTC, Atila Neves wrote: The title isn't very clear but I wasn't sure how to phrase it without code. Basically what I want to do is this (won't compile): struct Foo(int N) { } void func(T)(T obj) if(is(T:Foo)) { } void func(T)(T obj) if(!is(T:Foo)) {

Re: fieldPostBlit - what is wrong with this and workarounds

2013-11-06 Thread Daniel Davidson
On Friday, 1 November 2013 at 20:29:54 UTC, Jonathan M Davis wrote: On Friday, November 01, 2013 14:28:55 Daniel Davidson wrote: On Thursday, 31 October 2013 at 19:39:44 UTC, Jonathan M Davis Deep copying is not the only reason to have a postblit. Smart pointers such as

Re: Small troubles with private

2013-11-06 Thread Timon Gehr
On 11/05/2013 05:00 PM, bearophile wrote: 1) I usually write more than one class or struct inside each D module, unlike in Java. But sometimes when I move that class or struct elsewhere (during refactoring, or in other situations) I get access errors to private fields. Those errors were already

Re: How to compile and test samples under Windows?

2013-11-06 Thread evilrat
On Wednesday, 6 November 2013 at 10:38:29 UTC, Adam Ryczkowski wrote: Thank you for the answer. This is the contents of the build.bat, which is shipped with the D instalation: ..\..\windows\bin\shell all.sh Can you tell me, what is outdated? pi sample at least has compile errors.

Re: How to compile and test samples under Windows?

2013-11-06 Thread Adam Ryczkowski
...All the samples I use are shipped with the DMD32 D Compiler v2.063.2 instalation package for Windows. I've just reinstalled D to make sure that.

Re: How to compile and test samples under Windows?

2013-11-06 Thread evilrat
On Wednesday, 6 November 2013 at 10:46:39 UTC, Adam Ryczkowski wrote: ...All the samples I use are shipped with the DMD32 D Compiler v2.063.2 instalation package for Windows. I've just reinstalled D to make sure that. no, i mean its not get updated to fetch with phobos changes. though it

Re: Operator Precedence and Associativity

2013-11-06 Thread Timon Gehr
On 11/06/2013 04:34 AM, 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 am also not sure if these ..., @, # belong there at all. There might be other errors or

Re: Limiting template functions to template instantiations of a struct

2013-11-06 Thread Namespace
On Wednesday, 6 November 2013 at 13:00:17 UTC, Atila Neves wrote: The title isn't very clear but I wasn't sure how to phrase it without code. Basically what I want to do is this (won't compile): struct Foo(int N) { } void func(T)(T obj) if(is(T:Foo)) { } void func(T)(T obj) if(!is(T:Foo)) {

Re: UFCS with constructors

2013-11-06 Thread bearophile
qznc: Operator precedence of . is higher than unary minus. Is this good? However, what is Typedef for? It's to create a differently named type, useful for stronger static typing, to increase code clarity and avoid some bugs. If you have a function like this: double foo(in double x,

How to re-initialise an associative array.

2013-11-06 Thread Gary Willoughby
A simple request but i'm failing hard. How do i re-init an associative array? This is obviously not the way: import std.stdio; void main(string[] args) { int[string] x; x[hello] = 1; x[world] = 2;

Re: How to re-initialise an associative array.

2013-11-06 Thread JR
On Wednesday, 6 November 2013 at 16:15:36 UTC, Gary Willoughby wrote: A simple request but i'm failing hard. How do i re-init an associative array? This is obviously not the way: import std.stdio; void main(string[] args) { int[string] x;

Re: How to re-initialise an associative array.

2013-11-06 Thread Daniel Davidson
On Wednesday, 6 November 2013 at 16:15:36 UTC, Gary Willoughby wrote: A simple request but i'm failing hard. How do i re-init an associative array? This is obviously not the way: import std.stdio; void main(string[] args) { int[string] x;

Re: How to re-initialise an associative array.

2013-11-06 Thread Daniel Davidson
On Wednesday, 6 November 2013 at 16:41:19 UTC, Gary Willoughby wrote: x.clear(); I looked at that but apparently it leaves the array in an unsafe state. Source: http://forum.dlang.org/thread/iu3ll6$2d48$1...@digitalmars.com Wow! Good to know, thanks!

Re: How to re-initialise an associative array.

2013-11-06 Thread Gary Willoughby
On Wednesday, 6 November 2013 at 16:34:13 UTC, Daniel Davidson wrote: On Wednesday, 6 November 2013 at 16:15:36 UTC, Gary Willoughby wrote: A simple request but i'm failing hard. How do i re-init an associative array? This is obviously not the way: import std.stdio; void

Re: How to re-initialise an associative array.

2013-11-06 Thread Daniel Davidson
On Wednesday, 6 November 2013 at 16:41:19 UTC, Gary Willoughby wrote: I looked at that but apparently it leaves the array in an unsafe state. Source: http://forum.dlang.org/thread/iu3ll6$2d48$1...@digitalmars.com Is that still the case? The following seems to work just fine. Maybe Kenji

Re: How to re-initialise an associative array.

2013-11-06 Thread Gary Willoughby
On Wednesday, 6 November 2013 at 16:49:44 UTC, Daniel Davidson wrote: On Wednesday, 6 November 2013 at 16:41:19 UTC, Gary Willoughby wrote: I looked at that but apparently it leaves the array in an unsafe state. Source: http://forum.dlang.org/thread/iu3ll6$2d48$1...@digitalmars.com Is

Re: UFCS with constructors

2013-11-06 Thread Ali Çehreli
On 11/06/2013 03:04 AM, bearophile wrote: import std.typecons: Typedef; alias Foo = Typedef!double; void main() { auto a1 = Foo(1); pragma(msg, typeof(a1)); auto a2 = 1.Foo; pragma(msg, typeof(a2)); auto a3 = Foo(-1); pragma(msg, typeof(a3)); auto a4 = -1.Foo;

Re: How to re-initialise an associative array.

2013-11-06 Thread H. S. Teoh
On Wed, Nov 06, 2013 at 05:15:34PM +0100, Gary Willoughby wrote: A simple request but i'm failing hard. How do i re-init an associative array? [...] Just assign null to it: import std.stdio; void main() { int[string] aa; aa[a] = 1;

Re: UFCS with constructors

2013-11-06 Thread Maxim Fomin
On Wednesday, 6 November 2013 at 17:10:34 UTC, Ali Çehreli wrote: I would be very surprised if unary - produced a different type from the operand: Ali Operator does not produce type, it produces value of expression, and type of expression happens not to be the type you expected. But such

Re: How to re-initialise an associative array.

2013-11-06 Thread Maxim Fomin
On Wednesday, 6 November 2013 at 17:49:41 UTC, H. S. Teoh wrote: The GC will take care of cleaning up the old data. T Unfortunately it will not take care of calling struct destructors.

Re: UFCS with constructors

2013-11-06 Thread Ali Çehreli
On 11/06/2013 09:46 AM, Maxim Fomin wrote: On Wednesday, 6 November 2013 at 17:10:34 UTC, Ali Çehreli wrote: I would be very surprised if unary - produced a different type from the operand: Ali Operator does not produce type, it produces value of expression, and type of expression

Re: Associative Array: reasonable limits?

2013-11-06 Thread Dmitry Olshansky
06-Nov-2013 00:36, Charles Hixson пишет: On 11/05/2013 05:34 AM, Dmitry Olshansky wrote: 05-Nov-2013 02:20, Charles Hixson пишет: On 11/03/2013 01:46 AM, Dmitry Olshansky wrote: 03-Nov-2013 02:37, Charles Hixson пишет: I'm contemplating an associative array that will eventually grow to be an

Re: UFCS with constructors

2013-11-06 Thread Maxim Fomin
On Wednesday, 6 November 2013 at 18:02:32 UTC, Ali Çehreli wrote: But such expectations need not correspond to language rules (try to think from from language laywer perspective). I still argue that the expression -expr must have the same type as expr. In bearophile case, I guess

Re: UFCS with constructors

2013-11-06 Thread Dicebot
On Wednesday, 6 November 2013 at 18:16:04 UTC, Maxim Fomin wrote: I think that reason for such behavior is the way used defined operator overloading functions are implemented, not the language per se, so programmers confuse themselves. What about other possible reason - Typedef implementation

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

2013-11-06 Thread Gary Willoughby
As part of developing the DUnit framework i'm looking into executing the unit test at a more fine grain level. The new 'getUnitTests' trait looks interesting but it's value is a symbol of an aggregate (e.g. struct/class/module). foreach (module_; ModuleInfo) {

who to use -allinst

2013-11-06 Thread Benjamin Thaut
Could someone please explain the new -allinst compiler flag? Is it supposed to be used on static libraries or on the executable using templates from those static libraries? Kind Regards Benjamin Thaut

Re: who to use -allinst

2013-11-06 Thread Dicebot
On Wednesday, 6 November 2013 at 19:33:10 UTC, Benjamin Thaut wrote: Could someone please explain the new -allinst compiler flag? Is it supposed to be used on static libraries or on the executable using templates from those static libraries? Kind Regards Benjamin Thaut It is a hack that

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

2013-11-06 Thread Dicebot
module aaa; import std.string; template Alias(alias S) { alias Alias = S; } void main() { import std.string; foreach (symbol_name; __traits(allMembers, aaa)) { alias symbol = Alias!(__traits(getMember, aaa, symbol_name));

Re: who to use -allinst

2013-11-06 Thread Benjamin Thaut
Am 06.11.2013 20:48, schrieb Dicebot: On Wednesday, 6 November 2013 at 19:33:10 UTC, Benjamin Thaut wrote: Could someone please explain the new -allinst compiler flag? Is it supposed to be used on static libraries or on the executable using templates from those static libraries? Kind Regards

Re: who to use -allinst

2013-11-06 Thread Dicebot
On Wednesday, 6 November 2013 at 20:02:42 UTC, Benjamin Thaut wrote: Well I encounter strange linker errors since 2.064. The question is if it is supposed to be used when compiling the executable or when compiling the static library. You are trying to think about it about a normal feature

Re: who to use -allinst

2013-11-06 Thread Benjamin Thaut
Am 06.11.2013 21:14, schrieb Dicebot: On Wednesday, 6 November 2013 at 20:02:42 UTC, Benjamin Thaut wrote: Well I encounter strange linker errors since 2.064. The question is if it is supposed to be used when compiling the executable or when compiling the static library. You are trying to

Re: who to use -allinst

2013-11-06 Thread Dicebot
Sorry about that, I have already spent all my rage on this decision but with no result. Releasing incomplete features as in good old times.

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

2013-11-06 Thread Dicebot
On Wednesday, 6 November 2013 at 21:07:47 UTC, Gary Willoughby wrote: Unfortunately this still suffers the same problem in that you need a module symbol name to do anything. I need to get all module symbols at compile time. You need only symbol name of your root compiled module which imports

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

2013-11-06 Thread Daniel Davidson
On Wednesday, 6 November 2013 at 21:26:09 UTC, Dicebot wrote: On Wednesday, 6 November 2013 at 21:07:47 UTC, Gary Willoughby wrote: Unfortunately this still suffers the same problem in that you need a module symbol name to do anything. I need to get all module symbols at compile time. You

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

2013-11-06 Thread Dicebot
On Wednesday, 6 November 2013 at 21:36:52 UTC, Daniel Davidson wrote: I don't think it works that way, as how could a compile time test module know about modules that have pulled it in? Exactly. __traits work during compile-time. If module is not imported, it is not known during compile-time

Re: Limiting template functions to template instantiations of a struct

2013-11-06 Thread Atila Neves
Wow. It didn't even occur to me that `is` could be used like that. I think that operator is the hardest part of the language for me to grok. Thanks guys!

Re: Limiting template functions to template instantiations of a struct

2013-11-06 Thread Dicebot
On Wednesday, 6 November 2013 at 21:49:52 UTC, Atila Neves wrote: Wow. It didn't even occur to me that `is` could be used like that. I think that operator is the hardest part of the language for me to grok. Thanks guys! http://dlang.org/expression.html#IsExpression ;)

Re: UFCS with constructors

2013-11-06 Thread bearophile
Dicebot: Typedef implementation sucks? ;) So do you suggest to open some enhancement request/bug report on Typedef? Bye, bearophile

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

2013-11-06 Thread Gary Willoughby
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 tests are kinda rolled into one function as

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

2013-11-06 Thread Dicebot
On Wednesday, 6 November 2013 at 22:33:48 UTC, Gary Willoughby wrote: 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 tests are kinda rolled into one function as show by the 'func' variable

Re: Limiting template functions to template instantiations of a struct

2013-11-06 Thread Atila Neves
On Wednesday, 6 November 2013 at 21:52:04 UTC, Dicebot wrote: On Wednesday, 6 November 2013 at 21:49:52 UTC, Atila Neves wrote: Wow. It didn't even occur to me that `is` could be used like that. I think that operator is the hardest part of the language for me to grok. Thanks guys!

Re: Limiting template functions to template instantiations of a struct

2013-11-06 Thread Dicebot
On Wednesday, 6 November 2013 at 22:41:08 UTC, Atila Neves wrote: I know, but I keep having to refer back to that and even then I didn't know about the syntax these guys just posted! ;) Well, it is mentioned in the list of `is` usage cases down that link. It is very ugly part of the language

Re: Limiting template functions to template instantiations of a struct

2013-11-06 Thread Namespace
On Wednesday, 6 November 2013 at 22:43:18 UTC, Dicebot wrote: On Wednesday, 6 November 2013 at 22:41:08 UTC, Atila Neves wrote: I know, but I keep having to refer back to that and even then I didn't know about the syntax these guys just posted! ;) Well, it is mentioned in the list of `is`

Re: Limiting template functions to template instantiations of a struct

2013-11-06 Thread H. S. Teoh
On Wed, Nov 06, 2013 at 11:52:56PM +0100, Namespace wrote: On Wednesday, 6 November 2013 at 22:43:18 UTC, Dicebot wrote: On Wednesday, 6 November 2013 at 22:41:08 UTC, Atila Neves wrote: I know, but I keep having to refer back to that and even then I didn't know about the syntax these guys

Re: UFCS with constructors

2013-11-06 Thread Dicebot
On Wednesday, 6 November 2013 at 21:57:47 UTC, bearophile wrote: Dicebot: Typedef implementation sucks? ;) So do you suggest to open some enhancement request/bug report on Typedef? Bye, bearophile Sure. get enough such reports and we may even get it back as language feature :) (I think

struct Unique(T)

2013-11-06 Thread ChrisG
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 bindings for the SDL library. The SDL library uses handles in

Re: Small troubles with private

2013-11-06 Thread Meta
On Tuesday, 5 November 2013 at 21:01:40 UTC, John J wrote: On 11/05/2013 11:00 AM, 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

Re: struct Unique(T)

2013-11-06 Thread Chris Cain
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 that say: doesn't work yet. It seems like some of it could be

Re: Small troubles with private

2013-11-06 Thread Chris Cain
On Wednesday, 6 November 2013 at 12:19:26 UTC, Timon Gehr wrote: How about just adding full granularity? By condition: @visibleIf!true // public @visibleIf!(isSubtypeOf!(typeof(this))) // protected By explicit enumeration: @visible!(getModule!(typeof(this))) //

Reflecting on a module

2013-11-06 Thread Shammah Chancellor
How does one reflect on all the classes in a module? I would like to read their attributes and generate an enum from attributes on said classes.

Re: Reflecting on a module

2013-11-06 Thread Adam D. Ruppe
On Thursday, 7 November 2013 at 01:37:24 UTC, Shammah Chancellor wrote: How does one reflect on all the classes in a module? __traits(allMembers, your_module) There's two easy ways to get your_module: __traits(parent, some_top_level_symbol0 or mixin(module.name.here); allMembers gives a

BinaryHeap

2013-11-06 Thread 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: Module or Dictionary corrupt

2013-11-06 Thread evilrat
On Wednesday, 6 November 2013 at 10:32:01 UTC, Namespace wrote: On Wednesday, 6 November 2013 at 10:21:38 UTC, evilrat wrote: On Wednesday, 6 November 2013 at 10:13:07 UTC, Namespace wrote: Should I open a bug for this? you should fix ur sc.ini first to use visual studio linker for x64 and