Re: Why many programmers don't like GC?

2021-01-19 Thread ddcovery via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 11:25:13 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 19 January 2021 at 10:43:45 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 19 January 2021 at 10:36:13 UTC, ddcovery wrote: GC if D is not enough for you), but think about the thousands of experienced developers

Re: How can I create a Standalone Bundle Portable file application using Dlang?

2021-01-19 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 11:10:25 UTC, Marcone wrote: On Tuesday, 19 January 2021 at 06:25:31 UTC, Imperatorn wrote: On Monday, 18 January 2021 at 19:42:22 UTC, Marcone wrote: How can I create a Standalone Bundle Portable file application using Dlang? Could you describe what you mean

Re: Convert double to long if lossless

2021-01-19 Thread drug via Digitalmars-d-learn
On 1/19/21 5:04 PM, drug wrote: On 1/19/21 4:48 PM, Per Nordlöw wrote: On Tuesday, 19 January 2021 at 13:36:58 UTC, Steven Schveighoffer wrote: Use a cast instead. const lvalue = cast(long)value; Ahh, good point. Followd by a compare of the original value I presume. don't forget to check

Re: Why many programmers don't like GC?

2021-01-19 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 13:41:33 UTC, ddcovery wrote: That you want GC to work efficiently seems great to me... but at least we agree that D memory management is (and must be) GC based (so I really don't understand your somewhat over-acted answer... maybe I need to read all the threads

Re: Convert double to long if lossless

2021-01-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/19/21 6:42 AM, Per Nordlöw wrote: I want to convert a double to a long if conversion is lossless (without fractional part, non-nan, non-inf, within long-range, etc). I currently have void foo() {     const double value = 10.1;     try     {     import std.conv : to;    

Re: Convert double to long if lossless

2021-01-19 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 13:36:58 UTC, Steven Schveighoffer wrote: Use a cast instead. const lvalue = cast(long)value; Ahh, good point. Followd by a compare of the original value I presume.

Struggling with wchar[] to string conversion

2021-01-19 Thread Stefan via Digitalmars-d-learn
Hi, I am using dmd2.081.1 on windows building a 32 bit executable. I am trying to find out how many instances of the same program are running. Therefor I use the core.sys.windows.tlhelp32 module. With the CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) and Process32First/Process32Next I

Re: Struggling with wchar[] to string conversion

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 15:32:12 UTC, Stefan wrote: contains a szExePath member that is a wchar[260]. Converting this to a string succeeds (compiler does not complain) with me32.szExePath.text You need to slice it on length. That default conversion will include all 260 chars. So

Re: How to use dguihub package ?

2021-01-19 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 17 January 2021 at 14:00:48 UTC, Mike Parker wrote: On Sunday, 17 January 2021 at 13:04:33 UTC, Vinod K Chandran Three of those messages include the solution to fix the errors. The fourth one is a missing import (`import std.conv : to`) in dguihub.core.utils. You could fix these

Re: Convert double to long if lossless

2021-01-19 Thread drug via Digitalmars-d-learn
On 1/19/21 6:50 PM, Ali Çehreli wrote: On 1/19/21 6:04 AM, drug wrote: > Another (low level) way is to shift mantissa left by exponent value. Luckily, we already have a helper in Phobos:   https://dlang.org/phobos/std_bitmanip.html#FloatRep Ali That makes life simpler, thanks for

Re: Convert double to long if lossless

2021-01-19 Thread drug via Digitalmars-d-learn
On 1/19/21 4:48 PM, Per Nordlöw wrote: On Tuesday, 19 January 2021 at 13:36:58 UTC, Steven Schveighoffer wrote: Use a cast instead. const lvalue = cast(long)value; Ahh, good point. Followd by a compare of the original value I presume. don't forget to check by std.math.isFinite before

Re: Struggling with wchar[] to string conversion

2021-01-19 Thread Jack via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 15:32:12 UTC, Stefan wrote: Hi, I am using dmd2.081.1 on windows building a 32 bit executable. I am trying to find out how many instances of the same program are running. Therefor I use the core.sys.windows.tlhelp32 module. With the

Re: Convert double to long if lossless

2021-01-19 Thread Ali Çehreli via Digitalmars-d-learn
On 1/19/21 6:04 AM, drug wrote: > Another (low level) way is to shift mantissa left by exponent value. Luckily, we already have a helper in Phobos: https://dlang.org/phobos/std_bitmanip.html#FloatRep Ali

Re: How to use dguihub package ?

2021-01-19 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 16:22:35 UTC, Vinod K Chandran wrote: Anyhow, I am planning to study this from beginning. "b ? (tbinfo.fsState |= TBSTATE_ENABLED) : (tbinfo.fsState &= ~TBSTATE_ENABLED);" This is the problem line in that property. "b" is a boolean parameter. But I dont know what

What are the advantages of using betterC?

2021-01-19 Thread Rempas via Digitalmars-d-learn
Sorry if that's a stupid question but I've read [this](https://dlang.org/spec/betterc.html) post that talks about betterC but I didn't understand where betterC is being used and what are the advantages it gives. Can anyone help me out with this?

Re: Convert double to long if lossless

2021-01-19 Thread Ali Çehreli via Digitalmars-d-learn
On 1/19/21 8:14 AM, drug wrote: > P.S. shouldn't compiler emit the error if a literal can't be represented > lossless? I think it would be a useful improvement. Ali

Re: Why many programmers don't like GC?

2021-01-19 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 13:41:33 UTC, ddcovery wrote: (so I really don't understand your somewhat over-acted answer... maybe I need to read all the threads to understand your discomfort. In any case, accept my forgiveness if I have been able to bother you). Forgot to answer, maybe I

Re: Convert double to long if lossless

2021-01-19 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 17:03:53 UTC, Ali Çehreli wrote: I think it would be a useful improvement. Indeed. Maybe Ilya could help out adding this to dmd.

Re: What are the advantages of using betterC?

2021-01-19 Thread Rempas via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 18:04:42 UTC, Adam D. Ruppe wrote: On Tuesday, 19 January 2021 at 17:44:03 UTC, Rempas wrote: Oh ok! So there is not advantage from using it like faster compile time, better performance etc. right? The default betterC build will compile about a quarter second

Re: Convert double to long if lossless

2021-01-19 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 16:14:17 UTC, drug wrote:   https://dlang.org/phobos/std_bitmanip.html#FloatRep Doesn't this pattern already cover all possible cases of `value` needed? void f(double value) { auto lvalue = cast(long)value; if (lvalue == value) // `value` lacks

Re: What are the advantages of using betterC?

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 17:44:03 UTC, Rempas wrote: Oh ok! So there is not advantage from using it like faster compile time, better performance etc. right? The default betterC build will compile about a quarter second faster than the default normal D build, but runtime performance is

Re: Convert double to long if lossless

2021-01-19 Thread Ali Çehreli via Digitalmars-d-learn
On 1/19/21 10:28 AM, Per Nordlöw wrote: > On Tuesday, 19 January 2021 at 16:14:17 UTC, drug wrote: >>>https://dlang.org/phobos/std_bitmanip.html#FloatRep > > Doesn't this pattern already cover all possible cases of `value` needed? I think so. I just remembered FloatRep as a cleaner tool

Re: Convert double to long if lossless

2021-01-19 Thread Schrom, Brian T via Digitalmars-d-learn
I'm probably missing something, but on the off chance you aren't aware, there is http://phobos.dpldocs.info/std.math.modf.html .

Re: What are the advantages of using betterC?

2021-01-19 Thread Imperatorn via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 17:44:03 UTC, Rempas wrote: On Tuesday, 19 January 2021 at 17:40:52 UTC, Adam D. Ruppe wrote: betterC is a niche restricted feature set. If you don't already have a use case in mind, I'd recommend avoiding it. It is for cases where you're stuck with certain

Re: What are the advantages of using betterC?

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
betterC is a niche restricted feature set. If you don't already have a use case in mind, I'd recommend avoiding it. It is for cases where you're stuck with certain limitations to integrate with the outside world. Like running on peculiar hardware or interoperating with certain outside

Re: What are the advantages of using betterC?

2021-01-19 Thread Rempas via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 17:40:52 UTC, Adam D. Ruppe wrote: betterC is a niche restricted feature set. If you don't already have a use case in mind, I'd recommend avoiding it. It is for cases where you're stuck with certain limitations to integrate with the outside world. Like running

Re: How can I check to see if template type is an array?

2021-01-19 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:38:41 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:36:47 UTC, Paul Backus wrote: On Tuesday, 19 January 2021 at 22:34:04 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:31:47 UTC, Paul Backus wrote: You've almost got it. The correct syntax is `is(T ==

Re: How can I check to see if template type is an array?

2021-01-19 Thread Tim via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:45:19 UTC, Paul Backus wrote: On Tuesday, 19 January 2021 at 22:38:41 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:36:47 UTC, Paul Backus wrote: On Tuesday, 19 January 2021 at 22:34:04 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:31:47 UTC, Paul

Re: Generating documentation help

2021-01-19 Thread Tim via Digitalmars-d-learn
On Sunday, 17 January 2021 at 22:27:13 UTC, Adam D. Ruppe wrote: On Sunday, 17 January 2021 at 21:48:20 UTC, Paul Backus wrote: I recommend using adrdox instead: note you should be able to just dub run adrdox and it will spit out `generated_docs/files...` (assuming i haven't broken that

Re: Generating documentation help

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 23:51:00 UTC, Tim wrote: I'm creating a u-services based app so my apps need to be documented properly as well. I can get around this by defining them as modules but then adrdox doesn't add them to index.html Well, it does all .d files passed in directories

Re: Generating documentation help

2021-01-19 Thread Tim via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 23:57:21 UTC, Adam D. Ruppe wrote: On Tuesday, 19 January 2021 at 23:51:00 UTC, Tim wrote: I'm creating a u-services based app so my apps need to be documented properly as well. I can get around this by defining them as modules but then adrdox doesn't add them to

Re: How can I check to see if template type is an array?

2021-01-19 Thread Tim via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:31:47 UTC, Paul Backus wrote: You've almost got it. The correct syntax is `is(T == U[], U)`. You can read it as "there exists some type U such that T == U[]". Thanks! Do I need to specify U in the template function?

Re: How can I check to see if template type is an array?

2021-01-19 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:26:52 UTC, Tim wrote: Hi all, I need to be able to check in a template whether the type given is an array type so that I can do some different logic. How can I do this? I would have thought that if(is(T == [])) would work, but no. Thanks in advance

Re: How can I check to see if template type is an array?

2021-01-19 Thread Tim via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:36:47 UTC, Paul Backus wrote: On Tuesday, 19 January 2021 at 22:34:04 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:31:47 UTC, Paul Backus wrote: You've almost got it. The correct syntax is `is(T == U[], U)`. You can read it as "there exists some type U

Re: How can I check to see if template type is an array?

2021-01-19 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:34:04 UTC, Tim wrote: On Tuesday, 19 January 2021 at 22:31:47 UTC, Paul Backus wrote: You've almost got it. The correct syntax is `is(T == U[], U)`. You can read it as "there exists some type U such that T == U[]". Thanks! Do I need to specify U in the

isCallable fails

2021-01-19 Thread frame via Digitalmars-d-learn
What could cause the following error? Error: expression isCallable!(data) of type void does not have a boolean value Problematic lines are: // T = some class // S = "data" (data is member of T) // typeof(S) = some struct U!X, not void alias S = __traits(getMember, T,

Re: Value of type enum members

2021-01-19 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 20:27:30 UTC, Andrey Zherikov wrote: Could someone please explain why there is a difference in values between compile-time and run-time? [...] void main() { pragma(msg, TENUM.foo);// T(2) pragma(msg, TENUM.bar);// T(3) writeln(TENUM.foo);

Re: How can I check to see if template type is an array?

2021-01-19 Thread Dennis via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 22:26:52 UTC, Tim wrote: I need to be able to check in a template whether the type given is an array type so that I can do some different logic. How can I do this? `if(is(T == E[], E))` or `isDynamicArray!T` is you `import std.traits;`

Re: Convert double to long if lossless

2021-01-19 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 21:04:51 UTC, kdevel wrote: And then? I mean: What do you want to do with the long what could not be done with the double in the first place? Motivated question. We want to propagate to our system locally that a double received from a network communication

Re: Value of type enum members

2021-01-19 Thread Petar via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 20:27:30 UTC, Andrey Zherikov wrote: Could someone please explain why there is a difference in values between compile-time and run-time? struct T { int i; this(int a) {i=a;} } enum TENUM : T { foo = T(2), bar = T(3), } void main() {

How can I check to see if template type is an array?

2021-01-19 Thread Tim via Digitalmars-d-learn
Hi all, I need to be able to check in a template whether the type given is an array type so that I can do some different logic. How can I do this? I would have thought that if(is(T == [])) would work, but no. Thanks in advance

Value of type enum members

2021-01-19 Thread Andrey Zherikov via Digitalmars-d-learn
Could someone please explain why there is a difference in values between compile-time and run-time? struct T { int i; this(int a) {i=a;} } enum TENUM : T { foo = T(2), bar = T(3), } void main() { pragma(msg, TENUM.foo);// T(2) pragma(msg, TENUM.bar);// T(3)

Re: Convert double to long if lossless

2021-01-19 Thread kdevel via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 11:42:17 UTC, Per Nordlöw wrote: I want to convert a double to a long if conversion is lossless (without fractional part, non-nan, non-inf, within long-range, etc). And then? I mean: What do you want to do with the long what could not be done with the double

Re: isCallable fails

2021-01-19 Thread frame via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 01:07:15 UTC, Ali Çehreli wrote: I may know the answer but I can't be sure because you don't provide code that reproduces the issue. I am trying to write code below according to your description but it's really tough. Can you reproduce the issue please. // T

Re: Generating documentation help

2021-01-19 Thread Tim via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 00:03:16 UTC, Adam D. Ruppe wrote: On Tuesday, 19 January 2021 at 23:58:59 UTC, Tim wrote: The main issue is that those scripts aren't being added to index.html Do they have module definitions and doc comments in there somewhere? like here I have all kinds

Re: Generating documentation help

2021-01-19 Thread Tim via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 01:25:28 UTC, Adam D. Ruppe wrote: On Wednesday, 20 January 2021 at 01:00:32 UTC, Tim wrote: But if I deleted index.html then reran the doc gen, it worked just fine. Looks like index.html is not being updated oh yeah i forgot i did that cuz I so often

Re: Generating documentation help

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 01:00:32 UTC, Tim wrote: But if I deleted index.html then reran the doc gen, it worked just fine. Looks like index.html is not being updated oh yeah i forgot i did that cuz I so often build individual files and it deleting the index annoyed me

Re: isCallable fails

2021-01-19 Thread Ali Çehreli via Digitalmars-d-learn
I may know the answer but I can't be sure because you don't provide code that reproduces the issue. I am trying to write code below according to your description but it's really tough. Can you reproduce the issue please. // T = some class // T is not a good name because it is usually

Re: Generating documentation help

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 23:58:59 UTC, Tim wrote: The main issue is that those scripts aren't being added to index.html Do they have module definitions and doc comments in there somewhere? like here I have all kinds of things http://dpldocs.info/experimental-docs/index.html

Re: Generating documentation help

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 00:06:35 UTC, Tim wrote: Yeah, they have both. They also contain the main entrypoint What are the module names? If it is like `module foo.main;` it will be listed under `foo` as a submodule rather than top-level since it is all organized by name. (if the

Re: Generating documentation help

2021-01-19 Thread Tim via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 00:13:42 UTC, Adam D. Ruppe wrote: On Wednesday, 20 January 2021 at 00:06:35 UTC, Tim wrote: Yeah, they have both. They also contain the main entrypoint What are the module names? If it is like `module foo.main;` it will be listed under `foo` as a submodule

Re: Generating documentation help

2021-01-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 00:16:51 UTC, Tim wrote: They are defined "module simulator" and "module analyzer". I also have "module math" etc. that are added to the index That's weird... There are a bunch of command line args to adrdox that might help like --document-undocumented

Re: Generating documentation help

2021-01-19 Thread Tim via Digitalmars-d-learn
On Wednesday, 20 January 2021 at 00:53:54 UTC, Adam D. Ruppe wrote: On Wednesday, 20 January 2021 at 00:16:51 UTC, Tim wrote: They are defined "module simulator" and "module analyzer". I also have "module math" etc. that are added to the index That's weird... There are a bunch of command

Re: How can I create a Standalone Bundle Portable file application using Dlang?

2021-01-19 Thread Marcone via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 06:25:31 UTC, Imperatorn wrote: On Monday, 18 January 2021 at 19:42:22 UTC, Marcone wrote: How can I create a Standalone Bundle Portable file application using Dlang? Could you describe what you mean with "Bundle portable file application"? All dependencies

Re: Why many programmers don't like GC?

2021-01-19 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 10:43:45 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 19 January 2021 at 10:36:13 UTC, ddcovery wrote: GC if D is not enough for you), but think about the thousands of experienced developers that where looking for something mature to work with and found that D was

Convert double to long if lossless

2021-01-19 Thread Per Nordlöw via Digitalmars-d-learn
I want to convert a double to a long if conversion is lossless (without fractional part, non-nan, non-inf, within long-range, etc). I currently have void foo() { const double value = 10.1; try { import std.conv : to; const lvalue = value.to!long; if (lvalue

Re: How can I create a Standalone Bundle Portable file application using Dlang?

2021-01-19 Thread evilrat via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 11:10:25 UTC, Marcone wrote: On Tuesday, 19 January 2021 at 06:25:31 UTC, Imperatorn wrote: On Monday, 18 January 2021 at 19:42:22 UTC, Marcone wrote: How can I create a Standalone Bundle Portable file application using Dlang? Could you describe what you mean

Re: Why many programmers don't like GC?

2021-01-19 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 06:14:52 UTC, Imperatorn wrote: What adjustments to the language would be needed in your opinion? I've mentioned them in connection with various approaches I've suggested. Depends on what area you want to improve. In short (off the top of my head, maybe more

Re: foreach, RefCounted and non-copyable range

2021-01-19 Thread Fynn Schröder via Digitalmars-d-learn
On Monday, 18 January 2021 at 18:57:04 UTC, vitamin wrote: You need something like RefCountedRange with methods popFront, front, empty. Thanks! refRange from std.range does the trick, indeed.

Re: struct constructor with rvalue param of same struct type

2021-01-19 Thread vit via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 06:49:06 UTC, Kyle Ingraham wrote: I’m sorry that this isn’t a solution to your problem but your code caught my attention. What is your snippet supposed to do? This is more specific example: https://run.dlang.io/is/W7rd2u import std.traits : CopyTypeQualifiers;

Re: Why many programmers don't like GC?

2021-01-19 Thread ddcovery via Digitalmars-d-learn
On Monday, 18 January 2021 at 15:18:40 UTC, aberba wrote: From my experiencing freelancing, I've come to see that a large portion of clients' decision stems from other things like familiarity and ecosystem (packages, frameworks, vendor/cloud support, engineering hiring pool,

Re: Why many programmers don't like GC?

2021-01-19 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 10:36:13 UTC, ddcovery wrote: GC if D is not enough for you), but think about the thousands of experienced developers that where looking for something mature to work with and found that D was not an option. And that's the point. The vast majority of