Re: Alternative to std.range.choose

2020-07-21 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 22 July 2020 at 04:33:20 UTC, James Gray wrote: Is there a better way to achieve behaviour similar to rangeFuncIf below? f gives a contrived example of when one might want this. g is how one might try and achieve the same with std.range.choose. import std.stdio; import std.range

Alternative to std.range.choose

2020-07-21 Thread James Gray via Digitalmars-d-learn
Is there a better way to achieve behaviour similar to rangeFuncIf below? f gives a contrived example of when one might want this. g is how one might try and achieve the same with std.range.choose. import std.stdio; import std.range : only, chain, join, choose; import std.algorithm : map; auto

Re: How DerelictCL works

2020-07-21 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 12:00:03 UTC, bioinfornatics wrote: Dear, I would like to use OpenCL in D. Thus I try to use DerelictCL. But I fail to use it I encounter this error message: -- /opt/jonathan/jonathan-dlang_ldc2092/root/usr/include/d/derelict/opencl/constants.di(835): Err

Re: What would be the advantage of using D to port some games?

2020-07-21 Thread JN via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 18:53:34 UTC, matheus wrote: Hi, I currently use D for small CLI/Batch apps, before that I used to program in C. Despite of using D I usually program like C but with the advantage of: GC, AA, CTFE and a few classes here and there. As we can see there are a lot o

Re: miscellaneous array questions...

2020-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 19:20:28 UTC, Simen Kjærås wrote: Walter gives some justification in the post immediately following: whelp proves my memory wrong!

Re: miscellaneous array questions...

2020-07-21 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 13:42:15 UTC, Steven Schveighoffer wrote: On 7/21/20 8:34 AM, Adam D. Ruppe wrote: The others aren't wrong about stack size limits playing some role, but the primary reason is that it is a weird hack for @safe, believe it or not. ... I don't recall exactly when thi

Re: Good way to send/receive UDP packets?

2020-07-21 Thread notna via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 13:05:21 UTC, wjoe wrote: On Sunday, 19 July 2020 at 09:48:24 UTC, notna wrote: Someone once wrote about a UDP library, which was used to sync data to somewhere in APAC (Hongkong?) and by doing so the data transfer was magnitudes faster then before (over TCP)...

Re: How DerelictCL works

2020-07-21 Thread aberba via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 12:00:03 UTC, bioinfornatics wrote: Dear, I would like to use OpenCL in D. Thus I try to use DerelictCL. But I fail to use it I encounter this error message: -- /opt/jonathan/jonathan-dlang_ldc2092/root/usr/include/d/derelict/opencl/constants.di(835): Err

Re: miscellaneous array questions...

2020-07-21 Thread Johan via Digitalmars-d-learn
On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: 1) The D Language Reference says: "There are four kinds of arrays..." with the first example being "type* Pointers to data" and "int* p; etc. At the risk of sounding overly nitpicky, isn't a pointer to an integer simply a pointe

Re: What would be the advantage of using D to port some games?

2020-07-21 Thread Johan via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 18:53:34 UTC, matheus wrote: Hi, I currently use D for small CLI/Batch apps, before that I used to program in C. Despite of using D I usually program like C but with the advantage of: GC, AA, CTFE and a few classes here and there. As we can see there are a lot o

Re: What would be the advantage of using D to port some games?

2020-07-21 Thread RegeleIONESCU via Digitalmars-d-learn
On Monday, 20 July 2020 at 20:03:05 UTC, Laurent Tréguier wrote: On Monday, 20 July 2020 at 19:49:52 UTC, RegeleIONESCU wrote: Hello! I was wondering why some game related packages/libraries are not being developed anymore or are kind of paused. Fore example the last version of derelict-sdl2

Re: miscellaneous array questions...

2020-07-21 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 13:23:32 UTC, Adam D. Ruppe wrote: But the array isn't initialized in the justification scenario. It is accessed through a null pointer and the type system thinks it is fine because it is still inside the static limit. At run time, the cpu just sees access to memo

Re: miscellaneous array questions...

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/20 8:34 AM, Adam D. Ruppe wrote: The others aren't wrong about stack size limits playing some role, but the primary reason is that it is a weird hack for @safe, believe it or not. ... I don't recall exactly when this was discussed but it came up in the earlier days of @safe, I'm pretty

Re: miscellaneous array questions...

2020-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 13:16:44 UTC, IGotD- wrote: Either the array will hit that page during initialization or something else during the execution. But the array isn't initialized in the justification scenario. It is accessed through a null pointer and the type system thinks it is fine

Re: miscellaneous array questions...

2020-07-21 Thread IGotD- via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 12:34:14 UTC, Adam D. Ruppe wrote: With the null `a`, the offset to the static array is just 0 + whatever and the @safe mechanism can't trace that. So the arbitrary limit was put in place to make it more likely that such a situation will hit a protected page and s

Re: Good way to send/receive UDP packets?

2020-07-21 Thread wjoe via Digitalmars-d-learn
On Sunday, 19 July 2020 at 09:48:24 UTC, notna wrote: Someone once wrote about a UDP library, which was used to sync data to somewhere in APAC (Hongkong?) and by doing so the data transfer was magnitudes faster then before (over TCP)... In the best case scenario, and orders of magnitude more

