Yet another static confusion

2013-02-20 Thread Lubos Pintes
Hi, I want to allocate a buffer which I use in a function which reads data from socket. So I did as a first line in that function: static char[] buffer=new char[4096]; The compiler (2.062) complained that it cannot evaluate new char[] at compile time. I Then tried to move the declaration

Re: on DDoc macros: a small problem

2013-02-20 Thread Johannes Pfau
Am Tue, 19 Feb 2013 16:43:09 -0800 schrieb Charles Hixson charleshi...@earthlink.net: I have, towards the start of my file: /** Macros: * Note = $(BR)$(BIG$(B$(GREEN Note:))) * Todo = brfont color=redbToDo:/b $0/fontbr * Em = $(B$(BLUE $0)) * DoNotUse = $(B Do Not Use $0) */

Re: Yet another static confusion

2013-02-20 Thread monarch_dodra
On Wednesday, 20 February 2013 at 08:03:48 UTC, Lubos Pintes wrote: Hi, I want to allocate a buffer which I use in a function which reads data from socket. So I did as a first line in that function: static char[] buffer=new char[4096]; The compiler (2.062) complained that it cannot evaluate

Re: Yet another static confusion

2013-02-20 Thread bearophile
Lubos Pintes: Allocating statically sized array bloats the executable. Because char.init is not '\0'. Try to initialize it with zero: char[10_000] a = '\0'; void main() {} Bye, bearophile

Re: D-DLLs Python

2013-02-20 Thread Chris
On Tuesday, 19 February 2013 at 17:40:03 UTC, John Colvin wrote: D doesn't use null termination for it's strings, strings are immutable(char)[]. You can form a D slice from a pointer by going slice = ptr[0..length] where length is the length of the array the pointer represents. You can't

Re: Yet another static confusion

2013-02-20 Thread Lubos Pintes
Ok thank you. I see now. One unrelated question: Why the safe attribute has the at-sign, while nothrow doesn't? Dňa 20. 2. 2013 11:19 monarch_dodra wrote / napísal(a): On Wednesday, 20 February 2013 at 08:03:48 UTC, Lubos Pintes wrote: Hi, I want to allocate a buffer which I use in a

Re: Yet another static confusion

2013-02-20 Thread bearophile
Lubos Pintes: Why the safe attribute has the at-sign, while nothrow doesn't? Historical accidents... There is no rhyme reason in that. Bye, bearophile

Re: D-DLLs Python

2013-02-20 Thread Chris
I tried extern (C) which has some advantages. However, it still doesn't produce the desired result (tried slicing too). extern(C) { export void synthesize(ref char[] str) { printf(Incoming printf: %s\n, str); writefln(writefln %s, str); writefln(writefln %s,

Re: Yet another static confusion

2013-02-20 Thread Steven Schveighoffer
On Wed, 20 Feb 2013 03:03:49 -0500, Lubos Pintes lubos.pin...@gmail.com wrote: Hi, I want to allocate a buffer which I use in a function which reads data from socket. So I did as a first line in that function: static char[] buffer=new char[4096]; The compiler (2.062) complained that it

Re: D-DLLs Python

2013-02-20 Thread Mike Parker
On Wednesday, 20 February 2013 at 12:48:53 UTC, Chris wrote: I tried extern (C) which has some advantages. However, it still doesn't produce the desired result (tried slicing too). extern(C) { export void synthesize(ref char[] str) { printf(Incoming printf: %s\n, str);

Re: D-DLLs Python

