Re: Create D portable binary

2017-12-08 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 8 December 2017 at 06:37:36 UTC, Adam D. Ruppe wrote: On Friday, 8 December 2017 at 05:16:22 UTC, Fra Mecca wrote: Is there a way to compile a project and deploying it as a single statically linked binary? A default build of a D program is *reasonably* compatible. All its

Re: Check whether a file is empty.

2017-12-08 Thread FreeSlave via Digitalmars-d-learn
On Friday, 8 December 2017 at 09:40:18 UTC, Vino wrote: Hi All, Request your help on how to check whether a given file is empty, I tried the getSize from std.file but no luck as in windows 7 is the file is empty the size of the file is 0 bytes but in Windows 2003 if the file is empty the

Re: Binary serialization of a struct

2017-12-08 Thread Cym13 via Digitalmars-d-learn
On Saturday, 16 September 2017 at 13:15:54 UTC, Azi Hassan wrote: On Saturday, 16 September 2017 at 03:30:51 UTC, Joseph wrote: Are there any simple direct serialization libraries where I can mark elements of a class or struct that I want serialized with an attribute and it will take care of

Re: Create D portable binary

2017-12-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-08 06:16, Fra Mecca wrote: Is there a way to compile a project and deploying it as a single statically linked binary? My main target would be something like a self contained jar (like .war files), but something that is in the style of go binaries and portable to another Linux

Check whether a file is empty.

2017-12-08 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on how to check whether a given file is empty, I tried the getSize from std.file but no luck as in windows 7 is the file is empty the size of the file is 0 bytes but in Windows 2003 if the file is empty the size of the file show as 2 bytes. From, Vino.B

Re: Parallel reads on std.container.array.Array

2017-12-08 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 8 December 2017 at 07:34:53 UTC, Arun Chandrasekaran wrote: I was wondering if std.container.array.Array supports threadsafe parallel reads similar to std::vector. I've created a small program for demonstration https://github.com/carun/parallel-read-tester It works fine with just

Re: Parallel reads on std.container.array.Array

2017-12-08 Thread Kagamin via Digitalmars-d-learn
On Friday, 8 December 2017 at 07:34:53 UTC, Arun Chandrasekaran wrote: I was wondering if std.container.array.Array supports threadsafe parallel reads similar to std::vector. No, your code can also fail on a system with inconsistent cache because data written by writing thread can remain in

Re: Parallel reads on std.container.array.Array

2017-12-08 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 8 December 2017 at 10:01:14 UTC, Kagamin wrote: On Friday, 8 December 2017 at 07:34:53 UTC, Arun Chandrasekaran wrote: I was wondering if std.container.array.Array supports threadsafe parallel reads similar to std::vector. No, your code can also fail on a system with inconsistent

Re: Binary serialization of a struct

2017-12-08 Thread Daniel Kozak via Digitalmars-d-learn
You should use size_t instead of ulong, but on 32bit you would have still problem because you are trying assign 2^32 which is too big to hold in 32bit On Thu, Dec 7, 2017 at 11:42 PM, kdevel via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Tuesday, 19 September 2017 at

Re: Parallel reads on std.container.array.Array

2017-12-08 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 8 December 2017 at 07:34:53 UTC, Arun Chandrasekaran wrote: 2. I'm on an 8 CPU box and I don't seem to hit 800% CPU with D version (max 720%). However I can get 800% CPU usage with the C++ version. Please ignore, this is because of the write.

Re: Check whether a file is empty.

2017-12-08 Thread Kagamin via Digitalmars-d-learn
Other functions that can be used for this are GetFileInformationByHandle, GetFileSizeEx, SetFilePointerEx or File.size in phobos.

Re: Create D portable binary

2017-12-08 Thread Cym13 via Digitalmars-d-learn
On Friday, 8 December 2017 at 06:37:36 UTC, Adam D. Ruppe wrote: On Friday, 8 December 2017 at 05:16:22 UTC, Fra Mecca wrote: Is there a way to compile a project and deploying it as a single statically linked binary? A default build of a D program is *reasonably* compatible. All its

Re: std.range.interfaces : InputRange moveFront

