Re: Passing shared delegates

2013-01-13 Thread Martin Drašar
Dne 11.1.2013 23:26, mist napsal(a): Do not have time to test code right now but first guess it is related to parsing differences for delegates and usual functions. Delegates can have shared/const applied to both delegate type itself and context of underlying function. Those are different beasts

Re: Mixin Template: cannot mixin scope(exit)?

2013-01-13 Thread 1100110
On 01/13/2013 11:35 PM, 1100110 wrote: Ok, I wish to create a standard timing system so that I can measure ~how long each function takes to execute. I wish to be able to place at the start of a function version(Time) mixin TimeExecution("funcName"); mixin template TimeExecution(T) if(isSomeStri

Mixin Template: cannot mixin scope(exit)?

2013-01-13 Thread 1100110
Ok, I wish to create a standard timing system so that I can measure ~how long each function takes to execute. I wish to be able to place at the start of a function version(Time) mixin TimeExecution("funcName"); mixin template TimeExecution(T) if(isSomeString!T) { import std.stdio, std.date

Re: Is there a weak pointer or references in D?

2013-01-13 Thread Alex Rønne Petersen
On 14-01-2013 00:18, Charles Hixson wrote: On 01/12/2013 09:24 PM, Alex Rønne Petersen wrote: On 11-01-2013 19:15, Charles Hixson wrote: I was looking for a way to create a weak reference to either a struct or a class. I need to be able to use it to automatically generate an active reference on

Re: Processes

2013-01-13 Thread 1100110
On 01/13/2013 08:01 AM, Tomas wrote: Hey, guys. I need to get all running processes list, and kill one. (example: Find all processes and if skype.exe is running, kill it.) --- import std.stdio; import std.process; //assuming we want to kill "htop" void main() { killProcess("htop"); } voi

Re: MS ODBC encoding issue

2013-01-13 Thread Sam Hu
On Monday, 31 December 2012 at 11:01:17 UTC, Regan Heath wrote: On Mon, 24 Dec 2012 07:18:51 -, Sam Hu wrote: On Friday, 21 December 2012 at 15:20:39 UTC, Regan Heath wrote: On Wed, 19 Dec 2012 06:33:16 -, Sam Hu wrote: On Monday, 10 December 2012 at 14:43:08 UTC, Regan Heath wro

Re: BitArray new design

2013-01-13 Thread Era Scarecrow
Well some minor update. From the looks of how it is going to be set up, it is almost entirely a template. Consider you have BitArray!(Fixed!(1024)), vs BitArray!(Dynamic), in order for one to copy to the other template functions are needed. Override one of them, and now i have to define it to

Re: Is there a weak pointer or references in D?

2013-01-13 Thread Charles Hixson
On 01/12/2013 09:24 PM, Alex Rønne Petersen wrote: On 11-01-2013 19:15, Charles Hixson wrote: I was looking for a way to create a weak reference to either a struct or a class. I need to be able to use it to automatically generate an active reference on access. (I intend to do this by rolling in

Re: does alias this work correctly?

2013-01-13 Thread Andrey
I just want very much avoid renaming function,it's principle for me. So I would like to know is my sample right or no. I think that the main overall principle here is that is it impossible to have two functions which differ only by static attribute. I even do not imagine the use case of this.

Re: static vs non-static

2013-01-13 Thread Jonathan M Davis
On Sunday, January 13, 2013 17:39:21 bearophile wrote: > Maxim Fomin: > > dmd allows to call static functions on instance. > > I think that's a D design mistake (and I think Jonathan Davis > agrees with me), but Walter prefers the current behavour. C++ and Java (and probably C# too) have this pro

Re: does alias this work correctly?

2013-01-13 Thread Jonathan M Davis
On Sunday, January 13, 2013 20:41:48 Zhenya wrote: > On Sunday, 13 January 2013 at 19:35:08 UTC, Maxim Fomin wrote: > > According to spec http://dlang.org/class.html#AliasThis > > undefined lookups are forwarded to AliasThis member. But in > > your case Foo struct has bar member, so no further reso

Re: static vs non-static

2013-01-13 Thread Jacob Carlborg
On 2013-01-13 16:58, Zhenya wrote: Hi! Sorry,if it already was discussed,but import std.stdio; struct Foo { static void bar() { writeln("static"); } void bar() { writeln("non-static"); } } int main() { Foo gun; gun.bar();//fails here } Is it all right,that compiler dosn't prefer non-static fu

Re: does alias this work correctly?

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 19:35:08 UTC, Maxim Fomin wrote: On Sunday, 13 January 2013 at 19:16:36 UTC, Zhenya wrote: Hi! Is it all right with it: struct Foo { struct Bar { void opCall() { writeln("non-static");

Re: does alias this work correctly?

2013-01-13 Thread Maxim Fomin
On Sunday, 13 January 2013 at 19:16:36 UTC, Zhenya wrote: Hi! Is it all right with it: struct Foo { struct Bar { void opCall() { writeln("non-static"); } } Bar bar; static struct Anothe

does alias this work correctly?

2013-01-13 Thread Zhenya
Hi! Is it all right with it: struct Foo { struct Bar { void opCall() { writeln("non-static"); } } Bar bar; static struct Anotherbar { static void bar()

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 18:16:40 UTC, Zhenya wrote: On Sunday, 13 January 2013 at 17:59:28 UTC, Andrey wrote: Don't know if this will be useful in any manner, but it came this silly way: class MyClass { struct _static { static void myfun() {

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 17:59:28 UTC, Andrey wrote: Don't know if this will be useful in any manner, but it came this silly way: class MyClass { struct _static { static void myfun() { writeln("static myfun"); } }

Re: static vs non-static

2013-01-13 Thread Andrey
Don't know if this will be useful in any manner, but it came this silly way: class MyClass { struct _static { static void myfun() { writeln("static myfun"); } } void myfun() { writeln("myfun");

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 17:17:54 UTC, Maxim Fomin wrote: On Sunday, 13 January 2013 at 16:23:27 UTC, Zhenya wrote: On Sunday, 13 January 2013 at 16:18:36 UTC, Maxim Fomin wrote: Yes, it is a problem - dmd allows to call static functions on instance. When both match, it issues ambiguity er

Re: static vs non-static

2013-01-13 Thread Maxim Fomin
On Sunday, 13 January 2013 at 16:23:27 UTC, Zhenya wrote: On Sunday, 13 January 2013 at 16:18:36 UTC, Maxim Fomin wrote: Yes, it is a problem - dmd allows to call static functions on instance. When both match, it issues ambiguity error. Hmmm...So it will remain as it is? It hurts me a little bi

Re: static vs non-static

2013-01-13 Thread Andrey
Definitely this is a bad design. Even in PHP you can't call static functions from class instance. :-) Having two functions with the same name and argument list within one class is a bad idea too.

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 17:04:21 UTC, Maxim Fomin wrote: On Sunday, 13 January 2013 at 16:39:22 UTC, bearophile wrote: Maxim Fomin: dmd allows to call static functions on instance. I think that's a D design mistake (and I think Jonathan Davis agrees with me), but Walter prefers the cu

Re: static vs non-static

2013-01-13 Thread Maxim Fomin
On Sunday, 13 January 2013 at 16:39:22 UTC, bearophile wrote: Maxim Fomin: dmd allows to call static functions on instance. I think that's a D design mistake (and I think Jonathan Davis agrees with me), but Walter prefers the current behavour. Bye, bearophile Then I agree with both of yo

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 16:39:22 UTC, bearophile wrote: Maxim Fomin: dmd allows to call static functions on instance. I think that's a D design mistake (and I think Jonathan Davis agrees with me), but Walter prefers the current behavour. Bye, bearophile Maybe you could suggest some

Re: static vs non-static

2013-01-13 Thread bearophile
Maxim Fomin: dmd allows to call static functions on instance. I think that's a D design mistake (and I think Jonathan Davis agrees with me), but Walter prefers the current behavour. Bye, bearophile

Re: static vs non-static

2013-01-13 Thread Zhenya
On Sunday, 13 January 2013 at 16:18:36 UTC, Maxim Fomin wrote: On Sunday, 13 January 2013 at 15:58:56 UTC, Zhenya wrote: Hi! Sorry,if it already was discussed,but import std.stdio; struct Foo { static void bar() { writeln("static"); } void bar()

Re: static vs non-static

2013-01-13 Thread Maxim Fomin
On Sunday, 13 January 2013 at 15:58:56 UTC, Zhenya wrote: Hi! Sorry,if it already was discussed,but import std.stdio; struct Foo { static void bar() { writeln("static"); } void bar() { writeln("non-static"); } } in

static vs non-static

2013-01-13 Thread Zhenya
Hi! Sorry,if it already was discussed,but import std.stdio; struct Foo { static void bar() { writeln("static"); } void bar() { writeln("non-static"); } } int main() { Foo gun; gun.bar();//fails here } Is it

Processes

2013-01-13 Thread Tomas
Hey, guys. I need to get all running processes list, and kill one. (example: Find all processes and if skype.exe is running, kill it.)

Re: Is there a weak pointer or references in D?

2013-01-13 Thread thedeemon
On Saturday, 12 January 2013 at 11:27:03 UTC, Era Scarecrow wrote: On Saturday, 12 January 2013 at 10:58:23 UTC, thedeemon wrote: So the runtime is aware of weak pointers and clears them to "empty" state when pointed value dies. I don't see yet how it can be implemented in D without patching it

Re: Lazy template arguments?

2013-01-13 Thread bearophile
monarch_dodra: Is this proposal a pure optimization trick, or is there some functionality gains here. The only one I can think of, is if "Foo!B" would fail to compile. Is this what you are going for...? It's first of all a way to implement a Ternary in library code, because in some situatio

Re: Lazy template arguments?

2013-01-13 Thread comco
On Sunday, 13 January 2013 at 11:26:57 UTC, monarch_dodra wrote: Bearophile: Is this proposal a pure optimization trick, or is there some functionality gains here. The only one I can think of, is if "Foo!B" would fail to compile. Is this what you are going for...? Also: // template Ternar

Re: Lazy template arguments?

2013-01-13 Thread bearophile
comco: Isn't the whole ct metaprogramming with types kind of functional and immutable? The answer is probably positive, but functional and lazy aren't exactly the same thing, from a computational point of view. I thought that the template instantiation is already implemented as being lazy

Re: Lazy template arguments?

2013-01-13 Thread monarch_dodra
On Sunday, 13 January 2013 at 11:15:03 UTC, comco wrote: On Saturday, 5 January 2013 at 10:37:31 UTC, bearophile wrote: In some case I'd like a hypothetical static ternary operator usable on types: alias T = (U.sizeof <= 16) ?? ushort : size_t; That is equivalent to: static if (U.sizeof <= 1

Re: Lazy template arguments?

2013-01-13 Thread comco
On Saturday, 5 January 2013 at 10:37:31 UTC, bearophile wrote: In some case I'd like a hypothetical static ternary operator usable on types: alias T = (U.sizeof <= 16) ?? ushort : size_t; That is equivalent to: static if (U.sizeof <= 16) { alias T = ushort; } else { alias T = size_t;

Re: structs are now lvalues - what is with "auto ref"?

2013-01-13 Thread Namespace
It turns out there already was a pull request that does this: https://github.com/D-Programming-Language/dmd/pull/1019 The pull request is still unmerged. Isn't this important enough or is the pull invalid?