Re: ~= call copy ctor?

2012-07-20 Thread Regan Heath
On Fri, 20 Jul 2012 14:50:19 +0100, Namespace rswhi...@googlemail.com wrote: New question: I have this code: [code] import std.stdio; struct Test { public: this(int i = 0) { writeln(CTOR); } this(this) { writeln(COPY CTOR); }

Re: Magic type return

2012-07-18 Thread Regan Heath
On Tue, 17 Jul 2012 15:23:05 +0100, bearophile bearophileh...@lycos.com wrote: Andrea Fontana: class Known { void* data; // external data by c api int type; // 0 for int, 1 for string, etc. .. } How can I implement a method like this? Known known; // -- suppose

Re: Passing a ubyte[] to a function taking a 'ref ubyte[16]'

2012-06-25 Thread Regan Heath
and without breaking the ABI. Regan Heath who designed the Tango digest module, also said that digets are often used with the factory pattern, which doesn't work with structs / templates. Correction; I supplied some code which became the Tango digest modules, someone else defined the final API

Re: Stack overflow

2012-06-22 Thread Regan Heath
On Fri, 22 Jun 2012 15:55:12 +0100, Namespace rswhi...@googlemail.com wrote: If you have a null object you get an Access Violation without _any_ further information. That totally sucks. It doesn't have to be that way. A debug executable contains all sort of debugging information and a

Re: Does D have high-performance sockets

2012-06-13 Thread Regan Heath
On Tue, 12 Jun 2012 22:29:58 +0100, D Day damian...@hotmail.co.uk wrote: Are there any implementations of this anywhere for D? I really only care about the windows platform - and have considered writing this myself with IOCP and std.socket, but I figure someone else must have already done

Re: gdc and gcc object linking issues

2012-06-07 Thread Regan Heath
On Thu, 07 Jun 2012 15:12:46 +0100, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 6/7/12, Kagamin s...@here.lot wrote: If you define a variable in the header, it will be included in each including module and you'll get several instances of the variable and symbol collision at link

Re: Static function conflicts with Non-Static?!

2012-06-06 Thread Regan Heath
On Sat, 02 Jun 2012 09:23:50 +0100, Jonathan M Davis jmdavisp...@gmx.com wrote: ...and probably the same for C#, though I'm not sure No, in C# you cannot call a static member function with a class instance, see Static Members: A static method, field, property, or event is callable on a

Re: Static function conflicts with Non-Static?!

2012-06-06 Thread Regan Heath
On Sat, 02 Jun 2012 19:25:05 +0100, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 6/2/12, Jonathan M Davis jmdavisp...@gmx.com wrote: The trick is getting Walter to agree. The trick is getting all the people that bought TDPL to burn their books, because by the time all these new

Re: Package Declaration

2012-06-06 Thread Regan Heath
On Tue, 05 Jun 2012 10:29:23 +0100, Jonathan M Davis jmdavisp...@gmx.com wrote: On Tuesday, June 05, 2012 11:08:03 Namespace wrote: Currently i have all of my Files in the same Directory. Now i will split them up in several specific Sub-Directories, e.g. Graphics, System and so one. But i

Re: Reading ASCII file with some codes above 127 (exten ascii)

2012-05-25 Thread Regan Heath
On Wed, 23 May 2012 22:02:25 +0100, Paul phshaf...@gmail.com wrote: This works, though it's ugly: foreach(line; uniS.splitLines()) { transcode(line, latinS); fout.writeln((cast(char[]) latinS)); } The Latin1String type, at the storage level, is a ubyte[]. By casting to

Re: convert ubyte[k..k + 1] to int

2012-05-16 Thread Regan Heath
On Wed, 16 May 2012 15:24:33 +0100, ref2401 refacto...@gmail.com wrote: i have an array of ubytes. how can i convert two adjacent ubytes from the array to an integer? pseudocode example: ubyte[5] array = createArray(); int value = array[2..3]; is there any 'memcpy' method or something else

Re: Help: running a method from the importing file's method space

2012-05-01 Thread Regan Heath
I'm not sure if any of this is helpful but I've had a tinker and had some measure of success :p I think you have the following issues to resolve: 1. When you build the lib, you need to tell it that the progMain symbol is to be found 'extern'ally. 2. When you build the exe, you have to make sure

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-24 Thread Regan Heath
On Mon, 23 Apr 2012 16:43:20 +0100, Steven Schveighoffer schvei...@yahoo.com wrote: While dealing with unicode in my std.stream rewrite, I've found that hand-decoding dchars is way faster than using library calls. After watching Andrei's talk on generic and generative programming I have

Re: Assert and the optional Message

2012-03-09 Thread Regan Heath
: kbhit and Sleep are windows specific (sleep would be the unix equivalent, not sure on one for kbhit). Regan Heath -- Using Opera's revolutionary email client: http://www.opera.com/mail/

Re: Assert and the optional Message

2012-03-09 Thread Regan Heath
On Fri, 09 Mar 2012 11:12:44 -, Jonathan M Davis jmdavisp...@gmx.com wrote: On Friday, March 09, 2012 11:03:38 Regan Heath wrote: On Fri, 09 Mar 2012 08:20:33 -, Chris Pons cmp...@gmail.com wrote: Any idea why, system(PAUSE) does work? As Jonathan says, assert throws AssertError

Re: Can I do an or in a version block?

2012-03-08 Thread Regan Heath
On Thu, 08 Mar 2012 06:12:44 -, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday, March 08, 2012 06:38:48 Tyler Jameson Little wrote: I would like to do something like this: version (linux || BSD) { // do something... } else { version (Windows) { // do something

Re: SocketStream exceptions and disconnect handling

2012-03-07 Thread Regan Heath
On Wed, 07 Mar 2012 17:29:25 -, Pedro Lacerda pslace...@gmail.com wrote: 2012/3/7 Pedro Lacerda pslace...@gmail.com Hi all, I'm trying to handle disconnections transparently on SocketStream. I thought something like this: void send(ubyte[] buffer) in { assert(buffer.length 0); } body {

Re: Shutting down thread with Socket blocking for connection

2012-03-05 Thread Regan Heath
A more efficient approach is to use async socket routines and an event object. So, in main you create a shared event object, then start the listen thread. In listen you call an async select or accept, and then wait on that /and/ the shared event object. To stop listen you set the shared

Re: Arrray sizeof

2011-12-28 Thread Regan Heath
On Sat, 24 Dec 2011 16:46:18 -, RenatoL rex...@gmail.com wrote: snippet: int[] arr1 = [1,2,3,4,5]; int[5] arr2 = [1,2,3,4,5]; writeln(arr1.sizeof); writeln(arr2.sizeof); Output: 8 20 0 is ok to me but why 8?? It's a quirk of D that int[] is a reference type, so you get the size of

Re: Download file via http

2011-12-13 Thread Regan Heath
On Tue, 13 Dec 2011 17:58:57 -, Kai Meyer k...@unixlords.com wrote: On 12/13/2011 10:39 AM, Vladimir Panteleev wrote: On Tuesday, 13 December 2011 at 17:29:20 UTC, Kai Meyer wrote: I get bytes_needed from the Content-Length header. The I get the correct number of bytes from the

Re: Abstract functions in child classes

2011-12-02 Thread Regan Heath
On Fri, 02 Dec 2011 17:24:11 -, Adam a...@anizi.com wrote: Ok, fine, let me put it THIS way. Suppose I use a parent library, and *I* don't update it. The USER of my library provides an updated version for some unrelated reason. So, NOT testing that something is instantiable or not - JUST

Re: Abstract functions in child classes

2011-12-02 Thread Regan Heath
On Fri, 02 Dec 2011 17:24:11 -, Adam a...@anizi.com wrote: Ok, fine, let me put it THIS way. Suppose I use a parent library, and *I* don't update it. The USER of my library provides an updated version for some unrelated reason. So.. the user has: Parent.dll Your.dll Their.exe and

Re: Abstract functions in child classes

2011-12-02 Thread Regan Heath
On Fri, 02 Dec 2011 17:43:04 -, Adam a...@anizi.com wrote: I grant you that I should test it, and I never said otherwise. If I'm attacking a strawman, it's the same one that was just put in front of me as a misinterpretation of my argument. Well, I believe I understand your argument and I

Re: Abstract functions in child classes

2011-12-02 Thread Regan Heath
On Fri, 02 Dec 2011 17:44:44 -, Adam a...@anizi.com wrote: Or I provide it as source, in which case, D *can* check it. But it means that when the parent is changed, my class type and instantiability implicitly changes, too. True. This is a case I hadn't considered before. In this case

Re: piping processes

2011-12-01 Thread Regan Heath
On Wed, 30 Nov 2011 23:35:58 -, NMS nathanms...@gmail.com wrote: Is there a cross-platform way to create a new process and get its i/o streams? Like java.lang.Process? No. It different on windows and unix platforms, tho most/many of the unix platforms are similar. std.process is

Re: piping processes

2011-12-01 Thread Regan Heath
On Thu, 01 Dec 2011 11:28:50 -, Dejan Lekic dejan.le...@gmail.com wrote: We talked about that too on IRC - the conclusion was - we should have std.pipe module with (at least) AnonymousPipe, and NamedPipe classes. Definitely. I will have a hunt for my misplaced code but it had some sort

Re: piping processes

2011-12-01 Thread Regan Heath
On Thu, 01 Dec 2011 11:29:52 -, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: I can't find my thread in the archives yet, but I made a similar inquiry a few days ago. You can see a few examples for Windows here:

Re: Abstract functions in child classes

2011-12-01 Thread Regan Heath
On Thu, 01 Dec 2011 17:50:48 -, Adam a...@anizi.com wrote: Ok, starting to feel like I'm missing something obvious... This: void main() { Child child = new Child; } also produces the (expected) error. Basically dmd was letting you get away with the abstract class

Re: My new least favorite one-liner...

2011-11-07 Thread Regan Heath
On Sun, 06 Nov 2011 04:39:28 -, Jude Young 10equa...@gmail.com wrote: Nice. Exactly what I was looking for. I knew I was missing something tiny. Now I just need to figure out why that works and I can say I've learned something! Thanks guys, Jude On Sat, Nov 5, 2011 at 5:38 AM, bearophile

Re: Calling D DLL from C# and passing/retrieving string variables

2011-10-12 Thread Regan Heath
On Wed, 12 Oct 2011 17:10:09 +0100, Trass3r u...@known.com wrote: [DllImport(mydll.dll, CallingConvention = CallingConvention.Cdecl, SetLastError = false, CharSet = CharSet.Auto)] private static extern bool concatenate( string str1, //

Re: Order of base-class constructor calls

2011-10-11 Thread Regan Heath
On Fri, 07 Oct 2011 23:02:33 +0100, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: So I'm looking for some techniques or tricks (or, dare I say, design patterns :x) you guys might have if you've ever ran into this kind of problem. The best I can come up with is a runtime solution: import

Re: check for running process

2011-10-05 Thread Regan Heath
On Wed, 05 Oct 2011 16:05:02 +0100, Steven Schveighoffer schvei...@yahoo.com wrote: On Wed, 05 Oct 2011 10:38:58 -0400, Dsmith dsm...@nomail.com wrote: In the core.thread library, there is a method isRunning() which takes a thread. To make code more portable, rather than use a system

Re: std.socket - problems closing socket

2011-10-04 Thread Regan Heath
On Mon, 03 Oct 2011 19:41:14 +0100, simendsjo simend...@gmail.com wrote: It seems nginx is to blame here, and not me. I tried Lighttp and it works. It gives several EWOULDBLOCK, but I can just handle these again with no problem. I should have tried this sooner... I've used a lot of time

Re: std.socket - problems closing socket

2011-10-03 Thread Regan Heath
On Sat, 01 Oct 2011 00:26:35 +0100, simendsjo simend...@gmail.com wrote: Not sure if this is a problem with std.socket, nginx or my knowledge of sockets. I'm pretty sure it's the last one. I'm experimenting with fastcgi on nginx, and the socket stays in TIME_WAIT even after I call

Re: std.socket - problems closing socket

2011-10-03 Thread Regan Heath
This might be a useful read.. http://msdn.microsoft.com/en-us/library/windows/desktop/ms738547(v=vs.85).aspx

Re: std.socket - problems closing socket

2011-10-03 Thread Regan Heath
On Mon, 03 Oct 2011 12:57:56 +0100, simendsjo simend...@gmail.com wrote: On 03.10.2011 11:36, Regan Heath wrote: For a graceful close you're supposed to ensure there is no data pending. To do that you: shutdown(SD_SEND); // send only, not recv enter a loop reading all data remaining

Re: std.socket - problems closing socket

2011-10-03 Thread Regan Heath
On Mon, 03 Oct 2011 17:33:57 +0100, simendsjo simend...@gmail.com wrote: Yes. I've coded the client as follows: 1) start listening socket 2) wait for incoming connections or incoming data 3) receive(). If a socket returns 0 or -1, close it and process next with data 4) read fastcgi request

Re: Sourcing a script's env into D?

2011-09-30 Thread Regan Heath
On Fri, 30 Sep 2011 07:18:34 +0100, Jacob Carlborg d...@me.com wrote: On 2011-09-29 19:31, Nick Sabalausky wrote: Due to process separation, the following won't work: script.sh: #!/bin/sh SOME_VAR=foobar test.d: import std.process; void main() { system(./script.sh);

Re: Using pure to create immutable

2011-09-23 Thread Regan Heath
On Thu, 22 Sep 2011 22:18:29 +0100, Jonathan M Davis jmdavisp...@gmx.com wrote: On Thursday, September 22, 2011 14:10 Steven Schveighoffer wrote: No, the parameter types can be const, and can accept mutable arguments. The main point is, the return value has to be proven to be *unique*. The

Re: A little puzzle

2011-09-20 Thread Regan Heath
On Mon, 19 Sep 2011 23:09:45 +0100, Simen Kjaeraas simen.kja...@gmail.com wrote: On Mon, 19 Sep 2011 23:20:47 +0200, bearophile bearophileh...@lycos.com wrote: A tiny puzzle I've shown on IRC. This is supposed to create an inverted array of cards, but what does it print instead? import

Re: How would I retrieve the stdout error message of a system/shell command?

2011-09-09 Thread Regan Heath
On Thu, 08 Sep 2011 16:33:49 +0100, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: E.g.: import std.process; void main() { auto res = shell(dmd bla.d); } where bla.d doesn't exist. This will throw an exception, but even if I caught the exception I will still loose the error message.

Re: null Vs [] return arrays

2011-04-07 Thread Regan Heath
On Tue, 05 Apr 2011 18:46:06 +0100, Steven Schveighoffer schvei...@yahoo.com wrote: On Tue, 05 Apr 2011 13:24:49 -0400, Regan Heath re...@netmail.co.nz wrote: On Fri, 01 Apr 2011 18:23:28 +0100, Steven Schveighoffer schvei...@yahoo.com wrote: assert( !is null); // works on D. Try

Re: null Vs [] return arrays

2011-04-01 Thread Regan Heath
On Mon, 28 Mar 2011 17:54:29 +0100, bearophile bearophileh...@lycps.com wrote: Steven Schveighoffer: So essentially, you are getting the same thing, but using [] is slower. It seems I was right then, thank you and Kagamin for the answers. This may be slightly OT but I just wanted to raise

Re: null Vs [] return arrays

2011-04-01 Thread Regan Heath
On Fri, 01 Apr 2011 13:38:45 +0100, Steven Schveighoffer schvei...@yahoo.com wrote: On Fri, 01 Apr 2011 06:38:56 -0400, Regan Heath re...@netmail.co.nz wrote: On Mon, 28 Mar 2011 17:54:29 +0100, bearophile bearophileh...@lycps.com wrote: Steven Schveighoffer: So essentially, you

Re: Read file/stream

2011-03-14 Thread Regan Heath
On Fri, 11 Mar 2011 22:39:43 -, Stewart Gordon smjg_1...@yahoo.com wrote: On 11/03/2011 21:51, Steven Schveighoffer wrote: snip Presumably there's a reason that it's been provided for uint but not ushort or ulong I think things in std.intrinsic are functions that tie directly to

Re: Writing an integer to a file

2011-03-07 Thread Regan Heath
On Mon, 07 Mar 2011 11:26:25 -, yochi yoc...@gmail.com wrote: Hello, I am trying to write an integer to a file, but when I open the file it writes the char the number represents in ascii. does anyone have a suggestion? Post your code, people can then suggest changes. Also, some things to

Re: Buffered Endian Stream Socket?

2010-04-21 Thread Regan Heath
Kyle Mallory wrote: I'm trying to write a series of structs to a stream, which then has to be sent over the wire within a single TCP packet, in order for the host, an embedded device, to recognize the message. If there is too little, or too much data for a given command (packet), the device

Re: Link error with template struct on 2.042

2010-03-31 Thread Regan Heath
Frank Fischer wrote: On 2010-03-31, Regan Heath re...@netmail.co.nz wrote: Frank Fischer wrote: If I compile the above example with dmd main.d Weird, that command line works fine for me, no errors. Strange. I used the linux version 2.042, just downloaded. Ahh.. I am on Windoze

<    1   2