Re: std.algorithm.remove strange behavior (removing items for the dynamic array)

2012-05-11 Thread Jacob Carlborg
On 2012-05-11 05:18, Jonathan M Davis wrote: ...and got the following output: a before: [2, 4, 8, 16, 32, 64, 128] a after : [2, 4, 8, 32, 64, 128, 128] a after2: [2, 8, 32, 64, 128, 128, 128] I'm confused. Please tell me is it normal behavior of this function or is it a bug? Maybe i'm doing

Re: std.algorithm.remove strange behavior (removing items for the dynamic array)

2012-05-11 Thread Jonathan M Davis
On Friday, May 11, 2012 08:15:45 Jacob Carlborg wrote: On 2012-05-11 05:18, Jonathan M Davis wrote: ...and got the following output: a before: [2, 4, 8, 16, 32, 64, 128] a after : [2, 4, 8, 32, 64, 128, 128] a after2: [2, 8, 32, 64, 128, 128, 128] I'm confused. Please tell

Re: std.algorithm.remove strange behavior (removing items for the dynamic array)

2012-05-11 Thread Jacob Carlborg
On 2012-05-11 08:24, Jonathan M Davis wrote: On Friday, May 11, 2012 08:15:45 Jacob Carlborg wrote: Is it supposed to change the underlying array like that? It doesn't print the original sequence. Yes. To remove an element, it shifts all of the elements to the right of that element over by

Re: Make all functions from std.typecons Proxy inout

2012-05-11 Thread Kenji Hara
On Thursday, 10 May 2012 at 07:32:42 UTC, Namespace wrote: Can you explain me how TemplateThisParameter works? I read in the manual but a more detail explanation would help me a lot. Hmm, I have thought following code should work about foo, but doesn't. import std.stdio; struct Proxy {

Re: foreach_reverse error

2012-05-11 Thread mta`chrono
group returns a lazy forward range. use foreach(i; group(retro(ints))) Yet another reason foreach_reverse needs to go. T No please don't! There are hundred and ten very usefull cases.

Re: Make all functions from std.typecons Proxy inout

2012-05-11 Thread sclytrack
struct S { void f() {} void f() const{} void f() immutable {} void f() shared {} void f() shared const {} } struct Proxy(T) { T o; I'm new to the concept of shared const. What is the difference when comparing to immutable?

Re: Make all functions from std.typecons Proxy inout

2012-05-11 Thread sclytrack
On 05/11/2012 11:51 AM, sclytrack wrote: struct S { void f() {} void f() const{} void f() immutable {} void f() shared {} void f() shared const {} } struct Proxy(T) { T o; I'm new to the concept of shared const. What is the difference when comparing to immutable? And to answer myself.

Re: [Derelict2] Code SOMETIMES seg. faults!

2012-05-11 Thread David
When unloading SDL manually, you should disable the auto-unloading of Derelict. http://www.dsource.org/forums/viewtopic.php?t=6173

Re: Make all functions from std.typecons Proxy inout

2012-05-11 Thread sclytrack
import std.stdio; void test1(shared const float [] p) { writeln(works); } Nope, shared const still doesn't make sense to me. In the above example the p values can still change at any time. Why does shared const even exist?

Re: foreach_reverse error

2012-05-11 Thread Steven Schveighoffer
On Fri, 11 May 2012 03:43:53 -0400, mta`chrono chr...@mta-international.net wrote: group returns a lazy forward range. use foreach(i; group(retro(ints))) Yet another reason foreach_reverse needs to go. T No please don't! There are hundred and ten very usefull cases. No, there is only

Re: Make all functions from std.typecons Proxy inout

2012-05-11 Thread Steven Schveighoffer
On Fri, 11 May 2012 08:05:33 -0400, sclytrack sclytr...@iq87.fr wrote: import std.stdio; void test1(shared const float [] p) { writeln(works); } Nope, shared const still doesn't make sense to me. In the above example the p values can still change at any time. Why does shared const even

Re: Make all functions from std.typecons Proxy inout

2012-05-11 Thread Timon Gehr
On 05/11/2012 08:56 AM, Kenji Hara wrote: The spec: http://dlang.org/template#TemplateThisParameter doesn't talk about typeof(this). I think current behavior is less useful than I have thought. What would the current behavior be useful for? And, current std.typecons.Proxy doesn't work as

std.concurrency and module constructors

2012-05-11 Thread japplegame
OS: Windows 7 64bit Compiler: DMD32 D Compiler v2.059 Using spawn in module constructor causes very strange behavior. import std.concurrency; import std.stdio; void main() { } void worker() { receiveOnly!OwnerTerminated; } static this() { writeln(module constructor); spawn(worker); }

Re: std.concurrency and module constructors

2012-05-11 Thread japplegame
Thank you. Solution is: shared static this() { ... } or avoid any global things :)

Re: std.concurrency and module constructors

2012-05-11 Thread sclytrack
On 05/11/2012 03:44 PM, japplegame wrote: Thank you. Solution is: shared static this() { ... } or avoid any global things :) And I learned something new today. :-)