2017-12-08 Thread Andrei Alexandrescu via Digitalmars-d-learn
On 12/03/2017 12:42 AM, Johan Engelen wrote: On Friday, 1 December 2017 at 18:33:09 UTC, Ali Çehreli wrote: On 12/01/2017 07:21 AM, Steven Schveighoffer wrote: > On 12/1/17 4:29 AM, Johan Engelen wrote: >> (Also, I would expect "popFront" to return the element popped, but it >> doesn't, OK...

Re: Directory Size

2017-12-08 Thread vino via Digitalmars-d-learn
On Thursday, 7 December 2017 at 12:19:00 UTC, Vino wrote: On Thursday, 7 December 2017 at 09:04:19 UTC, Vino wrote: [...] Hi Andrea, Was able to find a solution to the above issue by adding the replace function as below, the the code is working as expected, is there any chance of using

Re: Check whether a file is empty.

2017-12-08 Thread vino via Digitalmars-d-learn
On Friday, 8 December 2017 at 12:25:19 UTC, FreeSlave wrote: On Friday, 8 December 2017 at 09:40:18 UTC, Vino wrote: Hi All, Request your help on how to check whether a given file is empty, I tried the getSize from std.file but no luck as in windows 7 is the file is empty the size of the

Problem with digest Hmac sha256 method and another problem while using openssl hmac

2017-12-08 Thread kerdemdemir via Digitalmars-d-learn
Hi, I need to have the same result while using : openssl dgst -sha256 -hmac "somestring" But the server rejecting my generated hmac with the code below . auto hmac = HMAC!SHA256("somestring".representation); hmac.put(url.representation); auto generatedHmac = hmac.finish(); string

Re: Problem with digest Hmac sha256 method and another problem while using openssl hmac

2017-12-08 Thread Ali Çehreli via Digitalmars-d-learn
On 12/08/2017 01:05 PM, kerdemdemir wrote: > Hi, > > I need to have the same result while using : > > openssl Works for me as adapted from Phobos documentation: import std.stdio; import std.digest.hmac, std.digest.sha; import std.string : representation; void main() { auto hmac =

Sort in return statement

2017-12-08 Thread codephantom via Digitalmars-d-learn
Anyone got ideas on how to get sort() working in the *return* statement? // ushort[] draw8Numbers() { import std.meta : aliasSeqOf; import std.range : iota; ushort[] numbers = [ aliasSeqOf!(iota(1,46)) ]; import std.random : randomShuffle;

Re: Check whether a file is empty.

2017-12-08 Thread codephantom via Digitalmars-d-learn
On Friday, 8 December 2017 at 19:13:20 UTC, vino wrote: Hi, The code is same just copy pasted the code form Windows 7 into Windows 2003 and executed, in Windows 7 the log file is of size 0 where as in windows 2003 the log file is of size 2 byte where the log file in both the server is

Re: Parallel reads on std.container.array.Array

2017-12-08 Thread Arun Chandrasekaran via Digitalmars-d-learn
So I tried the same on Haswell processor with LDC 1.6.0 and it crashes ``` === Starting D version === Took 1 sec, 107 ms, and 383 μs to load 100 items. Gonna search in parallel... *** Error in `./dmain-ldc': double free or corruption (fasttop): 0x00edc6e0 *** *** Error in

Re: Get pointer or reference of an element in Array(struct)

2017-12-08 Thread anonymous via Digitalmars-d-learn
On Saturday, 9 December 2017 at 06:15:16 UTC, Arun Chandrasekaran wrote: Is there a way to get the pointer or reference of an element in Array(T)? [...] auto d2 = gallery[0]; auto d2 = [0];

std.conv.to!string refuses to convert a char* to string.

2017-12-08 Thread Venkat via Digitalmars-d-learn
I am trying out the DJni library (https://github.com/Monnoroch/DJni). For some reason std.conv.to!string doesn't want to convert a char* to a string.The lines below are taken from the log. I see that the last frame is at gc_qalloc. I am not sure why it failed there. Can anybody elaborate on

Re: Sort in return statement

2017-12-08 Thread codephantom via Digitalmars-d-learn
On Saturday, 9 December 2017 at 04:31:33 UTC, SimonN wrote: Yes, this works, and your algorithm would even accept arbitary random-access ranges, not merely arrays. Would be nice if I could do it all as a 'one liner': // int[] draw8Numbers() { import std.algorithm.sorting :

Get pointer or reference of an element in Array(struct)

2017-12-08 Thread Arun Chandrasekaran via Digitalmars-d-learn
Is there a way to get the pointer or reference of an element in Array(T)? https://run.dlang.io/gist/70fd499afe8438d4877f57aec90c3091?compiler=dmd The assertion seems to fail below. Value copy is not is intended here. module test; void main() { struct Data { int id; }

Re: Temporary objects as function parameters or when-is-this-shit-going-to-end?

2017-12-08 Thread Mike Franklin via Digitalmars-d-learn
On Tuesday, 17 October 2017 at 19:00:38 UTC, Steven Schveighoffer wrote: In this case, an extra destructor call is made without a corresponding postblit or constructor. -Steve https://issues.dlang.org/show_bug.cgi?id=18050

Re: Parallel reads on std.container.array.Array

2017-12-08 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Saturday, 9 December 2017 at 01:34:40 UTC, Arun Chandrasekaran wrote: So I tried the same on Haswell processor with LDC 1.6.0 and it crashes ``` === Starting D version === Took 1 sec, 107 ms, and 383 μs to load 100 items. Gonna search in parallel... *** Error in `./dmain-ldc': double

Re: Sort in return statement

2017-12-08 Thread rjframe via Digitalmars-d-learn
On Sat, 09 Dec 2017 02:34:29 +, codephantom wrote: > Anyone got ideas on how to get sort() working in the *return* > statement? > > // > > ushort[] draw8Numbers() > { > import std.meta : aliasSeqOf; > import std.range : iota; > ushort[] numbers = [

Re: Sort in return statement

2017-12-08 Thread codephantom via Digitalmars-d-learn
On Saturday, 9 December 2017 at 02:45:35 UTC, rjframe wrote: `sort` returns a SortedRange of ushorts, not an array of ushorts. Make it: ``` import std.array : array; return sort(numbers.take(8)).array; ``` --Ryan That's it! Thanks Ryan.

Re: std.conv.to!string refuses to convert a char* to string.

2017-12-08 Thread Neia Neutuladh via Digitalmars-d-learn
On Saturday, 9 December 2017 at 05:55:21 UTC, Venkat wrote: I am trying out the DJni library (https://github.com/Monnoroch/DJni). For some reason std.conv.to!string doesn't want to convert a char* to a string.The lines below are taken from the log. I see that the last frame is at gc_qalloc. I

Re: Get pointer or reference of an element in Array(struct)

2017-12-08 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Saturday, 9 December 2017 at 06:38:46 UTC, anonymous wrote: On Saturday, 9 December 2017 at 06:15:16 UTC, Arun Chandrasekaran wrote: Is there a way to get the pointer or reference of an element in Array(T)? [...] auto d2 = gallery[0]; auto d2 = [0]; Thanks. Just curious why

Re: Sort in return statement

2017-12-08 Thread Seb via Digitalmars-d-learn
On Saturday, 9 December 2017 at 02:45:35 UTC, rjframe wrote: On Sat, 09 Dec 2017 02:34:29 +, codephantom wrote: Anyone got ideas on how to get sort() working in the *return* statement? // ushort[] draw8Numbers() { import std.meta : aliasSeqOf; import std.range :

Re: Sort in return statement

2017-12-08 Thread user1234 via Digitalmars-d-learn
On Saturday, 9 December 2017 at 03:24:52 UTC, codephantom wrote: On Saturday, 9 December 2017 at 02:45:35 UTC, rjframe wrote: `sort` returns a SortedRange of ushorts, not an array of ushorts. Make it: ``` import std.array : array; return sort(numbers.take(8)).array; ``` --Ryan That's it!

Re: std.conv.to!string refuses to convert a char* to string.

2017-12-08 Thread Venkat via Digitalmars-d-learn
Thanks for the quick response. std.string.fromStringz did the trick. I am not sure what was the deal with to!string.

Re: Sort in return statement

2017-12-08 Thread SimonN via Digitalmars-d-learn
On Saturday, 9 December 2017 at 03:24:52 UTC, codephantom wrote: On Saturday, 9 December 2017 at 02:45:35 UTC, rjframe wrote: `sort` returns a SortedRange of ushorts, not an array of ushorts. Make it: ``` import std.array : array; return sort(numbers.take(8)).array; ``` --Ryan That's it!

Re: GUI program on Mac OS in D?

2017-12-08 Thread mrphobby via Digitalmars-d-learn
On Thursday, 7 December 2017 at 12:27:36 UTC, Guillaume Piolat wrote: On Thursday, 7 December 2017 at 12:18:21 UTC, Guillaume Piolat wrote: You can easily make a DUB frontend to do that, for example https://github.com/AuburnSounds/Dplug/tree/master/tools/dplug-build And it might be cleaner

Re: GUI program on Mac OS in D?

2017-12-08 Thread mrphobby via Digitalmars-d-learn
On Thursday, 7 December 2017 at 09:39:45 UTC, Jacob Carlborg wrote: The latest DMD compiler only supports what's in the official documentation, i.e. [1]. What's documented in DIP43 [2] (except anything marked with "unimplemented") is what's been implemented in one of my forks. I'm working on

Re: What is "stringImportPaths"

2017-12-08 Thread mrphobby via Digitalmars-d-learn
On Thursday, 7 December 2017 at 09:47:31 UTC, Jacob Carlborg wrote: On 2017-12-06 20:05, mrphobby wrote: There are two kinds of language constructs that uses the "import" keyword. One is the "Import Declaration" [1] which is the most common one and is used to import other symbols. The other

Re: What is "stringImportPaths"

2017-12-08 Thread Ali Çehreli via Digitalmars-d-learn
On 12/08/2017 12:10 PM, mrphobby wrote: > I still think using the word "import" is confusing. Would rather have it > called "load" or something. But at least I understand it now :) We don't want any more keywords. :) (D's keywords are context-independent.) An unfortunate example was the