Re: Need help with DLANGUI

2015-03-24 Thread Rikki Cattermole via Digitalmars-d-learn
On 25/03/2015 2:31 a.m., Eric wrote: BTW, why do you need FreeImage to create image? Isn't it just possible inside dlangui? This is basically my question. Is there a drawing engine that can draw lines, circles, and shapes as well as single pixels? -Eric If you have some way to draw you

Re: Need help with DLANGUI

2015-03-24 Thread Eric via Digitalmars-d-learn
BTW, why do you need FreeImage to create image? Isn't it just possible inside dlangui? This is basically my question. Is there a drawing engine that can draw lines, circles, and shapes as well as single pixels? -Eric

Re: How to connect asynchronously (non block) with kqueue?

2015-03-24 Thread Etienne via Digitalmars-d-learn
On 3/24/2015 5:50 AM, zhmt wrote: I am using kqueue on macosx, I know how to write a simple server. But don't know which event will be triggered in kqueue when connected successfully , which event when failed? EVFILT_READ or EVFILT_WRITE? I have googled this question, got no examples, any

Re: How to connect asynchronously (non block) with kqueue?

2015-03-24 Thread zhmt via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 12:25:14 UTC, Etienne wrote: On 3/24/2015 5:50 AM, zhmt wrote: I am using kqueue on macosx, I know how to write a simple server. But don't know which event will be triggered in kqueue when connected successfully , which event when failed? EVFILT_READ or

How to connect asynchronously (non block) with kqueue?

2015-03-24 Thread zhmt via Digitalmars-d-learn
I am using kqueue on macosx, I know how to write a simple server. But don't know which event will be triggered in kqueue when connected successfully , which event when failed? EVFILT_READ or EVFILT_WRITE? I have googled this question, got no examples, any suggestions are welcome, Thanks.

Re: D's type classes pattern ?

2015-03-24 Thread anonymous via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 16:56:13 UTC, matovitch wrote: Thanks, just to be clear : void Bar(T : Foo)(T t){ } is the same as void Bar(T)(T t) if (is(T == Foo)){ } and it is checked only at compile time ? (for the runtime I know that what interface were meant for ;)). Ali already

Re: D's type classes pattern ?

2015-03-24 Thread Ali Çehreli via Digitalmars-d-learn
On 03/24/2015 08:50 AM, matovitch wrote: Lets say I want to implement some generic algorithm. I would like to checks the types passed to my algorithm implements a specific interface. I think you are looking for template constraints. Look at isInputRange's implementation:

Re: D's type classes pattern ?

2015-03-24 Thread Ali Çehreli via Digitalmars-d-learn
On 03/24/2015 09:56 AM, matovitch wrote: just to be clear : void Bar(T : Foo)(T t){ } That means if T can implicitly be converted to Foo. is the same as void Bar(T)(T t) if (is(T == Foo)){ } That means if T is exactly Foo. and it is checked only at compile time ? Yes to both. Ali

BigInt and xor

