Re: forks/pipes and std.socket

2010-09-07 Thread Masahiro Nakagawa
On Mon, 06 Sep 2010 05:32:28 +0900, Nick Sabalausky wrote: This may be a stupid question: Does std.socket encorporate or replace pipe usage? Ie, if I'm going to do something along the lines of (psuedo-code): auto parentToChild = pipe(); auto childToParent = pipe(); if(fork()) { // talk to

Re: Understanding isInfinite(Range)

2010-09-07 Thread Pelle
On 09/07/2010 12:44 AM, bearophile wrote: Andrej Mitrovic: I'm sorry, but what does q{..} mean? q{} is just a different syntax to write "" or `` It's a controversial feature. q{} isn't recognized by editors as a string, so they colour the syntax it contains normally as code, and not as a st

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Steven Schveighoffer
On Sun, 05 Sep 2010 09:40:59 -0400, BLS wrote: On 05/09/2010 02:16, Jonathan M Davis wrote: void foo(T)(T[] collection, T elem) { // Blah, whatever } I am curious, how this will look and feel once inout is working ? inout void foo(T)(inout(T)[] collection, inout T elem) { // Bl

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Jacob Carlborg
On 2010-09-07 14:49, Steven Schveighoffer wrote: On Sun, 05 Sep 2010 09:40:59 -0400, BLS wrote: On 05/09/2010 02:16, Jonathan M Davis wrote: void foo(T)(T[] collection, T elem) { // Blah, whatever } I am curious, how this will look and feel once inout is working ? inout void foo(T)(inout

Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread Steven Schveighoffer
On Sun, 05 Sep 2010 22:41:50 -0400, bearophile wrote: Tom Kazimiers: How can I have a (temporary) dynamic array on stack and make references to it (no copying)? I successively put integers in an array (but don't know how much there will be in advance) with an appender!(int[]) and get the dat

Question about typeof(this)

2010-09-07 Thread Jacob Carlborg
I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof where it says: "typeof(this) will generate the type of what this would be in a non-static member function, even if not in a member function. " From that I got the impression that the code below would print the same result,

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Steven Schveighoffer
On Tue, 07 Sep 2010 08:56:15 -0400, Jacob Carlborg wrote: On 2010-09-07 14:49, Steven Schveighoffer wrote: On Sun, 05 Sep 2010 09:40:59 -0400, BLS wrote: On 05/09/2010 02:16, Jonathan M Davis wrote: void foo(T)(T[] collection, T elem) { // Blah, whatever } I am curious, how this will l

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Pelle
On 09/07/2010 03:15 PM, Steven Schveighoffer wrote: On Tue, 07 Sep 2010 08:56:15 -0400, Jacob Carlborg wrote: On 2010-09-07 14:49, Steven Schveighoffer wrote: On Sun, 05 Sep 2010 09:40:59 -0400, BLS wrote: On 05/09/2010 02:16, Jonathan M Davis wrote: void foo(T)(T[] collection, T elem) {

Pop an element from an array inplace?

2010-09-07 Thread Paolo Invernizzi
Hi all, What's the best way to find an element into an array, drop it and shrink the array inplace, in D2? Thanks in advance, Paolo

Re: Pop an element from an array inplace?

2010-09-07 Thread Simen kjaeraas
Paolo Invernizzi wrote: Hi all, What's the best way to find an element into an array, drop it and shrink the array inplace, in D2? Thanks in advance, Paolo T extract( T )( ref T[] haystack, const T element ) { auto loc = indexOf( haystack, element ); T result = haystack[loc];

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Steven Schveighoffer
On Tue, 07 Sep 2010 09:28:18 -0400, Pelle wrote: On 09/07/2010 03:15 PM, Steven Schveighoffer wrote: On Tue, 07 Sep 2010 08:56:15 -0400, Jacob Carlborg wrote: On 2010-09-07 14:49, Steven Schveighoffer wrote: On Sun, 05 Sep 2010 09:40:59 -0400, BLS wrote: On 05/09/2010 02:16, Jonathan M

Re: Question about typeof(this)

2010-09-07 Thread Don
Jacob Carlborg wrote: I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof where it says: "typeof(this) will generate the type of what this would be in a non-static member function, even if not in a member function. " From that I got the impression that the code below would

Re: Question about typeof(this)

2010-09-07 Thread Stanislav Blinov
07.09.2010 17:00, Jacob Carlborg пишет: I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof where it says: "typeof(this) will generate the type of what this would be in a non-static member function, even if not in a member function. " From that I got the impression that the

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Pelle
On 09/07/2010 04:33 PM, Steven Schveighoffer wrote: Yes, a valid return. Your function should be: void foo(void delegate(const(C) f) const It helps to understand that inout/const/immutable has NOTHING to do with code generation, it only has to do with limiting what compiles. For this reason, an

Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread Tom Kazimiers
Hi, On 09/06/2010 04:55 AM, Jonathan M Davis wrote: > Static arrays are value types, but dynamic arrays are reference types. > > [...] > > No array copying takes place anywhere in that program. If you want to > copy an array, you'd do one of the following > > [...] > > Passing dynamic arrays to fu

Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread Tom Kazimiers
Hi, thanks for your tests. On 09/06/2010 04:59 AM, bearophile wrote: > My first test shows that it may work. But I have to grow the array > backwards, and push back the array start, because that's how my stack > grows (using alloca to allocate geometrically bigger chunks). So > unless you want to

Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread bearophile
Steven Schveighoffer: > Note that the new appender uses heap data to store its implementation, so > it's not as quick as it could be. This is per Andrei's requirement that > it be a reference type. Thank you for your answers. But I don't fully understand your answer. Do you mean it uses the

Re: Pop an element from an array inplace?

2010-09-07 Thread bearophile
Paolo Invernizzi: > What's the best way to find an element into an array, drop it and shrink > the array inplace, in D2? Inside the module std.array there is a commented out function that allows to remove items. I don't know why it is commented out, maybe there is some bug. You can find the in

Input Scanning

2010-09-07 Thread Max Mayrhofer
Hi all, I have what is I suspect a silly question, but I am having a total brainfart over this for some reason. I want to read an arbitrary amount of floats from user input and then perform some statistics work on them. For some reason, I can't figure out how to get it to recognise when the user h

DMD2 does not link on windows 7-64bit

2010-09-07 Thread %u
I get the following strange message when linking: == http://www.digitalmars.com/ctg/optlink.html OPTLINK : Warning 23: No Stack first.obj(first) Error 42: Symbol Undefined _D3std5stdio6stdoutS3std5stdio4File first.obj(first) Error 42: Symbol Undefin

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Steven Schveighoffer
On Tue, 07 Sep 2010 11:37:20 -0400, Pelle wrote: On 09/07/2010 04:33 PM, Steven Schveighoffer wrote: Yes, a valid return. Your function should be: void foo(void delegate(const(C) f) const It helps to understand that inout/const/immutable has NOTHING to do with code generation, it only has to

Re: DMD2 does not link on windows 7-64bit

2010-09-07 Thread OK
To answer my own post : the problems vanish when I add a main() method. question : how do I automagically add a standard main method ? regards, Oliver

Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread Steven Schveighoffer
On Tue, 07 Sep 2010 12:54:52 -0400, bearophile wrote: Steven Schveighoffer: Note that the new appender uses heap data to store its implementation, so it's not as quick as it could be. This is per Andrei's requirement that it be a reference type. Thank you for your answers. But I don't f

Loading a C/C++ dll

2010-09-07 Thread OK
Hello again, I know the extern(C) mechanism, but how do I actually load a C-dll such that my D-program has access to the functions of the C/C++ dll. regards, Oliver

Re: Question about typeof(this)

2010-09-07 Thread Jacob Carlborg
On 2010-09-07 17:29, Don wrote: Jacob Carlborg wrote: I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof where it says: "typeof(this) will generate the type of what this would be in a non-static member function, even if not in a member function. " From that I got the impressi

Re: forks/pipes and std.socket

2010-09-07 Thread Kagamin
Nick Sabalausky Wrote: > Does anyone who's done this sort of thing in D before, on Win or Lin, know > of anything else in particular to be aware of? There's no fork on windows. If you want a multithreaded server, it's usually implemented with threads on windows.

Re: Question about typeof(this)

2010-09-07 Thread Jacob Carlborg
On 2010-09-07 17:34, Stanislav Blinov wrote: 07.09.2010 17:00, Jacob Carlborg пишет: I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof where it says: "typeof(this) will generate the type of what this would be in a non-static member function, even if not in a member function.

Re: Loading a C/C++ dll

2010-09-07 Thread Kagamin
OK Wrote: > I know the extern(C) mechanism, but how do I actually load a C-dll > such that my D-program has access to the functions of the C/C++ dll. > You just link to it, system loader will do actual loading for you automatically.

Re: Generic collection/element function signatures in D2 versus D1

2010-09-07 Thread Jacob Carlborg
On 2010-09-07 17:37, Pelle wrote: On 09/07/2010 04:33 PM, Steven Schveighoffer wrote: Yes, a valid return. Your function should be: void foo(void delegate(const(C) f) const It helps to understand that inout/const/immutable has NOTHING to do with code generation, it only has to do with limiting

Re: forks/pipes and std.socket

2010-09-07 Thread Nick Sabalausky
"Kagamin" wrote in message news:i660qi$nu...@digitalmars.com... > Nick Sabalausky Wrote: > >> Does anyone who's done this sort of thing in D before, on Win or Lin, >> know >> of anything else in particular to be aware of? > > There's no fork on windows. If you want a multithreaded server, it's

Re: DMD2 does not link on windows 7-64bit

2010-09-07 Thread Mike Chaten
If you are trying to compile a library, add -lib to make it not require a main method. On Tue, Sep 7, 2010 at 2:12 PM, OK wrote: > To answer my own post : > the problems vanish when I add a main() method. > question : how do I automagically add a standard main method ? > > regards, Oliver >

How to properly link with a windws .lib file

2010-09-07 Thread OK
hello, now I have written some code in first.d and added some extern(C) functions in externs.d. How do I compile and link everything with extern.lib ? regards, Oliver

Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread bearophile
Steven Schveighoffer: > An appender is an ouput range, so passing it into a function so the > function can output to it is a requirement. I see, that's useful. I will write a Pimp-less version of it, then (when I don't need a range, but just a local accumulator). Thank you for your always gent

Re: How to properly link with a windws .lib file

2010-09-07 Thread Stanislav Blinov
OK wrote: hello, now I have written some code in first.d and added some extern(C) functions in externs.d. How do I compile and link everything with extern.lib ? regards, Oliver Recently there was a pretty thorough discussion about this: http://www.digitalmars.com/d/archives/digitalmars/D/lea

Re: Question about typeof(this)

2010-09-07 Thread Stanislav Blinov
Jacob Carlborg wrote: On 2010-09-07 17:34, Stanislav Blinov wrote: 07.09.2010 17:00, Jacob Carlborg пишет: I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof where it says: "typeof(this) will generate the type of what this would be in a non-static member function, even if not

Re: forks/pipes and std.socket

2010-09-07 Thread Steven Schveighoffer
On Tue, 07 Sep 2010 14:54:46 -0400, Nick Sabalausky wrote: "Kagamin" wrote in message news:i660qi$nu...@digitalmars.com... Nick Sabalausky Wrote: Does anyone who's done this sort of thing in D before, on Win or Lin, know of anything else in particular to be aware of? There's no fork on wi

Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread bearophile
> Beware of stack overflows. And you may add another runtime test to see in what direction the stack grows. Bye, bearophile

Re: Fast temporary dynamic arrays? (And slicing of them)

2010-09-07 Thread bearophile
Tom Kazimiers: > But good to know that it would work with backward growing of the > array - do have you an example of that? Just created: import std.stdio: writeln; import std.c.stdlib: alloca; void main() { int n = 30; alias int T; enum int initialCapacity = 4; static assert(in

Re: Question about typeof(this)

2010-09-07 Thread Don
Jacob Carlborg wrote: On 2010-09-07 17:29, Don wrote: Jacob Carlborg wrote: I'm reading http://www.digitalmars.com/d/2.0/declaration.html#Typeof where it says: "typeof(this) will generate the type of what this would be in a non-static member function, even if not in a member function. " From

Re: forks/pipes and std.socket

2010-09-07 Thread Nick Sabalausky
"Steven Schveighoffer" wrote in message news:op.vioibdr2eav...@localhost.localdomain... > On Tue, 07 Sep 2010 14:54:46 -0400, Nick Sabalausky wrote: > >> "Kagamin" wrote in message >> news:i660qi$nu...@digitalmars.com... >>> Nick Sabalausky Wrote: >>> Does anyone who's done this sort of th

linking works with windows Dll, but access violations occur

2010-09-07 Thread OK
Hello, I followed the recommended threads on linking windows Dlls Using the described tool "coffimplib" I was able to link to executables. However, sometimes when using function from the windows library I get : object.Error: Access Violation during execution. Is this problem known to someone and

How to link in a lib on cmd line?

2010-09-07 Thread Nick Sabalausky
I've tried all sorts of stuff and looked all over, but I'm completely at a loss. How do I link in a static lib on the command line?

Re: Input Scanning

2010-09-07 Thread Jonathan M Davis
On Tuesday 07 September 2010 09:55:29 Max Mayrhofer wrote: > Hi all, I have what is I suspect a silly question, but I am having a > total brainfart over this for some reason. I want to read an > arbitrary amount of floats from user input and then perform some > statistics work on them. For some re

Re: How to link in a lib on cmd line?

2010-09-07 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:i66oia$25s...@digitalmars.com... > I've tried all sorts of stuff and looked all over, but I'm completely at a > loss. How do I link in a static lib on the command line? And I don't mean "with C" or anything like that, just ordinary D. > type main.d modul

Re: How to link in a lib on cmd line?

2010-09-07 Thread Jonathan M Davis
On Tuesday 07 September 2010 18:23:59 Nick Sabalausky wrote: > I've tried all sorts of stuff and looked all over, but I'm completely at a > loss. How do I link in a static lib on the command line? Don't you just include it as one of the arguments, like all of the .d files? I don't know. I haven't

Re: How to link in a lib on cmd line?

2010-09-07 Thread Nick Sabalausky
"Jonathan M Davis" wrote in message news:mailman.129.1283909879.858.digitalmars-d-le...@puremagic.com... > On Tuesday 07 September 2010 18:23:59 Nick Sabalausky wrote: >> I've tried all sorts of stuff and looked all over, but I'm completely at >> a >> loss. How do I link in a static lib on the c

An array()/map inlining problem

2010-09-07 Thread bearophile
This is interesting, if you compile it with: dmd test.d It works. If you compile it with: dmd -inline test.d It doesn't compile and dmd returns: test.d(5): Error: function D main is a nested function and cannot be accessed from array import std.algorithm: map; import std.array: array; void main(

Re: An array()/map inlining problem

2010-09-07 Thread Jonathan M Davis
On Tuesday 07 September 2010 19:58:01 bearophile wrote: > This is interesting, if you compile it with: > dmd test.d > It works. If you compile it with: > dmd -inline test.d > It doesn't compile and dmd returns: > test.d(5): Error: function D main is a nested function and cannot be > accessed from a

Re: Input Scanning

2010-09-07 Thread Max Mayrhofer
Yea of course that does make sense, there ya go :)

Re: linking works with windows Dll, but access violations occur

2010-09-07 Thread Kagamin
You probably mess calling convention.