Conversion to output ranges

2012-02-07 Thread Mafi
Hi, does anybody know how to bring std.conv.to or something similar to output into an output range? int a = 42; char[25] buffer; to!typeof(buffer[])(a, buffer[]); I want to send these texts throw sockets. Therefore I'd like to reuse the buffer. Mafi

Re: Extra packet sent when using socket/socketstream

2012-02-07 Thread Vladimir Panteleev
On Monday, 6 February 2012 at 21:51:54 UTC, Vidar Wahlberg wrote: How can I make it not send a packet warning the recipient that it's about to receive another packet (of a given size)? Don't use std.socketstream. Streams serialize some types in an internal format (in your case, prepending the

DLL Injection

2012-02-07 Thread valente500
I've been trying for a while now to inject a DLL written in D into another process, and I just haven't been able to get it working. Here's the code for the DLL: import std.c.windows.windows; import core.sys.windows.dll; __gshared HINSTANCE g_hInst; extern (Windows) BOOL DllMain(HINSTANCE

Re: Using the Variant (Setting it's memory location)

2012-02-07 Thread Jesse Phillips
On Tuesday, 7 February 2012 at 00:39:00 UTC, Era Scarecrow wrote: Unfortunately I'd need to reference a buffer for the known structured types. Variant seems far more useful for making an interpreted language, than for my purposes. I've been using Variant with LuaD for some time. Sorry it

Re: Conversion to output ranges

2012-02-07 Thread Timon Gehr
On 02/07/2012 02:35 PM, Mafi wrote: Hi, does anybody know how to bring std.conv.to or something similar to output into an output range? int a = 42; char[25] buffer; to!typeof(buffer[])(a, buffer[]); I want to send these texts throw sockets. Therefore I'd like to reuse the buffer. Mafi You

Re: Conversion to output ranges

2012-02-07 Thread Timon Gehr
On 02/07/2012 04:49 PM, Timon Gehr wrote: On 02/07/2012 02:35 PM, Mafi wrote: Hi, does anybody know how to bring std.conv.to or something similar to output into an output range? int a = 42; char[25] buffer; to!typeof(buffer[])(a, buffer[]); I want to send these texts throw sockets. Therefore

Re: Conversion to output ranges

2012-02-07 Thread Timon Gehr
On 02/07/2012 04:50 PM, Timon Gehr wrote: On 02/07/2012 04:49 PM, Timon Gehr wrote: On 02/07/2012 02:35 PM, Mafi wrote: Hi, does anybody know how to bring std.conv.to or something similar to output into an output range? int a = 42; char[25] buffer; to!typeof(buffer[])(a, buffer[]); I want to

Re: Extra packet sent when using socket/socketstream

2012-02-07 Thread Vidar Wahlberg
On 2012-02-07 14:44, Vladimir Panteleev wrote: On Monday, 6 February 2012 at 21:51:54 UTC, Vidar Wahlberg wrote: How can I make it not send a packet warning the recipient that it's about to receive another packet (of a given size)? Don't use std.socketstream. Streams serialize some types in

Re: Conversion to output ranges

2012-02-07 Thread Pedro Lacerda
Maybe std.outbuffer... auto buffer = new OutBuffer(); int a = 42; buffer.write(a); byte[] bytes = cast(byte[]) buffer.toBytes(); ubyte[] ubytes = buffer.toBytes(); Pedro Lacerda 2012/2/7 Mafi m...@example.org Hi, does anybody know how to bring std.conv.to or

Re: Using the Variant (Setting it's memory location)

2012-02-07 Thread Pedro Lacerda
You can roll your own tagged union instead. The S struct can store long and byte[], S.ptr is a pointer to the data. enum Type { Long, Bytes } struct S { Type type; void* ptr; union { long _long; byte[] _bytes; } this(long l)

For: [your code hear]

2012-02-07 Thread Manfred Nowak
Goal: show some skill of D for implementing mathematics. A definition: Let T1, T2, T3 be sets. A problem P of type ( T1, T2, T3) is interpretable as a function from the domain cartesian product of T1 and powerset of T2 to the codomain T3. Objective: Present code, that is usefull for all

Re: For: [your code hear]

2012-02-07 Thread Timon Gehr
On 02/07/2012 08:16 PM, Manfred Nowak wrote: Goal: show some skill of D for implementing mathematics. A definition: Let T1, T2, T3 be sets. A problem P of type ( T1, T2, T3) is interpretable as a function from the domain cartesian product of T1 and powerset of T2 to the codomain T3.

post/pre-increment/decrement and property

2012-02-07 Thread Vidar Wahlberg
Take the following code: int _foo; @property auto foo() { return _foo; } @property auto foo(int foo) { return _foo = foo; } void main() { ++foo; } This won't compile, and it sort of makes sense (at least to me), but is it (or will it in the future be) possible to

Re: post/pre-increment/decrement and property

2012-02-07 Thread Robert Clipsham
On 07/02/2012 22:37, Vidar Wahlberg wrote: Take the following code: int _foo; @property auto foo() { return _foo; } @property auto foo(int foo) { return _foo = foo; } void main() { ++foo; } This won't compile, and it sort of makes sense (at least to me), but is it (or will it in the future be)

Re: post/pre-increment/decrement and property

2012-02-07 Thread Timon Gehr
On 02/07/2012 11:54 PM, Robert Clipsham wrote: On 07/02/2012 22:37, Vidar Wahlberg wrote: Take the following code: int _foo; @property auto foo() { return _foo; } @property auto foo(int foo) { return _foo = foo; } void main() { ++foo; } This won't compile, and it sort of makes sense (at least

How to reverse char[]?

2012-02-07 Thread H. S. Teoh
Hi all, I'm trying to reverse a character array. Why doesn't the following work? import std.algorithm; void main() { char[] array = ['a', 'b', 'c']; reverse(array); } I get: Error: template std.algorithm.reverse(Range) if

Re: How to reverse char[]?

2012-02-07 Thread Timon Gehr
On 02/08/2012 02:29 AM, H. S. Teoh wrote: Hi all, I'm trying to reverse a character array. Why doesn't the following work? import std.algorithm; void main() { char[] array = ['a', 'b', 'c']; reverse(array); } I get: Error: template

Could use some help with porting problems

2012-02-07 Thread Roderick Gibson
So I needed a coherent noise generator and decided to look at libnoise. Noticing it was rather small I decided I would just port it over to d and be done with it, as I expected it would help me understand d a bit better (it has). My problems all seem to stem from the const qualifier, which is

Re: How to reverse char[]?

2012-02-07 Thread James Miller
On 02/08/2012 02:29 AM, H. S. Teoh wrote: Hi all, I'm trying to reverse a character array. Why doesn't the following work?        import std.algorithm;        void main() {                char[] array = ['a', 'b', 'c'];                reverse(array);        } I get: Error: template

Re: How to reverse char[]?

2012-02-07 Thread Jonathan M Davis
On Wednesday, February 08, 2012 02:36:23 Timon Gehr wrote: char[] is handled by Phobos as a range of dchar, ergo it does not have swappable elements. Apparently there is no template specialisation of 'reverse' that handles narrow strings, you might want to file an enhancement request. There

Re: Could use some help with porting problems

2012-02-07 Thread Roderick Gibson
On 2/7/2012 7:58 PM, Daniel Murphy wrote: It seems the problem you've run into is that a class reference cannot be tail-const. Pointers can be tail-const like this: const(Data)* but there is no way currently (there are proposals) to make only the data and not the reference const. A workaround

Re: A GUI library to begin with

2012-02-07 Thread Gour
On Wed, 08 Feb 2012 05:55:37 +0200 Mr. Anonymous mailnew4s...@gmail.com wrote: Has anyone tried these? Any suggestions? wxD (http://wxd.sourceforge.net/) Sincerely, Gour -- Those persons who execute their duties according to My injunctions and who follow this teaching faithfully, without

Re: A GUI library to begin with

2012-02-07 Thread Mr. Anonymous
On 08.02.2012 7:04, Gour wrote: On Wed, 08 Feb 2012 05:55:37 +0200 Mr. Anonymousmailnew4s...@gmail.com wrote: Has anyone tried these? Any suggestions? wxD (http://wxd.sourceforge.net/) Sincerely, Gour The website says: wxD is intended for D language version 1.0, and doesn't work as good

Re: post/pre-increment/decrement and property

2012-02-07 Thread Jacob Carlborg
On 2012-02-08 01:50, Robert Clipsham wrote: On 07/02/2012 23:04, Timon Gehr wrote: Try this: int _foo; @property ref foo() { return _foo; } @property ref foo(int foo) { return _foo = foo; } void main() { ++foo; } Using 'ref' instead of auto returns a reference to _foo, allowing it to

Re: A GUI library to begin with

2012-02-07 Thread Jacob Carlborg
On 2012-02-08 04:55, Mr. Anonymous wrote: Hello, I want to start playing with D, and I'm looking at a GUI library to begin with. From what I see here: http://www.prowiki.org/wiki4d/wiki.cgi?GuiLibraries I have four choices: GtkD, DWT, DFL, DGui. Has anyone tried these? Any suggestions? What

Re: A GUI library to begin with

2012-02-07 Thread Mars
On Wednesday, 8 February 2012 at 03:55:41 UTC, Mr. Anonymous wrote: Has anyone tried these? Any suggestions? What is the status of DWT? What's the difference between DFL and DGui? I've only tried DFL and DGui, since I kinda didn't like the others, and of those two, DFL is the better choice,