Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 27 August 2017 at 10:46:53 UTC, Andrew Chapman wrote: [...] Oh interesting. Does DUB support passing through the --enable-contracts flag to ldc? Also, if this is an ldc specific thing it's probably not a good idea i'd imagine, since in the future one may want to use a GDC, or

Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Andrew Chapman via Digitalmars-d-learn
In the docs regarding contract programming and the use of enforce / assert: https://dlang.org/library/std/exception/enforce.html it says: "enforce is used to throw exceptions and is therefore intended to aid in error handling. It is not intended for verifying the logic of your program. That

Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 27 August 2017 at 10:46:53 UTC, Andrew Chapman wrote: On Sunday, 27 August 2017 at 10:37:50 UTC, Moritz Maxeiner wrote: [...] Oh interesting. Does DUB support passing through the --enable-contracts flag to ldc? Sure, using platform specific build settings [1] such as

Re: Building (and including libraries) without dub

2017-08-27 Thread zabruk70 via Digitalmars-d-learn
On Saturday, 26 August 2017 at 09:03:03 UTC, Hasen Judy wrote: What if I want to include a 3rd party library? Surely before dub existed, people were incorporating other libraries in their projects. sometimes pragma("lib", ...) very usefull (if i understand you correctly)

Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Andrew Chapman via Digitalmars-d-learn
On Sunday, 27 August 2017 at 10:37:50 UTC, Moritz Maxeiner wrote: On Sunday, 27 August 2017 at 10:17:47 UTC, Andrew Chapman wrote: On Sunday, 27 August 2017 at 10:08:15 UTC, ag0aep6g wrote: [...] Thanks, that explains it. I think it's a bit of a shame that the "in" blocks can't be used in

Re: How to store data when using parallel processing

2017-08-27 Thread Andrew Chapman via Digitalmars-d-learn
On Sunday, 27 August 2017 at 01:58:04 UTC, Jonathan M Davis wrote: [...] Thanks Jonathan, that makes sense. As it turns out, the Mutex approach actually makes things slower. In this case I believe trying to use multiple cores isn't worth it. Cheers.

Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread ag0aep6g via Digitalmars-d-learn
On 08/27/2017 12:02 PM, Andrew Chapman wrote: However, I am finding that BOTH enforce and assert are compiled out by dmd and ldc in release mode. Is there a standard way of doing what enforce does inside an "in" contract block that will work in release mode? I'm guessing I should write my

Making a repo of downloaded dub package

2017-08-27 Thread Dukc via Digitalmars-d-learn
More than once I have downloaded a DUB package which almost compiles but not quite. The fixes are often so trivial that even the user can do them, and the package starts working. But one may want to create a pull request to fix those issues for others too. Is there any way to make the

Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Andrew Chapman via Digitalmars-d-learn
On Sunday, 27 August 2017 at 10:08:15 UTC, ag0aep6g wrote: On 08/27/2017 12:02 PM, Andrew Chapman wrote: However, I am finding that BOTH enforce and assert are compiled out by dmd and ldc in release mode. Is there a standard way of doing what enforce does inside an "in" contract block that

Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 27 August 2017 at 10:17:47 UTC, Andrew Chapman wrote: On Sunday, 27 August 2017 at 10:08:15 UTC, ag0aep6g wrote: On 08/27/2017 12:02 PM, Andrew Chapman wrote: However, I am finding that BOTH enforce and assert are compiled out by dmd and ldc in release mode. Is there a standard

Re: 2 Dimensional Array Sorting

2017-08-27 Thread Vino.B via Digitalmars-d-learn
On Saturday, 26 August 2017 at 10:53:03 UTC, Vino.B wrote: On Saturday, 26 August 2017 at 10:45:13 UTC, Vino.B wrote: On Saturday, 26 August 2017 at 10:07:53 UTC, user1234 wrote: [...] Hi, Now there is no duplicate , but the sequence is still not correct [...] Hi, If I execute the

Re: gcd with doubles

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 27 August 2017 at 19:47:59 UTC, Alex wrote: Hi, all. Can anybody explain to me why void main() { import std.numeric; assert(gcd(0.5,32) == 0.5); assert(gcd(0.2,32) == 0.2); } fails on the second assert? I'm aware, that calculating gcd on doubles is not so

gcd with doubles

2017-08-27 Thread Alex via Digitalmars-d-learn
Hi, all. Can anybody explain to me why void main() { import std.numeric; assert(gcd(0.5,32) == 0.5); assert(gcd(0.2,32) == 0.2); } fails on the second assert? I'm aware, that calculating gcd on doubles is not so obvios, as on integers. But if the library accepts

Re: Unable to set static data member of a class (results in default value 0)

2017-08-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 August 2017 at 22:21:11 UTC, Enjoys Math wrote: static int dataReadDelay; That's thread-local. Use shared to make it shared across all threads, and/or initialize it in the same thread as the use. See: https://dlang.org/migrate-to-shared.html

Re: Comparison of Enumerations with base type of String?

2017-08-27 Thread Michael Reiland via Digitalmars-d-learn
whoa, you can use a struct as a basetype for an enum? I'm guessing it allows you to associate more information with the enum without using lookup tables and the like? And equality is probably just a memberwise comparison of the struct itself? That seems interesting like an interesting idea,