2015-03-24 Thread Dennis Ritchie via Digitalmars-d-learn
Tell me, please, how can I replace this code? import std.conv : to; import std.bigint : BigInt; import std.string : format; import std.stdio : writeln; void main() { BigInt[10] bitArr; ulong n = 18_446_724_073_709_551_614U; bitArr[0] = format(%b, n).to!BigInt;

D's type classes pattern ?

2015-03-24 Thread matovitch via Digitalmars-d-learn
Hi, It's been a long time since I coded some d code... sorry I take the lazy way asking for advices. :D Lets say I want to implement some generic algorithm. I would like to checks the types passed to my algorithm implements a specific interface. interface IStuff(Stuff) { void foo(); }

how call a c function with stdcall?

2015-03-24 Thread mzfhhhh via Digitalmars-d-learn
for example:use vc compile on x86 func.c: __declspec(dllexport) int _stdcall sub(int a,int b) { return a-b; } func.def: LIBRARY EXPORTS sub - i use implib.exe to create a omf format lib. D code: import std.exception; //this is a cdecl call extern(C)

Re: D's type classes pattern ?

2015-03-24 Thread matovitch via Digitalmars-d-learn
More like : import std.stdio; interface IStuff(Stuff) { void foo(); } class TypeClass(T, I) : I(T) { alias this stuff; T stuff; } void myAwesomeAlgo(Stuff) (TypeClass!(Stuff, IStuff) stuff) { stuff.foo(); } struct MyStuff { void foo() { writeln(Hello World

Re: D's type classes pattern ?

2015-03-24 Thread matovitch via Digitalmars-d-learn
Well, just follow that link to the code...it almost compile : http://dpaste.com/3JNP0QD.

Re: how call a c function with stdcall?

2015-03-24 Thread mzfhhhh via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 15:26:22 UTC, Adam D. Ruppe wrote: try extern(Windows) isntead of extern(C). use extern(Windows) or extern(System) the compile show the link error: Error 42: Symbol Undefined _sub@8 dll export func name is sub, and the dll is 3rd party,i can't

Re: how call a c function with stdcall?

2015-03-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 25 March 2015 at 00:09:33 UTC, mzf wrote: i use implib.exe /system func.lib func.dll to create a func.lib. You might also need to specify the .def file as the final argument to that. http://digitalmars.com/ctg/implib.html The def file can list aliases for the functions.

Re: Is there websocket client implementation for D

2015-03-24 Thread Rikki Cattermole via Digitalmars-d-learn
On 25/03/2015 6:55 a.m., Ilya Korobitsyn wrote: Hello! Is there any websocket client implementation in D? I know there is WS server as a part of vibe.d, but it does not seem to include client. Maybe there are some library bindings that I've missed? Thank you, Ilya It appears you are on your

Re: how call a c function with stdcall?

2015-03-24 Thread mzfhhhh via Digitalmars-d-learn
On Wednesday, 25 March 2015 at 00:26:21 UTC, Adam D. Ruppe wrote: On Wednesday, 25 March 2015 at 00:09:33 UTC, mzf wrote: i use implib.exe /system func.lib func.dll to create a func.lib. You might also need to specify the .def file as the final argument to that.

Re: D's type classes pattern ?

2015-03-24 Thread matovitch via Digitalmars-d-learn
Wait no ! In that case my type will have to inherit the interface...I don't want that, checking without inheriting...I know thats weird.

Re: [Dscanner] Textadept integration

2015-03-24 Thread Chris via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 16:54:47 UTC, Chris wrote: I tried to use Dscanner with Textadpet, but it doesn't work. I created the directory modules/dmd and copied the init.lua file from here [1] into it. What am I doing wrong, or is it an old version that is no longer supported? [1]

Re: D's type classes pattern ?

2015-03-24 Thread matovitch via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 16:44:54 UTC, weaselcat wrote: On Tuesday, 24 March 2015 at 15:51:00 UTC, matovitch wrote: Hi, It's been a long time since I coded some d code... sorry I take the lazy way asking for advices. :D Lets say I want to implement some generic algorithm. I would like to

Is there websocket client implementation for D

2015-03-24 Thread Ilya Korobitsyn via Digitalmars-d-learn
Hello! Is there any websocket client implementation in D? I know there is WS server as a part of vibe.d, but it does not seem to include client. Maybe there are some library bindings that I've missed? Thank you, Ilya

Re: BigInt and xor

2015-03-24 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 17:35:14 UTC, matovitch wrote: xor it with -1 instead of 1. (-1 is store as 0xfff..f with the classic modular arithmetic) Thanks.

Re: BigInt and xor

2015-03-24 Thread matovitch via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 15:45:36 UTC, Dennis Ritchie wrote: Tell me, please, how can I replace this code? import std.conv : to; import std.bigint : BigInt; import std.string : format; import std.stdio : writeln; void main() { BigInt[10] bitArr; ulong n =

Re: BigInt and xor

2015-03-24 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 16:35:04 UTC, Ivan Kazmenko wrote: What exactly is not working? Everything works. I'm just a little forgotten properties of the operation xor. I just wanted to xor 1 each digit in the number of type BigInt, while I would like to store each number in the binary

Re: BigInt and xor

2015-03-24 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 15:45:36 UTC, Dennis Ritchie wrote: Tell me, please, how can I replace this code? import std.conv : to; import std.bigint : BigInt; import std.string : format; import std.stdio : writeln; void main() { BigInt[10] bitArr; ulong n =

Re: D's type classes pattern ?

2015-03-24 Thread matovitch via Digitalmars-d-learn
To resume my goal (last lonely message I promise), how can you statically check a type implement an interface without making this type inherit the interface (otherwise std.traits would do it) ? ps : it seems to me that this is exactly what the haskell compiler do with type classes - layman

Re: BigInt and xor

2015-03-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 15:45:36 UTC, Dennis Ritchie wrote: Tell me, please, how can I replace this code? import std.conv : to; import std.bigint : BigInt; import std.string : format; import std.stdio : writeln; void main() { BigInt[10] bitArr; ulong n =

Re: D's type classes pattern ?

2015-03-24 Thread matovitch via Digitalmars-d-learn
well, alias this is the issue here. interface I { void foo(); } struct S { void foo() {} } class C : I { S s; alias this s; } don't compile...if you have any idea to do otherwise I am greatly interested. Thanks !

Re: std.typecons.Flag -- public import for API users?

2015-03-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Saturday, 21 March 2015 at 23:16:39 UTC, rcorre wrote: If I am developing a library and some of my functinos take a std.typecons.Flag as an argument, should I 'public import std.typecons: Flag, Yes, No'? It seems like it would be a pain for users of the library to have to import this

Re: D's type classes pattern ?

2015-03-24 Thread weaselcat via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 15:51:00 UTC, matovitch wrote: Hi, It's been a long time since I coded some d code... sorry I take the lazy way asking for advices. :D Lets say I want to implement some generic algorithm. I would like to checks the types passed to my algorithm implements a

Problem overloading operator for a struct with an immutable member

2015-03-24 Thread Nicolas Sicard via Digitalmars-d-learn
I don't know if this is a bug or expected behaviour. The struct is mutable, assignable and pre-increment operator works. But post-increment doesn't compile because of the immutable member. -- struct S { int i; immutable(Object) o; S opUnary(string op)() { return this; } void

[Dscanner] Textadept integration

2015-03-24 Thread Chris via Digitalmars-d-learn
I tried to use Dscanner with Textadpet, but it doesn't work. I created the directory modules/dmd and copied the init.lua file from here [1] into it. What am I doing wrong, or is it an old version that is no longer supported? [1] https://bitbucket.org/SirAlaran/ta-d/

Re: Need help with DLANGUI

2015-03-24 Thread Vadim Lopatin via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 13:31:06 UTC, Eric wrote: BTW, why do you need FreeImage to create image? Isn't it just possible inside dlangui? This is basically my question. Is there a drawing engine that can draw lines, circles, and shapes as well as single pixels? -Eric Hello, I've

Re: using vibe.d to parse json

2015-03-24 Thread Rikki Cattermole via Digitalmars-d-learn
On 24/03/2015 6:36 p.m., Laeeth Isharc wrote: On Tuesday, 24 March 2015 at 04:53:39 UTC, Laeeth Isharc wrote: Hi. struct RawGoogleResults { string version_; string status; string sig; string[string][][string] table; } enum json =

Re: how call a c function with stdcall?

2015-03-24 Thread Adam D. Ruppe via Digitalmars-d-learn
try extern(Windows) isntead of extern(C).

Re: BigInt and xor

2015-03-24 Thread matovitch via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 17:28:50 UTC, Dennis Ritchie wrote: On Tuesday, 24 March 2015 at 16:35:04 UTC, Ivan Kazmenko wrote: What exactly is not working? Everything works. I'm just a little forgotten properties of the operation xor. I just wanted to xor 1 each digit in the number of

Re: Need help with DLANGUI

2015-03-24 Thread Vadim Lopatin via Digitalmars-d-learn
On Monday, 23 February 2015 at 19:41:30 UTC, Eric wrote: I have been trying out dlanui, and I am able to create an image with FreeImage and display it with an ImageWidget. However this requires that I write the image out to disk, and then load it again to display it. Is there any way I can