Read Complete File to Array of Lines

2012-05-11 Thread Paul
I would like to read a complete file in one statement and then process it line by line. foreach (line; MyFile) etc. Is it possible to read a file into and array of lines? Thanks

Re: Detect unused variables

2012-05-11 Thread Namespace
No interest, I see. I improved the code again. Now, even user-defined types, and (associative) arrays detected. I'm sure there are a lot of situations where my code will fail, but I will continue working on it. Therefore criticisms and suggestions were really helpful. The new code:

Re: Read Complete File to Array of Lines

2012-05-11 Thread sclytrack
On 05/11/2012 05:00 PM, Paul wrote: I would like to read a complete file in one statement and then process it line by line. foreach (line; MyFile) etc. Is it possible to read a file into and array of lines? Thanks ---SOURCE import std.stdio; import std.file; int main() {

Re: Read Complete File to Array of Lines

2012-05-11 Thread H. S. Teoh
On Fri, May 11, 2012 at 05:00:16PM +0200, Paul wrote: I would like to read a complete file in one statement and then process it line by line. foreach (line; MyFile) etc. Is it possible to read a file into and array of lines? import std.array; import std.stdio; string[] getLines(File f)

Re: [Derelict2] Code SOMETIMES seg. faults!

2012-05-11 Thread Andrej Mitrovic
On 5/10/12, Minas minas_mina1...@hotmail.co.uk wrote: But sometimes (at about 3-5 runs), I get a segmentation fault! Long shot but: I've had crashes before when using write calls in an app that doesn't spawn a console window. What happened was stdout/stderr wasn't opened, so to fix that I'd have

Re: Read Complete File to Array of Lines

2012-05-11 Thread Graham Fawcett
On Friday, 11 May 2012 at 15:18:11 UTC, H. S. Teoh wrote: On Fri, May 11, 2012 at 05:00:16PM +0200, Paul wrote: I would like to read a complete file in one statement and then process it line by line. foreach (line; MyFile) etc. Is it possible to read a file into and array of lines? import

Re: Read Complete File to Array of Lines

2012-05-11 Thread Jesse Phillips
On Friday, 11 May 2012 at 15:00:18 UTC, Paul wrote: I would like to read a complete file in one statement and then process it line by line. foreach (line; MyFile) etc. Is it possible to read a file into and array of lines? Thanks Something like: import std.file; import std.string; void

Re: Read Complete File to Array of Lines

2012-05-11 Thread Graham Fawcett
On Friday, 11 May 2012 at 15:00:18 UTC, Paul wrote: I would like to read a complete file in one statement and then process it line by line. foreach (line; MyFile) etc. Is it possible to read a file into and array of lines? Thanks If you use the byLine approach... foreach(line;

Re: Read Complete File to Array of Lines

2012-05-11 Thread Steven Schveighoffer
On Fri, 11 May 2012 11:00:16 -0400, Paul phshaf...@gmail.com wrote: I would like to read a complete file in one statement and then process it line by line. foreach (line; MyFile) etc. Is it possible to read a file into and array of lines? Thanks Would something like this work? auto arr =

Re: Runtime.loadLibrary() on Linux

2012-05-11 Thread Alex Rønne Petersen
On 11-05-2012 20:46, Sean Kelly wrote: On Thursday, 10 May 2012 at 07:09:43 UTC, F i L wrote: Is it possible? I get a message rt_loadLibrary() not supported on Posix when I try. Is there something I'm doing wrong or is loading shared libraries not supported at all on Linux systems? It should

Re: Read Complete File to Array of Lines

2012-05-11 Thread Graham Fawcett
On Friday, 11 May 2012 at 18:57:52 UTC, Steven Schveighoffer wrote: On Fri, 11 May 2012 11:00:16 -0400, Paul phshaf...@gmail.com wrote: I would like to read a complete file in one statement and then process it line by line. foreach (line; MyFile) etc. Is it possible to read a file into and

Re: Read Complete File to Array of Lines

2012-05-11 Thread Era Scarecrow
On Friday, 11 May 2012 at 19:24:49 UTC, Graham Fawcett wrote: It sure would. I suspect that Jesse's approach... readText(file.in).splitLines() ...would be the most efficient way if you need an actual array: slurp the whole file at once, then create an array of memory-sharing slices.

Re: Read Complete File to Array of Lines

2012-05-11 Thread Graham Fawcett
On Friday, 11 May 2012 at 20:06:45 UTC, Era Scarecrow wrote: On Friday, 11 May 2012 at 19:24:49 UTC, Graham Fawcett wrote: It sure would. I suspect that Jesse's approach... readText(file.in).splitLines() ...would be the most efficient way if you need an actual array: slurp the whole file at

Re: Read Complete File to Array of Lines

2012-05-11 Thread Paul
On Friday, 11 May 2012 at 19:24:49 UTC, Graham Fawcett wrote: On Friday, 11 May 2012 at 18:57:52 UTC, Steven Schveighoffer wrote: On Fri, 11 May 2012 11:00:16 -0400, Paul phshaf...@gmail.com wrote: I would like to read a complete file in one statement and then process it line by line.

Re: Read Complete File to Array of Lines

2012-05-11 Thread Paul
On Friday, 11 May 2012 at 18:02:54 UTC, Jesse Phillips wrote: On Friday, 11 May 2012 at 15:00:18 UTC, Paul wrote: I would like to read a complete file in one statement and then process it line by line. foreach (line; MyFile) etc. Is it possible to read a file into and array of lines? Thanks

Re: Runtime.loadLibrary() on Linux

2012-05-11 Thread F i L
Sean Kelly wrote: It should be made to work on Linux. Interested in submitting a pull request? The function is in src/rt/dmain2.d. alexrp beat me to it: https://github.com/D-Programming-Language/dmd/pull/941 https://github.com/D-Programming-Language/druntime/pull/211

Assigning value to a lazy parameter in a function call

2012-05-11 Thread Vidar Wahlberg
Wasn't easy to find a short good description of the issue in the subject, but here's some code to illustrate my concern: --- import std.stdio; void log(T...)(lazy string message, lazy T t) { debug writefln(message, t); } void main() { int a = 42; writefln(The meaning of

What is a good strategy for finding undefined symbols...

2012-05-11 Thread WhatMeWorry
I've been trying to compile the DerelictGL and finally got it to compile cleanly. But now the linker is complaining. I've been searching for hours for these definitions and I feel like I've just been going around in circles. What is a novice to do? Is this just something I am supposed to

Re: Assigning value to a lazy parameter in a function call

2012-05-11 Thread Chris Cain
On Friday, 11 May 2012 at 20:45:53 UTC, Vidar Wahlberg wrote: I often call functions where one of the parameters may be an integer which i post/pre increment/decrement. However, that can be quite risky if the parameter is defined as lazy as shown above. The value of a above after calling log

Re: Read Complete File to Array of Lines

2012-05-11 Thread Paul
On Friday, 11 May 2012 at 20:43:47 UTC, Era Scarecrow wrote: On Friday, 11 May 2012 at 20:40:23 UTC, Paul wrote: On Friday, 11 May 2012 at 18:02:54 UTC, Jesse Phillips wrote: void main() { foreach(line; readText(file.in).splitLines()) ... } Thanks Jesse. I'm finding that I can't just

Re: Read Complete File to Array of Lines

2012-05-11 Thread Era Scarecrow
On Friday, 11 May 2012 at 21:13:41 UTC, Paul wrote: std.utf.UTFException@std\utf.d(644): Invalid UTF-8 sequence (at index 1) What are you reading? If it's regular text (0-127) then you shouldn't have an issue. However 128-255 (or, -1 to -127) are treated differently. D by default is UTF-8 or

Re: Assigning value to a lazy parameter in a function call

2012-05-11 Thread Vidar Wahlberg
On 2012-05-11 23:03, Chris Cain wrote: On Friday, 11 May 2012 at 20:45:53 UTC, Vidar Wahlberg wrote: Perhaps the compiler should print out a warning when you're assigning a value to a lazy parameter in a function call? The entire point of a lazy parameter is to not be calculated/processed

Re: Assigning value to a lazy parameter in a function call

2012-05-11 Thread Jonathan M Davis
On Friday, May 11, 2012 23:39:44 Vidar Wahlberg wrote: On 2012-05-11 23:03, Chris Cain wrote: On Friday, 11 May 2012 at 20:45:53 UTC, Vidar Wahlberg wrote: Perhaps the compiler should print out a warning when you're assigning a value to a lazy parameter in a function call? The entire

Re: Assigning value to a lazy parameter in a function call

2012-05-11 Thread Chris Cain
On Friday, 11 May 2012 at 21:39:57 UTC, Vidar Wahlberg wrote: I'm not suggesting that the compiler should print a warning if you're doing a calculation in the function call, I'm suggesting it should give you a warning if you're assigning the result of the calculation to a variable in the

Re: What is a good strategy for finding undefined symbols...

2012-05-11 Thread Sean Kelly
On May 11, 2012, at 1:56 PM, WhatMeWorry wrote: I've been trying to compile the DerelictGL and finally got it to compile cleanly. But now the linker is complaining. I've been searching for hours for these definitions and I feel like I've just been going around in circles. What is a

Re: Assigning value to a lazy parameter in a function call

2012-05-11 Thread Vidar Wahlberg
On 2012-05-12 00:27, Chris Cain wrote: [...] Thank you for the detailed answer. I still suspect this can fool some people, and (in my ignorance) I couldn't (and still can't, to be honest) really see when you would want to assign a variable in a lazy parameter, I would expect that to be far

Re: Assigning value to a lazy parameter in a function call

2012-05-11 Thread Chris Cain
On Friday, 11 May 2012 at 23:07:31 UTC, Vidar Wahlberg wrote: Thank you for the detailed answer. I still suspect this can fool some people, and (in my ignorance) I couldn't (and still can't, to be honest) really see when you would want to assign a variable in a lazy parameter, I would expect