Re: gcd with doubles

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn
On Sunday, 27 August 2017 at 19:47:59 UTC, Alex wrote: [..] Is there a workaround, maybe? To expand on the earlier workaround: You can also adapt a floating point to string algorithm in order to dynamically determine an upper bound on the number of after decimal point digits required. Below

Re: gcd with doubles

2017-08-27 Thread Alex via Digitalmars-d-learn
ok... googled a little bit. Seems to be the problem of the kind floating poing <--> decimal... Will try to get by with some division and lrint logic, as there is a lack of definition, how to define a gcd in general case. For example with 30 and 0.16. Never mind...

Unable to set static data member of a class (results in default value 0)

2017-08-27 Thread Enjoys Math via Digitalmars-d-learn
I have: class DataSignal : Thread { public: static int dataReadDelay; void run() { while (true) { Thread.sleep(dur!"msecs"(dataReadDelay)); // Read in the new file data } } } in main I have: DataSignal.dataReadDelay = 8000; // initialize a

Re: Comparison of Enumerations with base type of String?

2017-08-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 27, 2017 22:01:52 Michael Reiland via Digitalmars-d-learn wrote: > whoa, you can use a struct as a basetype for an enum? I'm > guessing it allows you to associate more information with the > enum without using lookup tables and the like? And equality is > probably just a

Re: 2 Dimensional Array Sorting

2017-08-27 Thread Vino.B via Digitalmars-d-learn
On Sunday, 27 August 2017 at 11:53:29 UTC, Vino.B wrote: On Saturday, 26 August 2017 at 10:53:03 UTC, Vino.B wrote: [...] Hi, After analyzing a bit further was able to find that the out data before sorting is like below(4 - 2 dimensional array) hence the sorting is not working, so may i

Re: No CTFE of function

2017-08-27 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 27 August 2017 at 00:20:47 UTC, ag0aep6g wrote: On 08/27/2017 01:53 AM, Cecil Ward wrote: On Saturday, 26 August 2017 at 23:49:30 UTC, Cecil Ward wrote: [...] I think I understand, but I'm not sure. I should have explained properly. I suspect what I should have said was that I was

Re: Getting error in dmd testsuite

2017-08-27 Thread Joakim via Digitalmars-d-learn
On Saturday, 26 August 2017 at 21:59:10 UTC, Thomas Mader wrote: Hello, I am building ldc on Nix (https://nixos.org/nix/) but keep getting an error while running the cppa.d test from the dmd testsuite (https://github.com/ldc-developers/dmd-testsuite). 1588: ... runnable/cppa.d

Re: How to implement Timeout function

2017-08-27 Thread Jerry via Digitalmars-d-learn
On Sunday, 27 August 2017 at 15:56:14 UTC, Saigon wrote: Hi, Can I have Timeout function like this one [1] in Ruby? I want to check if a TCP service is running, and the check would return error if timeout occurs. Thanks a lot [1] https://github.com/ruby/ruby/blob/trunk/lib/timeout.rb Can

How to implement Timeout function

2017-08-27 Thread Saigon via Digitalmars-d-learn
Hi, Can I have Timeout function like this one [1] in Ruby? I want to check if a TCP service is running, and the check would return error if timeout occurs. Thanks a lot [1] https://github.com/ruby/ruby/blob/trunk/lib/timeout.rb

Re: No CTFE of function

2017-08-27 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 27 August 2017 at 17:36:54 UTC, Cecil Ward wrote: On Sunday, 27 August 2017 at 00:20:47 UTC, ag0aep6g wrote: [...] Static had already been tried. Failed. Thanks to your tip, I tried enum next. Failed as well, wouldn't compile with GDC. [...] I wonder if there is anything

Re: How to implement Timeout function

2017-08-27 Thread Saigon via Digitalmars-d-learn
On Sunday, 27 August 2017 at 15:56:55 UTC, Jerry wrote: On Sunday, 27 August 2017 at 15:56:14 UTC, Saigon wrote: Hi, Can I have Timeout function like this one [1] in Ruby? I want to check if a TCP service is running, and the check would return error if timeout occurs. Thanks a lot [1]

C callbacks getting a value of 0! Bug in D?

2017-08-27 Thread Johnson Jones via Digitalmars-d-learn
Trying to set a callback for portaudio and it's seeing zero for the value passed. Pa_OpenStream(, input, output, sampleRate, cast(ulong)0, cast(PaStreamFlags)(PaStreamFlags.NoFlag + 0*PaStreamFlags.PrimeOutputBuffersUsingStreamCallback),

Re: C callbacks getting a value of 0! Bug in D?

2017-08-27 Thread Johnson Jones via Digitalmars-d-learn
Looking at the assembly shows something like this: 0041ea98 push 0x0 0041ea9a push 0x0 0041ea9c push 0x0 0041ea9e push dword 0x100 0041eaa3 mov ecx, [typeid(PaStreamParameters)+0xe36fc (0x80d4cc)] 0041eaa9 mov eax, [fs:0x2c] 0041eaaf mov edx, [eax+ecx*4] 0041eab2 push dword [edx+0x1c]

Re: No CTFE of function

2017-08-27 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 27 August 2017 at 17:47:54 UTC, Cecil Ward wrote: I wonder if there is anything written up anywhere about what kinds of things are blockers to either CTFE or to successful constant-folding optimisation in particular compilers or in general? Would be useful to know what to stay