Symbol undefined due to import statement

2011-08-15 Thread Andre
Hi, there is a behaviour which seems strange for me. I have following structure C:\Projects\ProjectA\main.d C:\Projects\Reusuable\net\http.d The content of main.d is: module main; import std.stdio; import net.http; int main() { return 0; } The content of http.d is: module

Re: Symbol undefined due to import statement

2011-08-15 Thread torhu
On 15.08.2011 10:15, Andre wrote: ... I compile the application with command: dmd -IC:\Projects\Reusuable main.d This works, but if I now edit the http.d file and add an import statement like "import std.stdio;" then the linker will output following error: main.obj(main) Error 42: Symbol

Re: Symbol undefined due to import statement

2011-08-15 Thread Andre
Am Mon, 15 Aug 2011 10:24:38 +0200 schrieb torhu: > dmd -IC:\Projects\Reusuable main.d net\http.d Hi torhu, thanks a lot. This works. Kind regards Andre

Re: delegate object instead of a literal

2011-08-15 Thread Joel Christensen
Ok, this is a good one I think. import std.string, std.algorithm, std.functional; bool isANum( dchar chr ) { return inPattern( chr, digits ~ `"+-.` ); } void main() { auto input = `abc123`; auto indexEnd = -1; indexEnd = count!( not!isANum )( input ); assert( indexEnd =

Re: htod

2011-08-15 Thread Jason King
Thank you very much, that solved my issue. C:\dir>htod -I c:\d\dm\include ocilib.h Fatal error: unable to open input file 'stdlib.h' You have an extra space there. Use: htod -IC:\d\dm\include ocilib.h That will work.

Re: const main args?

2011-08-15 Thread Steven Schveighoffer
On Fri, 12 Aug 2011 17:51:50 -0400, bearophile wrote: Steven Schveighoffer: > int main(in string[] args); What would be the purpose of this? Why do you use "in" in function arguments? To make sure you will not modify the given array. I think it's not good practice to change the lengt

Re: to invalidate a range

2011-08-15 Thread Steven Schveighoffer
On Fri, 12 Aug 2011 16:58:15 -0400, Ellery Newcomer wrote: On 08/12/2011 03:29 PM, Steven Schveighoffer wrote: On Fri, 12 Aug 2011 15:54:53 -0400, Ellery Newcomer wrote: in std.container, the stable* container functions advocate that they do not invalidate the ranges of their containers.

Re: to invalidate a range

2011-08-15 Thread Steven Schveighoffer
On Fri, 12 Aug 2011 18:29:00 -0400, Ellery Newcomer wrote: On 08/12/2011 03:54 PM, Jonathan M Davis wrote: In the case of container that uses nodes - such as a linked list - because you can add and remove elements without affecting other elements, iterators and ranges don't tend to get

Re: Split by length?

2011-08-15 Thread Steven Schveighoffer
On Sun, 14 Aug 2011 23:00:26 -0400, Andrej Mitrovic wrote: Simplified (and slow) implementation: T[] splitLength(T)(T arr, size_t count) if (isArray!T) { T[] result; while (arr.length) { result ~= arr.take(count); arr.popFrontN(count); } return result; }

Re: Split by length?

2011-08-15 Thread Andrej Mitrovic
On 8/15/11, Steven Schveighoffer wrote: > Ouch! It's not that big of an ouch actually: http://codepad.org/m1zKlP0e

Re: const main args?

2011-08-15 Thread mimocrocodil
I seen what sendmail actually changes they arguments of command line for nice output of "ps ax" command. May be it changes his argc/argv for this?

byte* and int length -> byte[]

2011-08-15 Thread mimocrocodil
I obtain immutable(byte)* and int where contained length of bytes block from C library. Can I convert this into byte[] without explict copying etc. Something like: byte* p; // bytes int size; // size of bytes block byte[] b; b.length = size; b.ptr = p; // now b contains bytes from library

Re: byte* and int length -> byte[]

2011-08-15 Thread Jimmy Cao
On Mon, Aug 15, 2011 at 12:16 PM, mimocrocodil <4deni...@gmail.com> wrote: > I obtain immutable(byte)* and int where contained length of bytes block > from C library. > > Can I convert this into byte[] without explict copying etc. > > Something like: > > byte* p; // bytes > int size; // size of by

Re: byte* and int length -> byte[]

2011-08-15 Thread David Nadlinger
On 8/15/11 7:16 PM, mimocrocodil wrote: Can I convert this into byte[] without explict copying etc. […] byte* p; // bytes int size; // size of bytes block Simply slice the pointer: p[0 .. size] David

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

2011-08-15 Thread bearophile
Marco Leise: > That's why Pascal uses another set of operators for integer divisions, > namely 'div' and 'mod', so you can never get into that situation. The > above code would have worked and in case step was an integer, the compiler > would have complained about not using 'div'. I doubt th

Re: byte* and int length -> byte[]

2011-08-15 Thread Steven Schveighoffer
On Mon, 15 Aug 2011 13:16:54 -0400, mimocrocodil <4deni...@gmail.com> wrote: I obtain immutable(byte)* and int where contained length of bytes block from C library. Can I convert this into byte[] without explict copying etc. Something like: byte* p; // bytes int size; // size of bytes blo

Re: byte* and int length -> byte[]

2011-08-15 Thread Mafi
Am 15.08.2011 19:16, schrieb mimocrocodil: I obtain immutable(byte)* and int where contained length of bytes block from C library. Can I convert this into byte[] without explict copying etc. Something like: byte* p; // bytes int size; // size of bytes block byte[] b; b.length = size; b.ptr =

Re: const main args?

2011-08-15 Thread bearophile
Steven Schveighoffer: > int main(string[] _args) > { > const args = _args; // not modifiable copy > } Currently DMD accepts code like: int main(in string[] args) { return 0; } void main(in string[] args) {} int main() { return 0; } void main() {} What I have asked is if it's worth changing

Re: htod

2011-08-15 Thread Jacob Carlborg
On 2011-08-13 04:13, Trass3r wrote: I'm working on a tool to convert C header files to D modules based on clang. But currently it's not a prioritized project. I also played with the idea. Clang's Rewrite facilities should be perfect for that. Yeah, I'm using Rewrite, if I recall correctly.

Re: byte* and int length -> byte[]

2011-08-15 Thread Vijay Nayar
On Mon, 15 Aug 2011 17:16:54 +, mimocrocodil wrote: > I obtain immutable(byte)* and int where contained length of bytes block > from C library. > > Can I convert this into byte[] without explict copying etc. > > Something like: > > byte* p; // bytes > int size; // size of bytes block > > b

count until predicate returns false

2011-08-15 Thread Andrej Mitrovic
This will print the count of whitespace chars in a line: writeln(count!isWhite(line)); What I need is the count of whitspace chars until the first non-whitespace char is found, essentially I need a "countWhile" template: writeln(countWhile!isWhite(line)); Can I do this with existing templates s

Re: count until predicate returns false

2011-08-15 Thread Simen Kjaeraas
On Mon, 15 Aug 2011 21:53:11 +0200, Andrej Mitrovic wrote: This will print the count of whitespace chars in a line: writeln(count!isWhite(line)); What I need is the count of whitspace chars until the first non-whitespace char is found, essentially I need a "countWhile" template: writeln(co

Re: count until predicate returns false

2011-08-15 Thread Jonathan M Davis
On Monday, August 15, 2011 12:53 Andrej Mitrovic wrote: > This will print the count of whitespace chars in a line: > > writeln(count!isWhite(line)); > > What I need is the count of whitspace chars until the first > non-whitespace char is found, essentially I need a "countWhile" > template: > > w

Re: count until predicate returns false

2011-08-15 Thread David Nadlinger
On 8/15/11 11:00 PM, Jonathan M Davis wrote: On Monday, August 15, 2011 12:53 Andrej Mitrovic wrote: This will print the count of whitespace chars in a line: writeln(count!isWhite(line)); What I need is the count of whitspace chars until the first non-whitespace char is found, essentially I ne

Re: delegate object instead of a literal

2011-08-15 Thread Jonathan M Davis
On Monday, August 15, 2011 02:25 Joel Christensen wrote: > Ok, this is a good one I think. > > import std.string, std.algorithm, std.functional; > > bool isANum( dchar chr ) { > return inPattern( chr, digits ~ `"+-.` ); > } > > void main() { > auto input = `abc123`; > auto indexEnd = -1; > > in

Re: count until predicate returns false

2011-08-15 Thread Jonathan M Davis
On Monday, August 15, 2011 14:09 David Nadlinger wrote: > On 8/15/11 11:00 PM, Jonathan M Davis wrote: > > On Monday, August 15, 2011 12:53 Andrej Mitrovic wrote: > >> This will print the count of whitespace chars in a line: > >> > >> writeln(count!isWhite(line)); > >> > >> What I need is the cou

Re: const main args?

2011-08-15 Thread Timon Gehr
On 08/15/2011 03:47 PM, Steven Schveighoffer wrote: On Fri, 12 Aug 2011 17:51:50 -0400, bearophile wrote: Steven Schveighoffer: > int main(in string[] args); What would be the purpose of this? Why do you use "in" in function arguments? To make sure you will not modify the given array. I t

Re: const main args?

2011-08-15 Thread Brad Roberts
On Mon, 15 Aug 2011, Timon Gehr wrote: > On 08/15/2011 03:47 PM, Steven Schveighoffer wrote: > > On Fri, 12 Aug 2011 17:51:50 -0400, bearophile > > wrote: > > > > > Steven Schveighoffer: > > > > > > > > int main(in string[] args); > > > > > > > > What would be the purpose of this? > > > > > >

Re: const main args?

2011-08-15 Thread Timon Gehr
On 08/15/2011 11:53 PM, Brad Roberts wrote: On Mon, 15 Aug 2011, Timon Gehr wrote: On 08/15/2011 03:47 PM, Steven Schveighoffer wrote: On Fri, 12 Aug 2011 17:51:50 -0400, bearophile wrote: Steven Schveighoffer: int main(in string[] args); What would be the purpose of this? Why do you

Re: count until predicate returns false

2011-08-15 Thread Andrej Mitrovic
That doesn't work: import std.algorithm; import std.stdio; import std.functional; import std.uni; void main() { auto line = " foo"; writeln(countUntil!(not!isWhite)(line)); } test.d(9): Error: template std.algorithm.countUntil(alias pred = "a == b",R1,R2) if (is(typeof(startsWith!(pred)

Re: delegate object instead of a literal

2011-08-15 Thread Jonathan M Davis
On Monday, August 15, 2011 14:28 Jonathan M Davis wrote: > On Monday, August 15, 2011 02:25 Joel Christensen wrote: > > Ok, this is a good one I think. > > > > import std.string, std.algorithm, std.functional; > > > > bool isANum( dchar chr ) { > > return inPattern( chr, digits ~ `"+-.` ); > > }

Re: count until predicate returns false

2011-08-15 Thread Jonathan M Davis
On Monday, August 15, 2011 15:15 Andrej Mitrovic wrote: > That doesn't work: > > import std.algorithm; > import std.stdio; > import std.functional; > import std.uni; > > void main() > { > auto line = " foo"; > writeln(countUntil!(not!isWhite)(line)); > } > > test.d(9): Error: template std.algori

Re: count until predicate returns false

2011-08-15 Thread Andrej Mitrovic
Thanks, but I'll wait for the next release before I use it. In the meantime I guess I'll use this monster: array(until!(not!isWhite)(line)).length

Re: count until predicate returns false

2011-08-15 Thread bearophile
Andrej Mitrovic: > In the meantime I guess I'll use this monster: > > array(until!(not!isWhite)(line)).length This is better: import std.algorithm, std.range, std.ascii, std.functional; void main() { string line = " foo "; size_t n = walkLength(until!(not!isWhite)(line)); assert(

Re: count until predicate returns false

2011-08-15 Thread Andrej Mitrovic
Thanks!

how to enable core dumps for assert() triggering?

2011-08-15 Thread mimocrocodil
subj

Re: byte* and int length -> byte[]

2011-08-15 Thread mimocrocodil
to Vijay Nayar: Thanks! Heh... Inside the my code this data also not be changed, so that I would agree to obtain something like immutable byte[] :)

Re: delegate object instead of a literal

2011-08-15 Thread Joel Christensen
On 16-Aug-11 10:22 AM, Jonathan M Davis wrote: On Monday, August 15, 2011 14:28 Jonathan M Davis wrote: On Monday, August 15, 2011 02:25 Joel Christensen wrote: Ok, this is a good one I think. import std.string, std.algorithm, std.functional; bool isANum( dchar chr ) { return inPattern( chr,