Re: std/process.d: nothrow functions which throw (in struct ProcessPipes)

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/20 8:49 AM, Adam D. Ruppe wrote: On Tuesday, 21 July 2020 at 12:44:23 UTC, Drone1h wrote: Would it be possible to explain this, please ? nothrow only applies to Exception and its children. Error is a different branch. Error means you have a programming error and cannot be caught and

Re: std/process.d: nothrow functions which throw (in struct ProcessPipes)

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/20 8:44 AM, Drone1h wrote: Hello All, In phobos/std/process.d, in the ProcessPipes struct, we can see a few functions which are marked with "nothrow", but which (under some conditions) throw:     @property File stdout() @safe nothrow     {     if ((_redirectFlags & Redirect.st

Re: std/process.d: nothrow functions which throw (in struct ProcessPipes)

2020-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 12:44:23 UTC, Drone1h wrote: Would it be possible to explain this, please ? nothrow only applies to Exception and its children. Error is a different branch. Error means you have a programming error and cannot be caught and recovered (though the compiler allows it

std/process.d: nothrow functions which throw (in struct ProcessPipes)

2020-07-21 Thread Drone1h via Digitalmars-d-learn
Hello All, In phobos/std/process.d, in the ProcessPipes struct, we can see a few functions which are marked with "nothrow", but which (under some conditions) throw: @property File stdout() @safe nothrow { if ((_redirectFlags & Redirect.stdout) == 0) throw new Error

Re: miscellaneous array questions...

2020-07-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: How does that pertain to an array? C arrays work as pointers to the first element and D can use that style too. 2) "The total size of a static array cannot exceed 16Mb" What limits this? The others aren't wrong about stack size l

Re: miscellaneous array questions...

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/20 7:10 AM, IGotD- wrote: On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: 2) "The total size of a static array cannot exceed 16Mb" What limits this? And with modern systems of 16GB and 32GB, isn't 16Mb excessively small?   (an aside: shouldn't that be 16MB in the reference

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread Ecstatic Coder via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 12:21:16 UTC, Steven Schveighoffer wrote: On 7/21/20 7:44 AM, Ecstatic Coder wrote: On Tuesday, 21 July 2020 at 11:01:20 UTC, drug wrote: On 7/20/20 10:04 PM, Ecstatic Coder wrote: I'm currently implementing a small open source backup tool (dub), and therefore I nee

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/21/20 7:44 AM, Ecstatic Coder wrote: On Tuesday, 21 July 2020 at 11:01:20 UTC, drug wrote: On 7/20/20 10:04 PM, Ecstatic Coder wrote: I'm currently implementing a small open source backup tool (dub), and therefore I need to accurately store the file modification SysTime in binary format,

Re: std.process - avoid interaction with parent shell

2020-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/20/20 6:04 PM, Vladimir Panteleev wrote: On Monday, 20 July 2020 at 20:55:52 UTC, Steven Schveighoffer wrote: I tried redirecting /dev/null to stdin when executing my application (and I assumed that would pass onto the process child), but it still asks. What am I doing wrong? Generically

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread drug via Digitalmars-d-learn
On 7/21/20 2:44 PM, Ecstatic Coder wrote: Ah thanks for telling me :) The loaded byte array in the union type was indeed the same as the saved one, so I immediately thought it was crashing because of some hidden pointer for timezone or something which was then pointing to garbage at reloadin

How DerelictCL works

2020-07-21 Thread bioinfornatics via Digitalmars-d-learn
Dear, I would like to use OpenCL in D. Thus I try to use DerelictCL. But I fail to use it I encounter this error message: -- /opt/jonathan/jonathan-dlang_ldc2092/root/usr/include/d/derelict/opencl/constants.di(835): Error: genCLVectorTypes cannot be interpreted at compile time, becau

Re: miscellaneous array questions...

2020-07-21 Thread wjoe via Digitalmars-d-learn
On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: 2) "The total size of a static array cannot exceed 16Mb" What limits this? And with modern systems of 16GB and 32GB, isn't 16Mb excessively small? (an aside: shouldn't that be 16MB in the reference instead of 16Mb? that is, Doesn't b

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread Ecstatic Coder via Digitalmars-d-learn
On Tuesday, 21 July 2020 at 11:01:20 UTC, drug wrote: On 7/20/20 10:04 PM, Ecstatic Coder wrote: I'm currently implementing a small open source backup tool (dub), and therefore I need to accurately store the file modification SysTime in binary format, so that I can later load this SysTime from

Re: miscellaneous array questions...

2020-07-21 Thread IGotD- via Digitalmars-d-learn
On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: 2) "The total size of a static array cannot exceed 16Mb" What limits this? And with modern systems of 16GB and 32GB, isn't 16Mb excessively small? (an aside: shouldn't that be 16MB in the reference instead of 16Mb? that is, Doesn't

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread drug via Digitalmars-d-learn
On 7/20/20 10:04 PM, Ecstatic Coder wrote: I'm currently implementing a small open source backup tool (dub), and therefore I need to accurately store the file modification SysTime in binary format, so that I can later load this SysTime from the snapshot file to compare it with the current file

Re: Accurately serializing and deserializing a SysTime in binary format

2020-07-21 Thread Ecstatic Coder via Digitalmars-d-learn
As my question obviously didn't interest any expert, I took advantage of my lunch break to do some more research ;) Maybe I'm wrong, but to my knowledge, there is no function to get the number of hectonanoseconds since January 1, 1970. Fortunately I can get the number of seconds since the sam