How to debug GC leak

2017-12-17 Thread Andrew Benton via Digitalmars-d-learn
I'm looking for a memory leak in my use of vibe.d JSON objects. The gc profiler built into the runtime only shows allocation count and allocation bytes, so I can make guesses around what might have leaked, but I can't be sure where or when, or exactly what leaked. I'm sure someone else has

Re: How to pack a struct to a ubyte[] in a more "The D way" style ?

2017-12-17 Thread Binghoo Dang via Digitalmars-d-learn
Thanks for your idea. On Monday, 18 December 2017 at 05:08:24 UTC, Jonathan M Davis wrote: ubyte[] makeCMDPacket(RCPCmd cmd, in ubyte[] data) { this.preamble = RCPPKT_PRE; this.hdr.msgtype = RCPMSG_CMD; this.hdr.cmdcode = cast (ubyte)

Re: How to pack a struct to a ubyte[] in a more "The D way" style ?

2017-12-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 18, 2017 03:00:47 Binghoo Dang via Digitalmars-d-learn wrote: > hi, > > I'm a dlang newbie, and I recently made a program that interacts > with an RFID Reader, it's basically a Serial-Port communication > model. And after 2 days, I finally got a working code like these: > >

How to pack a struct to a ubyte[] in a more "The D way" style ?

2017-12-17 Thread Binghoo Dang via Digitalmars-d-learn
hi, I'm a dlang newbie, and I recently made a program that interacts with an RFID Reader, it's basically a Serial-Port communication model. And after 2 days, I finally got a working code like these: ``` enum RCPCmd{ RCPCMD_GET_REGION = 0x06, RCPCMD_SET_REGION = 0x07,

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 17 December 2017 at 20:09:02 UTC, ParticlePeter wrote: On Sunday, 17 December 2017 at 19:29:00 UTC, ParticlePeter wrote: On Sunday, 17 December 2017 at 19:16:02 UTC, ParticlePeter [snip] LINKCMD=%VCINSTALLDIR%\bin\HostX32\x64\link.exe or

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 17 December 2017 at 19:29:00 UTC, ParticlePeter wrote: On Sunday, 17 December 2017 at 19:16:02 UTC, ParticlePeter wrote: On Sunday, 17 December 2017 at 17:56:47 UTC, John wrote: I don't think so, all that would need to be changed is this line:

Re: Fold in Parallelism

2017-12-17 Thread Ali Çehreli via Digitalmars-d-learn
On 12/17/2017 08:11 AM, Vino wrote: > As per the document form std.parallelism it states that we can use > taskPool.reduce so can we use the same for fold (taskPool.fold) as > basically both are same with slight variation on seed values, if > possible can can we define the same in the below

Re: Passing anonymous enums as function parameters

2017-12-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, December 17, 2017 12:47:26 kerdemdemir via Digitalmars-d-learn wrote: > What I meant with anonymous enums was: > https://dlang.org/spec/enum.html#anonymous_enums. Maybe I > couldn't explain well but I believe D have anonymous enums. I am > sorry I have forgotten to remove " :string" in

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 17 December 2017 at 19:16:02 UTC, ParticlePeter wrote: On Sunday, 17 December 2017 at 17:56:47 UTC, John wrote: I don't think so, all that would need to be changed is this line: https://github.com/dlang/dmd/blob/v2.077.1/ini/windows/bin/sc.ini#L53 Not very many people use it I

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 17 December 2017 at 17:56:47 UTC, John wrote: I don't think so, all that would need to be changed is this line: https://github.com/dlang/dmd/blob/v2.077.1/ini/windows/bin/sc.ini#L53 Not very many people use it I guess if it's been there for 8 months lol. Hm, actually that line

Re: Where is sleep()?

2017-12-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 17 December 2017 at 17:01:37 UTC, Steven Schveighoffer wrote: I searched for "sleep" in "library", core.thread was the first result. Yeah, me too (followed by core.time, std.datetime.stopwatch, and std.datetime...), but it isn't obvious any of them are actual winners. If you

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread John via Digitalmars-d-learn
On Sunday, 17 December 2017 at 17:15:57 UTC, ParticlePeter wrote: On Sunday, 17 December 2017 at 16:40:46 UTC, John wrote: Yah the sc.ini file is wrong for Environment64. [Environment64] LIB="%@P%\..\lib64" . . . ; Windows installer uncomments the version detected

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 17 December 2017 at 16:40:46 UTC, John wrote: Yah the sc.ini file is wrong for Environment64. [Environment64] LIB="%@P%\..\lib64" . . . ; Windows installer uncomments the version detected LINKCMD=%VCINSTALLDIR%\bin\HostX86\x86\link.exe Thanks! Is this a known, reported bug?

Re: Where is sleep()?

2017-12-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/17/17 8:32 AM, Adam D. Ruppe wrote: On Sunday, 17 December 2017 at 08:32:20 UTC, Ryan David Sheasby wrote: What am I missing? the official search is hard to use, so I made my own. When looking for something, try dpldocs.info/search_term http://dpldocs.info/sleep and here it pops

Re: Function signature testing with is expression.

2017-12-17 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Sunday, 17 December 2017 at 16:19:00 UTC, ag0aep6g wrote: On Sunday, 17 December 2017 at 14:44:15 UTC, Alexandru Ermicioi wrote: Suppose: struct F { static void foo(T)(T i, int o) {} } enum bool check(T) = is(F.foo!T == void function(Z, int), Z); enum correct = check!int;

Re: Where is sleep()?

2017-12-17 Thread Ali Çehreli via Digitalmars-d-learn
On 12/17/2017 12:32 AM, Ryan David Sheasby wrote: > I've searched high and low but can't > seem to find a simple sleep/delay/wait/pause function in the core or in > phobos. Prepending "dlang" to Google searches has been working well for me. Googling for "dlang sleep" lists the documentation as

Re: Passing anonymous enums as function parameters

2017-12-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-17 12:49, kerdemdemir wrote: I have an enum statement : enum : string {     KErdem     Ali     Zafer     Salih     //etc... } I don't want to give a name to my enum class since I am accessing this variables very often. But I also have a function like: double

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread John via Digitalmars-d-learn
On Sunday, 17 December 2017 at 15:57:08 UTC, ParticlePeter wrote: I upgraded from DMD 2.074.1 (!) to 2.077.1 and tried to compile a mixed c++/d project (DMD links to one c++ lib). Here is the full error message: fatal error C1905: Front end and back end not compatible (must target same

Re: Dynamic Array reserve

2017-12-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/17/17 11:18 AM, Vino wrote: On Sunday, 17 December 2017 at 00:45:06 UTC, Ali Çehreli wrote: On 12/16/2017 03:58 PM, Steven Schveighoffer wrote: [...] I was going to suggest the same to Vino and I was writing the following program to demonstrate how low the number of allocations is.

Re: Dynamic Array reserve

2017-12-17 Thread Vino via Digitalmars-d-learn
On Sunday, 17 December 2017 at 00:45:06 UTC, Ali Çehreli wrote: On 12/16/2017 03:58 PM, Steven Schveighoffer wrote: [...] I was going to suggest the same to Vino and I was writing the following program to demonstrate how low the number of allocations is. [...] Hi Steven /Ali,

Re: Function signature testing with is expression.

2017-12-17 Thread ag0aep6g via Digitalmars-d-learn
On Sunday, 17 December 2017 at 14:44:15 UTC, Alexandru Ermicioi wrote: Suppose: struct F { static void foo(T)(T i, int o) {} } enum bool check(T) = is(F.foo!T == void function(Z, int), Z); enum correct = check!int; Upon running it will return false, though, by logic is

Fold in Parallelism

2017-12-17 Thread Vino via Digitalmars-d-learn
HI All, As per the document form std.parallelism it states that we can use taskPool.reduce so can we use the same for fold (taskPool.fold) as basically both are same with slight variation on seed values, if possible can can we define the same in the below lines Tried the below but getting

Re: Function signature testing with is expression.

2017-12-17 Thread Ali Çehreli via Digitalmars-d-learn
On 12/17/2017 06:44 AM, Alexandru Ermicioi wrote: > It is interesting that it will not work with global functions as well: > > > void foo(int i, double d) {}; > enum bool check = is(typeof(foo) == void function(int, double)); > There, the address-of operator is missing. This

Re: Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
On Sunday, 17 December 2017 at 15:57:08 UTC, ParticlePeter wrote: I upgraded from DMD 2.074.1 (!) to 2.077.1 and tried to compile a mixed c++/d project (DMD links to one c++ lib). Here is the full error message: Forgot most important info, ita an x64 project those used VS linker by default

Linker error since upgrade to DMD 2.077.1: fatal error C1905: Front end and back end not compatible

2017-12-17 Thread ParticlePeter via Digitalmars-d-learn
I upgraded from DMD 2.074.1 (!) to 2.077.1 and tried to compile a mixed c++/d project (DMD links to one c++ lib). Here is the full error message: fatal error C1905: Front end and back end not compatible (must target same processor). LINK : fatal error LNK1257: code generation failed Error:

Function signature testing with is expression.

2017-12-17 Thread Alexandru Ermicioi via Digitalmars-d-learn
Hi, Have someone tried to test a function against a signature using is expression? Suppose: struct F { static void foo(T)(T i, int o) {} } enum bool check(T) = is(F.foo!T == void function(Z, int), Z); enum correct = check!int; Upon running it will return false,

Clarity about extern(Windows)/extern(System)

2017-12-17 Thread Mike Parker via Digitalmars-d-learn
For years now, I've been under the impression that the distinction between extern(Windows) and extern(System) actually mattered. I recall extern(System) was first added to the language to resolve this situation for C bindings: version(Windows) extern(Windows): else extern(C): Which, or

Re: Where is sleep()?

2017-12-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 17 December 2017 at 08:32:20 UTC, Ryan David Sheasby wrote: What am I missing? the official search is hard to use, so I made my own. When looking for something, try dpldocs.info/search_term http://dpldocs.info/sleep and here it pops right up.

Re: Passing anonymous enums as function parameters

2017-12-17 Thread kerdemdemir via Digitalmars-d-learn
What I meant with anonymous enums was: https://dlang.org/spec/enum.html#anonymous_enums. Maybe I couldn't explain well but I believe D have anonymous enums. I am sorry I have forgotten to remove " :string" in my example from the "enum : string". Please stretch out ": string" part my problem

Re: Does D have class' attributes like C#'s?

2017-12-17 Thread SealabJaster via Digitalmars-d-learn
On Saturday, 16 December 2017 at 19:57:30 UTC, Marc wrote: Does D have something similar? As others have said, D has UDAs. An alternative to using __traits(getAttributes) is to use std.traits.getUDAs [1] I've made a small example using std.traits.getUDAs, based off of your example. [2]

Re: Passing anonymous enums as function parameters

2017-12-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, December 17, 2017 11:49:58 kerdemdemir via Digitalmars-d-learn wrote: > I have an enum statement : > > enum : string > { > KErdem > Ali > Zafer > Salih > //etc... > } > > > I don't want to give a name to my enum class since I am accessing > this variables very

Passing anonymous enums as function parameters

2017-12-17 Thread kerdemdemir via Digitalmars-d-learn
I have an enum statement : enum : string { KErdem Ali Zafer Salih //etc... } I don't want to give a name to my enum class since I am accessing this variables very often. But I also have a function like: double ReturnCoolNess( /* Is there any way? */ enumVal ) { switch

Re: Dub generate import files

2017-12-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-17 02:32, Venkat wrote: dmd has the -H and -Hd switches. Does dub have any setting to make it generate D interface files ? Not that I know of, but you can create your own build type for that [1] [1] http://code.dlang.org/package-format?lang=sdl#build-types -- /Jacob Carlborg

Re: Does D have class' attributes like C#'s?

2017-12-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-16 22:11, Marc wrote: I can't "pack" an object, right? In C#, TextSize is a class and 256 is constructor's first argument. In D it's pretty much an array but I guess it's close enough. Thanks! In D it's an tuple of basically anything that is known at compile time, values or

Re: Scope failure is not preventing application crush in case of uncaught exceptions

2017-12-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, December 17, 2017 09:32:53 codephantom via Digitalmars-d-learn wrote: > On Sunday, 17 December 2017 at 08:26:03 UTC, Jonathan M Davis > > wrote: > > assert(0) does indeed turn into a HLT instruction in -release > > mode (as does any assertion that's known to be false at compile > >

Re: Scope failure is not preventing application crush in case of uncaught exceptions

2017-12-17 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 17 December 2017 at 08:10:06 UTC, codephantom wrote: On Sunday, 17 December 2017 at 00:10:27 UTC, Anonymouse wrote: If you return inside a scopeguard though, the exception (or error!) is swallowed. https://run.dlang.io/is/GEtQ6D The scope guard will not 'swallow' it, if you use

Re: Where is sleep()?

2017-12-17 Thread codephantom via Digitalmars-d-learn
On Sunday, 17 December 2017 at 08:32:20 UTC, Ryan David Sheasby wrote: Hey guys. First time poster here. I've searched high and low but can't seem to find a simple sleep/delay/wait/pause function in the core or in phobos. The most recent information I can find about it is this forum post from

Re: Scope failure is not preventing application crush in case of uncaught exceptions

2017-12-17 Thread codephantom via Digitalmars-d-learn
On Sunday, 17 December 2017 at 08:26:03 UTC, Jonathan M Davis wrote: assert(0) does indeed turn into a HLT instruction in -release mode (as does any assertion that's known to be false at compile time). It's a special case intended for marking code that's supposed to be unreachable. Without

Re: Where is sleep()?

2017-12-17 Thread Ryan David Sheasby via Digitalmars-d-learn
On Sunday, 17 December 2017 at 08:40:53 UTC, rikki cattermole wrote: On 17/12/2017 8:32 AM, Ryan David Sheasby wrote: Hey guys. First time poster here. I've searched high and low but can't seem to find a simple sleep/delay/wait/pause function in the core or in phobos. The most recent

Re: Where is sleep()?

2017-12-17 Thread rikki cattermole via Digitalmars-d-learn
On 17/12/2017 8:32 AM, Ryan David Sheasby wrote: Hey guys. First time poster here. I've searched high and low but can't seem to find a simple sleep/delay/wait/pause function in the core or in phobos. The most recent information I can find about it is this forum post from 12 years ago:

Where is sleep()?

2017-12-17 Thread Ryan David Sheasby via Digitalmars-d-learn
Hey guys. First time poster here. I've searched high and low but can't seem to find a simple sleep/delay/wait/pause function in the core or in phobos. The most recent information I can find about it is this forum post from 12 years ago:

Re: Scope failure is not preventing application crush in case of uncaught exceptions

2017-12-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, December 17, 2017 08:10:06 codephantom via Digitalmars-d-learn wrote: > On Sunday, 17 December 2017 at 00:10:27 UTC, Anonymouse wrote: > > If you return inside a scopeguard though, the exception (or > > error!) is swallowed. https://run.dlang.io/is/GEtQ6D > > The scope guard will not

Re: Scope failure is not preventing application crush in case of uncaught exceptions

2017-12-17 Thread codephantom via Digitalmars-d-learn
On Sunday, 17 December 2017 at 00:10:27 UTC, Anonymouse wrote: If you return inside a scopeguard though, the exception (or error!) is swallowed. https://run.dlang.io/is/GEtQ6D The scope guard will not 'swallow' it, if you use -release mode. Which suggests to me, that assert(0) operates