2013-02-20 Thread Chris
On Wednesday, 20 February 2013 at 14:05:40 UTC, Mike Parker wrote: Your function is being called from Python, correct? Then in addition to the extern(C), the argument needs to be a char*, not a D array or a reference to one. Correct, and it works _now_*! The lines printf(Incoming printf:

Re: D-DLLs Python

2013-02-20 Thread bearophile
Chris: extern (C) {export void printThis(char* str);} Maybe the D wiki should contain info to save some time and experiments to people. Possible alternative syntax: extern(C) export void printThis(char* str); Also, think if you want some const: extern(C) export void

Re: D-DLLs Python

2013-02-20 Thread John Colvin
On Wednesday, 20 February 2013 at 14:28:06 UTC, Chris wrote: On Wednesday, 20 February 2013 at 14:05:40 UTC, Mike Parker wrote: Your function is being called from Python, correct? Then in addition to the extern(C), the argument needs to be a char*, not a D array or a reference to one.

Re: D-DLLs Python

2013-02-20 Thread Chris
On Wednesday, 20 February 2013 at 14:36:56 UTC, bearophile wrote: Chris: extern (C) {export void printThis(char* str);} Maybe the D wiki should contain info to save some time and experiments to people. I agree and I am glad that the people on this forum are always willing to help. I will

Re: D-DLLs Python

2013-02-20 Thread Chris
On Wednesday, 20 February 2013 at 14:43:06 UTC, John Colvin wrote: On Wednesday, 20 February 2013 at 14:28:06 UTC, Chris wrote: On Wednesday, 20 February 2013 at 14:05:40 UTC, Mike Parker wrote: Your function is being called from Python, correct? Then in addition to the extern(C), the argument

Re: on DDoc macros: a small problem

2013-02-20 Thread Charles Hixson
On 02/20/2013 12:51 AM, Johannes Pfau wrote: Am Tue, 19 Feb 2013 16:43:09 -0800 schrieb Charles Hixsoncharleshi...@earthlink.net: I have, towards the start of my file: /** Macros: * Note = $(BR)$(BIG$(B$(GREEN Note:))) * Todo =brfont color=redbToDo:/b $0/fontbr * Em = $(B$(BLUE

Re: collectException range violation

2013-02-20 Thread cal
On Wednesday, 20 February 2013 at 07:54:19 UTC, monarch_dodra wrote: Note that an Error is not an Exception, and an Exception is not an Error. Both, however, are Throwable's. If you want to catch an *anything*, then catch a Throwable. As already mentioned though, catching an Error is not

Re: on DDoc macros: a small problem

2013-02-20 Thread Charles Hixson
On 02/20/2013 12:51 AM, Johannes Pfau wrote: Am Tue, 19 Feb 2013 16:43:09 -0800 schrieb Charles Hixsoncharleshi...@earthlink.net: I have, towards the start of my file: /** Macros: * Note = $(BR)$(BIG$(B$(GREEN Note:))) * Todo =brfont color=redbToDo:/b $0/fontbr * Em = $(B$(BLUE

Re: on DDoc macros: a small problem

2013-02-20 Thread H. S. Teoh
On Wed, Feb 20, 2013 at 11:02:51AM -0800, Charles Hixson wrote: On 02/20/2013 12:51 AM, Johannes Pfau wrote: Am Tue, 19 Feb 2013 16:43:09 -0800 schrieb Charles Hixsoncharleshi...@earthlink.net: I have, towards the start of my file: /** Macros: * Note = $(BR)$(BIG$(B$(GREEN

Re: on DDoc macros: a small problem

2013-02-20 Thread Charles Hixson
On 02/20/2013 11:10 AM, H. S. Teoh wrote: On Wed, Feb 20, 2013 at 11:02:51AM -0800, Charles Hixson wrote: On 02/20/2013 12:51 AM, Johannes Pfau wrote: Am Tue, 19 Feb 2013 16:43:09 -0800 schrieb Charles Hixsoncharleshi...@earthlink.net: I have, towards the start of my file: /** Macros:

Re: Issues with std.regex

2013-02-20 Thread MrAppleseed
Hello to everyone, and thank you for your help! Sorry for the delay in response, as I was busy with family matters. However, upon returning today, and with everyone's help, I have successfully gotten it to work. The code below worked out swimmingly: auto reg = regex(`[

Re: static class

2013-02-20 Thread Ben Davis
On 18/02/2013 21:25, Michael wrote: Yes, it's comes from C#. So, there is no static for classes at module level. Good to have a msg for it at compile-time. import std.stdio; public final abstract class Test { static this() { writeln(in static ctor); } static : void foo() {

Re: on DDoc macros: a small problem

2013-02-20 Thread Charles Hixson
On 02/20/2013 11:02 AM, Charles Hixson wrote: On 02/20/2013 12:51 AM, Johannes Pfau wrote: Am Tue, 19 Feb 2013 16:43:09 -0800 schrieb Charles Hixsoncharleshi...@earthlink.net: I have, towards the start of my file: /** Macros: * Note = $(BR)$(BIG$(B$(GREEN Note:))) * Todo =brfont