std.file.readText() extra Line Feed character

2014-12-18 Thread Colin via Digitalmars-d-learn
Why does std.file.readText() append a Line Feed char onto the end of the string? I have a file with the following contents in it: Name = Int Other=Float One More = String(Random;) I then have the code: void main(string[] args){ const text = Name = Int

Re: std.file.readText() extra Line Feed character

2014-12-18 Thread ketmar via Digitalmars-d-learn
On Thu, 18 Dec 2014 09:18:35 + Colin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Why does std.file.readText() append a Line Feed char onto the end of the string? I have a file with the following contents in it: Name = Int Other=Float One More =

Re: std.file.readText() extra Line Feed character

2014-12-18 Thread Colin via Digitalmars-d-learn
On Thursday, 18 December 2014 at 09:25:47 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 18 Dec 2014 09:18:35 + Colin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Why does std.file.readText() append a Line Feed char onto the end of the string? I have a file with

Re: std.file.readText() extra Line Feed character

2014-12-18 Thread yazd via Digitalmars-d-learn
On Thursday, 18 December 2014 at 10:16:38 UTC, Colin wrote: On Thursday, 18 December 2014 at 09:25:47 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 18 Dec 2014 09:18:35 + Colin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Why does std.file.readText() append a

Re: std.file.readText() extra Line Feed character

2014-12-18 Thread Colin via Digitalmars-d-learn
On Thursday, 18 December 2014 at 10:43:32 UTC, yazd wrote: On Thursday, 18 December 2014 at 10:16:38 UTC, Colin wrote: On Thursday, 18 December 2014 at 09:25:47 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 18 Dec 2014 09:18:35 + Colin via Digitalmars-d-learn

Re: core.bitop.bt not faster than ?

2014-12-18 Thread Dicebot via Digitalmars-d-learn
Having quick read through the http://en.wikipedia.org/wiki/Word_%28computer_architecture%29 may help re-calibrating the way you thing about bit operations and optimization.

Re: Check type is a struct at compile time?

2014-12-18 Thread shona123 via Digitalmars-d-learn
But how to do the same thing for a struct? _ dhoom

Re: Derelict SDL2 library not loading on OS X

2014-12-18 Thread Mike Parker via Digitalmars-d-learn
On 12/18/2014 3:29 PM, Joel wrote: I've installed SDL2. Joels-MacBook-Pro:DerelictTest joelcnz$ cat test.d import derelict.sdl2.sdl; int main() { DerelictSDL2.load(); } Joels-MacBook-Pro:DerelictTest joelcnz$ dmd test libDerelictSDL2.a libDerelictUtil.a Joels-MacBook-Pro:DerelictTest

Re: std.file.readText() extra Line Feed character

2014-12-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 18 December 2014 at 09:18:36 UTC, Colin wrote: I don't think it's my editor adding chars to the end of the file, as I'm using vi. :-) vim actually does it by default. Check out :help eol from inside it. I think other vi clones do it too but I'm not sure, but I know vim has it

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/17/14 6:15 AM, zeljkog wrote: On 15.12.14 01:00, Nordlöw wrote: Isn't this algorithm already encoded somewhere in Phobos? void append(T, Args...)(ref T[] arr, auto ref Args args){ { static if (args.length == 1) arr ~= args[0]; // inlined else{ arr.length +=

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-18 Thread Nordlöw
On Wednesday, 17 December 2014 at 12:30:37 UTC, Tobias Pankrath wrote: void append(T, Args...)(ref T[] arr, auto ref Args args){ { static if (args.length == 1) arr ~= args[0]; // inlined else{ arr.length += args.length; foreach(i, e; args) arr[$ - args.length + i]

Why do std.traits use template foo(args...) instead of foo(alias arg) ?

2014-12-18 Thread Mathias LANG via Digitalmars-d-learn
An exemple being fullyQualifiedName: https://github.com/D-Programming-Language/phobos/blob/master/std/traits.d#L415 I don't get this pattern. Is it documented somewhere ?

Re: Why do std.traits use template foo(args...) instead of foo(alias arg) ?

2014-12-18 Thread Low Functioning via Digitalmars-d-learn
On Thursday, 18 December 2014 at 15:48:02 UTC, Mathias LANG wrote: An exemple being fullyQualifiedName: https://github.com/D-Programming-Language/phobos/blob/master/std/traits.d#L415 I don't get this pattern. Is it documented somewhere ? http://dlang.org/variadic-function-templates.html

Re: Why do std.traits use template foo(args...) instead of foo(alias arg) ?

2014-12-18 Thread Dicebot via Digitalmars-d-learn
On Thursday, 18 December 2014 at 15:48:02 UTC, Mathias LANG wrote: An exemple being fullyQualifiedName: https://github.com/D-Programming-Language/phobos/blob/master/std/traits.d#L415 I don't get this pattern. Is it documented somewhere ? Full pattern looks like this: template foo(T...)

Re: Why do std.traits use template foo(args...) instead of foo(alias arg) ?

2014-12-18 Thread ketmar via Digitalmars-d-learn
On Thu, 18 Dec 2014 15:52:06 + Low Functioning via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 18 December 2014 at 15:48:02 UTC, Mathias LANG wrote: An exemple being fullyQualifiedName:

Re: Why do std.traits use template foo(args...) instead of foo(alias arg) ?

2014-12-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/18/14 11:21 AM, ketmar via Digitalmars-d-learn wrote: On Thu, 18 Dec 2014 15:52:06 + Low Functioning via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Thursday, 18 December 2014 at 15:48:02 UTC, Mathias LANG wrote: An exemple being fullyQualifiedName:

Re: Why do std.traits use template foo(args...) instead of foo(alias arg) ?

2014-12-18 Thread ketmar via Digitalmars-d-learn
On Thu, 18 Dec 2014 11:26:20 -0500 Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 12/18/14 11:21 AM, ketmar via Digitalmars-d-learn wrote: On Thu, 18 Dec 2014 15:52:06 + Low Functioning via Digitalmars-d-learn digitalmars-d-learn@puremagic.com

Re: Why do std.traits use template foo(args...) instead of foo(alias arg) ?

2014-12-18 Thread Mathias LANG via Digitalmars-d-learn
On Thursday, 18 December 2014 at 16:10:31 UTC, Dicebot wrote: On Thursday, 18 December 2014 at 15:48:02 UTC, Mathias LANG wrote: An exemple being fullyQualifiedName: https://github.com/D-Programming-Language/phobos/blob/master/std/traits.d#L415 I don't get this pattern. Is it documented

Re: Why do std.traits use template foo(args...) instead of foo(alias arg) ?

2014-12-18 Thread Dicebot via Digitalmars-d-learn
On Thursday, 18 December 2014 at 17:20:28 UTC, Mathias LANG wrote: Thanks for the precision. Is it something that is going to be fixed, or is it by design ? It is something that most likely would have been designed differently if we had another chance (aka D3) but unlikely to change in D2 as

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-18 Thread Tobias Pankrath via Digitalmars-d-learn
On Thursday, 18 December 2014 at 15:12:39 UTC, Nordlöw wrote: On Wednesday, 17 December 2014 at 12:30:37 UTC, Tobias Pankrath wrote: void append(T, Args...)(ref T[] arr, auto ref Args args){ { static if (args.length == 1) arr ~= args[0]; // inlined else{ arr.length += args.length;

PyD-like wrapping for Excel/VBA and Julia?

2014-12-18 Thread Laeeth Isharc via Digitalmars-d-learn
I have a bunch of D functions I would like to make available to Excel (and possibly Julia) without having to write wrappers for each function individually. For Excel, I think one needs two levels of wrapper - one is to create a C style interface [using extern(Windows) calling convention, and

Re: std.file.readText() extra Line Feed character

2014-12-18 Thread Ali Çehreli via Digitalmars-d-learn
On 12/18/2014 02:51 AM, Colin wrote: vi, and it does indeed have a '\n' at the end of file. Ah, I see. That's a little annoying. It looks like there are ways of dealing with it: http://stackoverflow.com/questions/1050640/vim-disable-automatic-newline-at-end-of-file Ali happy with Emacs

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-18 Thread zeljkog via Digitalmars-d-learn
On 18.12.14 14:50, Steven Schveighoffer wrote: I wonder how your code compares to this: void append(T)(ref T[] arr, T[] args...) { arr ~= args; } This is ~20% slower for ints, but it difference increases for bigger structs.

Re: Derelict SDL2 library not loading on OS X

2014-12-18 Thread Joel via Digitalmars-d-learn
[snip] Failed to load one or more shared libraries: After that last colon, you should be seeing a list of library names that failed to load. Did you somehow fail to copy/paste it or is it really missing? Yes, there was something wrong there, here's another go: Joels-MBP:test joelcnz$ dmd

Re: PyD-like wrapping for Excel/VBA and Julia?

2014-12-18 Thread Ellery Newcomer via Digitalmars-d-learn
On 12/18/2014 12:41 PM, Laeeth Isharc wrote: I have a bunch of D functions I would like to make available to Excel (and possibly Julia) without having to write wrappers for each function individually. I've thought about refactoring the reflection parts of pyd into a reusable library for e.g.

Memoizing methods

2014-12-18 Thread kyle via Digitalmars-d-learn
If you memoize a method inside a class definition using std.functional.memoize is caching done in a per-object manner, or do all objects of this class share cached return values? Thank you.

Re: Derelict SDL2 library not loading on OS X

2014-12-18 Thread Mike Parker via Digitalmars-d-learn
On 12/19/2014 9:58 AM, Joel wrote: [snip] derelict.util.exception.SymbolLoadException@derelict/util/exception.d(35): Failed to load symbol SDL_free from shared library /usr/local/lib/libSDL2.dylib OK, the loader is finding libSDL2.dylib in /usr/local/lib where it expects it to be. Your

BigInt and

2014-12-18 Thread Andre via Digitalmars-d-learn
Hi, I try to translate following javascript coding to D: i = buffer[2] 16; i |= buffer[1] 8; i |= buffer[0]; i += buffer[3] 24 0; Buffer is: [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 111] Expected result for i is: 4294967295 But in D the last statement