Re: tiny web server in D

2011-07-13 Thread Jos van Uden
On 14-7-2011 5:48, Dr.Smith wrote: import std.socket, std.string; void main() { Socket listener = new TcpSocket; assert(listener.isAlive); listener.bind(new InternetAddress(8080)); listener.listen(10); string webpage = "index.html"; Socket currSock; uint bytes

tiny web server in D

2011-07-13 Thread Dr.Smith
While the following D program runs without compiler error, it seems unable to serve a web page. Is there a better way? import std.socket, std.string; void main() { Socket listener = new TcpSocket; assert(listener.isAlive); listener.bind(new InternetAddress(8080)); listener.liste

Re: template instance cannot use local 'f' as parameter to non-global template

2011-07-13 Thread Tyro[a.c.edwards]
On 7/14/2011 12:24 AM, Trass3r wrote: Am 13.07.2011, 16:58 Uhr, schrieb Tyro[a.c.edwards] : Don't know it this is the right answer or a possible bug but it does the trick: void h() { import std.stdio; write("h()"); } class Bla { mixin wrap!h; } mixin template wrap(alias f) { void blub(typeof(

Re: template instance cannot use local 'f' as parameter to non-global template

2011-07-13 Thread Tyro[a.c.edwards]
On 7/14/2011 12:24 AM, Trass3r wrote: Am 13.07.2011, 16:58 Uhr, schrieb Tyro[a.c.edwards] : Don't know it this is the right answer or a possible bug but it does the trick: void h() { import std.stdio; write("h()"); } class Bla { mixin wrap!h; } mixin template wrap(alias f) { void blub(typeof(

Re: String Appender Fails (Memory Allocation Failure)

2011-07-13 Thread Loopback
On 2011-07-14 01:17, David Nadlinger wrote: Currently, no memory can be allocated at all during garbage collection runs, which is where destructors are usually called. David That explains it. Do you know when this feature will be available, if at all? Here is another interesting case, where I

Re: String Appender Fails (Memory Allocation Failure)

2011-07-13 Thread David Nadlinger
On 7/14/11 1:11 AM, Loopback wrote: Now the program calls Runtime.terminate, which is supposed to take care of the memory garbage and etc. This does not work. The terminate function call throws an Error, "Memory Allocation Failure". This failure originates in the 'Foo' destructor, which in turn c

Re: String Appender Fails (Memory Allocation Failure)

2011-07-13 Thread Loopback
On 2011-07-14 01:11, Loopback wrote: Hello! I've been working on a project where I had to do all memory handling explicitly because no destructors were called. When I got too tired of the explicit memory handling I decided to trace what was causing this error. After hours of code stripping I had

String Appender Fails (Memory Allocation Failure)

2011-07-13 Thread Loopback
Hello! I've been working on a project where I had to do all memory handling explicitly because no destructors were called. When I got too tired of the explicit memory handling I decided to trace what was causing this error. After hours of code stripping I had gotten myself a small concrete sample

Re: Centralizable configured compile-time class instantiation

2011-07-13 Thread shd
2011/7/13 Jesse Phillips : > shd Wrote: >> 2011/7/13 Jesse Phillips : >> > You say no to libraries >> >> That's not true! I'm not sure how did you came up to this conclusions, >> but i love libraries for applications same as command-line programs >> (like ffmpeg) for GUI apps. > > It comes from, "a

Re: Centralizable configured compile-time class instantiation

2011-07-13 Thread shd
2011/7/13 Dmitry Olshansky > Time ago I thought of something more like tag based file system, where > filetypes and e.g. date of modification are just that  - one of myriad of > tags, besides any additional that are user/system defined. > Though I have never reached any more or less complete desig

Re: Declaring a D pointer to a C function

2011-07-13 Thread Steven Schveighoffer
On Wed, 13 Jul 2011 11:32:50 -0400, Daniel Murphy wrote: "Andrej Mitrovic" wrote in message news:mailman.1607.1310570915.14074.digitalmars-d-le...@puremagic.com... Thanks! I've literally lost an entire day once when I was just starting using D and C together and had a calling convention mis

Re: Centralizable configured compile-time class instantiation

2011-07-13 Thread Jesse Phillips
shd Wrote: > 2011/7/13 Jesse Phillips : > > You say no to libraries > > That's not true! I'm not sure how did you came up to this conclusions, > but i love libraries for applications same as command-line programs > (like ffmpeg) for GUI apps. It comes from, "and APIs are not what i'd love to wor

Re: Declaring a D pointer to a C function

2011-07-13 Thread Daniel Murphy
"Andrej Mitrovic" wrote in message news:mailman.1607.1310570915.14074.digitalmars-d-le...@puremagic.com... > Thanks! I've literally lost an entire day once when I was just > starting using D and C together and had a calling convention mismatch. > :x It's worse than just calling conventions - try

Re: template instance cannot use local 'f' as parameter to non-global template

2011-07-13 Thread Trass3r
I've seen this error before... *searches memory and old code* Here you go: http://d.puremagic.com/issues/show_bug.cgi?id=3051 I think this is yet another issue. The inner template argument is not something on the stack but it is a template argument.

Re: template instance cannot use local 'f' as parameter to non-global template

2011-07-13 Thread Trass3r
Am 13.07.2011, 16:58 Uhr, schrieb Tyro[a.c.edwards] : Don't know it this is the right answer or a possible bug but it does the trick: void h() { import std.stdio; write("h()"); } class Bla { mixin wrap!h; } mixin template wrap(alias f) { void blub(typeof(&f) g = &f) {

Re: Declaring a D pointer to a C function

2011-07-13 Thread Andrej Mitrovic
On 7/13/11, Daniel Murphy wrote: > "Andrej Mitrovic" wrote in message > news:mailman.1569.1310506439.14074.digitalmars-d-le...@puremagic.com... >> Is this going to be fixed any time soon? Allowing callbacks with D >> calling convention where a C callback is expected should be an error, >> and thi

Re: Declaring a D pointer to a C function

2011-07-13 Thread Daniel Murphy
"Andrej Mitrovic" wrote in message news:mailman.1569.1310506439.14074.digitalmars-d-le...@puremagic.com... > Is this going to be fixed any time soon? Allowing callbacks with D > calling convention where a C callback is expected should be an error, > and this is like the 10th time I've ran into th

Re: template instance cannot use local 'f' as parameter to non-global template

2011-07-13 Thread Tyro[a.c.edwards]
On 7/13/2011 11:35 PM, Trass3r wrote: Am 13.07.2011, 16:02 Uhr, schrieb Steven Schveighoffer : void h() {} class Bla { mixin wrap!h; } mixin template wrap(alias f) { void blub(alias g = f)() { g(); } } As a workaround, is there a reason you need blub to be parameterized? I mean, f is alr

Re: template instance cannot use local 'f' as parameter to non-global template

2011-07-13 Thread Trass3r
Am 13.07.2011, 16:02 Uhr, schrieb Steven Schveighoffer : void h() {} class Bla { mixin wrap!h; } mixin template wrap(alias f) { void blub(alias g = f)() { g(); } } As a workaround, is there a reason you need blub to be parameterized? I m

Re: template instance cannot use local 'f' as parameter to non-global template

2011-07-13 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 09:06:56 -0400, Trass3r wrote: Is this a bug? If not, how do you make it work? void h() {} class Bla { mixin wrap!h; } mixin template wrap(alias f) { void blub(alias g = f)() { } } void main() { Bla b = new Bla(); b.blub();

Re: template instance cannot use local 'f' as parameter to non-global template

2011-07-13 Thread Stephan
On 12.07.2011 15:06, Trass3r wrote: Is this a bug? If not, how do you make it work? void h() {} class Bla { mixin wrap!h; } mixin template wrap(alias f) { void blub(alias g = f)() { } } void main() { Bla b = new Bla(); b.blub(); } test.d(18): Error: template instance cannot use local 'f' as

Re: template instance cannot use local 'f' as parameter to non-global template

2011-07-13 Thread Trass3r
Anybody an idea?

Re: Centralizable configured compile-time class instantiation

2011-07-13 Thread Dmitry Olshansky
On 13.07.2011 15:39, shd wrote: I hope i didn't bored you too much with my imagination because there is something more i don't like. Directory hierarchy :) It's not D-related though. Understanding a risk of going completely OT: you are not alone on this one :) Time ago I thought of something m

Re: Centralizable configured compile-time class instantiation

2011-07-13 Thread shd
2011/7/13 Jesse Phillips : > After reading Kagamin's response, I'm not sure I understand you still. You > want to have code reuse, you want to have run-time and compile-time > configuration, but you don't want to make use of the > technologies/techniques/patterns which facilitate these. I'm not

Re: Centralizable configured compile-time class instantiation

2011-07-13 Thread shd
2011/7/13 Kagamin : > Hmm... If you have > wrappers/gl/guiImpl/... > and > wrappers/what/guiImpl/... > and conditionally add them to includes > for example > with -I wrappers/gl you should be able to import guiImpl; and use > guiImpl.Window. If it's -I wrappers/what, guiImpl.Window is still > gui

Re: This seems like what could be a common cause of bugs

2011-07-13 Thread Kagamin
Steven Schveighoffer Wrote: > On Tue, 12 Jul 2011 11:07:57 -0400, Kagamin wrote: > > > Steven Schveighoffer Wrote: > > > >> Yes, but this is getting into territory where the false positive rate > >> might get high. > > > > I bet it will be difficult to find a real-world example of this false >

Re: Centralizable configured compile-time class instantiation

2011-07-13 Thread Kagamin
shd Wrote: > 2011/7/12 Kagamin : > > You want an IOC container like Unity? > exactly > > And you want the interface-to-class mapping to be configurable externally > > rather than version out these classes directly in source? > > like > > version(UseGL) > > { > > �static import wrappers.gl; > >