Re: general questions about static this() at module level

2016-10-31 Thread WhatMeWorry via Digitalmars-d-learn
On Monday, 31 October 2016 at 18:46:31 UTC, Jonathan M Davis wrote: though there's no reason to ever use a static constructor (shared or otherwise) when you can directly initialize the variable. It's really meant for more complicated initialization that can't be done directly. Also, I would

Re: strange -fPIC compilation error

2016-10-31 Thread Charles Hixson via Digitalmars-d-learn
On 10/31/2016 12:31 PM, Daniel Kozak via Digitalmars-d-learn wrote: Dne 31.10.2016 v 20:20 Charles Hixson via Digitalmars-d-learn napsal(a): ... but dmd -defaultlib=libphobos2.so -fPIC test.d works. It shouldn't be required (as in the default /etc/dmd.conf should handle it correctly, but I

Re: newbie problem with nothrow

2016-10-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 31, 2016 22:20:59 Kapps via Digitalmars-d-learn wrote: > Assuming you're sure it'll never throw. To enforce this, use try > { } catch { throw new Error("blah"); }. You can still throw > errors, just not exceptions (as errors are not meant to be > caught). I always use

Re: newbie problem with nothrow

2016-10-31 Thread Kapps via Digitalmars-d-learn
On Monday, 31 October 2016 at 17:04:28 UTC, Temtaime wrote: On Monday, 31 October 2016 at 16:55:51 UTC, WhatMeWorry wrote: Is there a way to turn off nothrow or work around it? Because to me it looks like nothrow prevents me from doing anything useful. extern(C) void onKeyEvent(GLFWwindow*

Re: Can someone please explain why the following assertion fails?

2016-10-31 Thread Ali Çehreli via Digitalmars-d-learn
On 10/31/2016 12:08 PM, Gary Willoughby wrote: Can someone please explain why the following assertion fails? import std.stdio; import std.conv; void main(string[] args) { auto x = 1; assert(hashOf(x.to!(string)) == hashOf(x.to!(string))); } Thanks. I think you need

Re: Can someone please explain why the following assertion fails?

2016-10-31 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 31 October 2016 at 19:24:13 UTC, Ali Çehreli wrote: On 10/31/2016 12:08 PM, Gary Willoughby wrote: [...] Because it considers the .ptr property of arrays as well: https://github.com/dlang/druntime/blob/master/src/core/internal/hash.d#L61 [...] Ah right. Is there an

Re: strange -fPIC compilation error

2016-10-31 Thread Daniel Kozak via Digitalmars-d-learn
Dne 31.10.2016 v 20:20 Charles Hixson via Digitalmars-d-learn napsal(a): ... but dmd -defaultlib=libphobos2.so -fPIC test.d works. It shouldn't be required (as in the default /etc/dmd.conf should handle it correctly, but I can deal with it now. It should work, it is possible that you have

Re: Can someone please explain why the following assertion fails?

2016-10-31 Thread Ali Çehreli via Digitalmars-d-learn
On 10/31/2016 12:08 PM, Gary Willoughby wrote: Can someone please explain why the following assertion fails? import std.stdio; import std.conv; void main(string[] args) { auto x = 1; assert(hashOf(x.to!(string)) == hashOf(x.to!(string))); } Thanks. Because it considers the .ptr

Re: strange -fPIC compilation error

2016-10-31 Thread Charles Hixson via Digitalmars-d-learn
On 10/31/2016 11:23 AM, Daniel Kozak via Digitalmars-d-learn wrote: Dne 31.10.2016 v 18:06 Charles Hixson via Digitalmars-d-learn napsal(a): On 10/31/2016 09:26 AM, Charles Hixson via Digitalmars-d-learn wrote: On 10/30/2016 11:34 PM, Daniel Kozak via Digitalmars-d-learn wrote: Dne

Re: Can someone please explain why the following assertion fails?

2016-10-31 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 31 October 2016 at 19:08:50 UTC, Gary Willoughby wrote: Can someone please explain why the following assertion fails? import std.stdio; import std.conv; void main(string[] args) { auto x = 1; assert(hashOf(x.to!(string)) == hashOf(x.to!(string))); } Thanks. DMD64

Can someone please explain why the following assertion fails?

2016-10-31 Thread Gary Willoughby via Digitalmars-d-learn
Can someone please explain why the following assertion fails? import std.stdio; import std.conv; void main(string[] args) { auto x = 1; assert(hashOf(x.to!(string)) == hashOf(x.to!(string))); } Thanks.

Re: general questions about static this() at module level

2016-10-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, October 31, 2016 16:02:13 WhatMeWorry via Digitalmars-d-learn wrote: > On Monday, 31 October 2016 at 05:42:16 UTC, sarn wrote: > > On Monday, 31 October 2016 at 04:35:35 UTC, WhatMeWorry wrote: > >> [...] > > > > I've seen hacks to do the same thing in C++. They're not > > pretty,

Re: strange -fPIC compilation error

2016-10-31 Thread Daniel Kozak via Digitalmars-d-learn
Dne 31.10.2016 v 18:06 Charles Hixson via Digitalmars-d-learn napsal(a): On 10/31/2016 09:26 AM, Charles Hixson via Digitalmars-d-learn wrote: On 10/30/2016 11:34 PM, Daniel Kozak via Digitalmars-d-learn wrote: Dne 31.10.2016 v 02:30 Charles Hixson via Digitalmars-d-learn napsal(a): Well,

Re: general questions about static this() at module level

2016-10-31 Thread Ali Çehreli via Digitalmars-d-learn
On 10/31/2016 09:02 AM, WhatMeWorry wrote: > Thanks! If you don't mind a follow up question, is this: > > immutable uint maxSize = 128; > > identical to this: > > immutable uint maxSize; > > static this() > { > maxSize = 128; > > } As usual, yes and no. :) The former is initialized at

Re: Newbie: can't manage some types...

2016-10-31 Thread zabruk70 via Digitalmars-d-learn
On Monday, 31 October 2016 at 16:06:48 UTC, Adam D. Ruppe wrote: dmd yourfile.d winmm.lib i personally like https://dlang.org/spec/pragma.html#lib pragma(lib, "winmm.lib");

Re: strange -fPIC compilation error

2016-10-31 Thread Charles Hixson via Digitalmars-d-learn
On 10/31/2016 09:26 AM, Charles Hixson via Digitalmars-d-learn wrote: On 10/30/2016 11:34 PM, Daniel Kozak via Digitalmars-d-learn wrote: Dne 31.10.2016 v 02:30 Charles Hixson via Digitalmars-d-learn napsal(a): Well, that certainly changed the error messages. With dmd

Re: newbie problem with nothrow

2016-10-31 Thread Temtaime via Digitalmars-d-learn
On Monday, 31 October 2016 at 16:55:51 UTC, WhatMeWorry wrote: Is there a way to turn off nothrow or work around it? Because to me it looks like nothrow prevents me from doing anything useful. extern(C) void onKeyEvent(GLFWwindow* window, int key, int scancode, int action, int modifier)

newbie problem with nothrow

2016-10-31 Thread WhatMeWorry via Digitalmars-d-learn
Is there a way to turn off nothrow or work around it? Because to me it looks like nothrow prevents me from doing anything useful. extern(C) void onKeyEvent(GLFWwindow* window, int key, int scancode, int action, int modifier) nothrow { if(queue.roomInQueue()) { auto event =

Re: Newbie: can't manage some types...

2016-10-31 Thread Cleverson Casarin Uliana via Digitalmars-d-learn
Thanks Adam for your kindness, it Works now. Thanks Alfred for the hint on setting the console output to 65001, will be useful as well. Greetings Cleverson

Re: strange -fPIC compilation error

2016-10-31 Thread Charles Hixson via Digitalmars-d-learn
On 10/30/2016 11:34 PM, Daniel Kozak via Digitalmars-d-learn wrote: Dne 31.10.2016 v 02:30 Charles Hixson via Digitalmars-d-learn napsal(a): Well, that certainly changed the error messages. With dmd -defaultlib=/usr/lib/x86_64-linux-gnu/libphobos2.so test.d I get:

Re: Newbie: can't manage some types...

2016-10-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 31 October 2016 at 14:02:01 UTC, Cleverson Casarin Uliana wrote: Error 42: Symbol Undefined _PlaySoundW@12 This is the most common linker error, it means you used a function without including the library. PlaySound's docs

Re: general questions about static this() at module level

2016-10-31 Thread WhatMeWorry via Digitalmars-d-learn
On Monday, 31 October 2016 at 05:42:16 UTC, sarn wrote: On Monday, 31 October 2016 at 04:35:35 UTC, WhatMeWorry wrote: [...] I've seen hacks to do the same thing in C++. They're not pretty, though. [...] Class/struct static constructors are good for initialising class/struct static

Re: Newbie: can't manage some types...

2016-10-31 Thread Alfred Newman via Digitalmars-d-learn
On Monday, 31 October 2016 at 11:44:25 UTC, Cleverson Casarin Uliana wrote: Hello all, I'm trying to do two tasks which involves some type conversion, and I'm having dificulties, probably because I haven't yet understood well how such types works. First, I wanted to convert UTF-8 strings to

Re: ACM paper: CPU is the new bottleneck

2016-10-31 Thread Kagamin via Digitalmars-d-learn
On the other hand if you do more IO, you can have higher CPU load due to compression and serialization.

Re: Newbie: can't manage some types...

2016-10-31 Thread Cleverson Casarin Uliana via Digitalmars-d-learn
Thank you very much, Adam, now I'm receiving another strange error. My code is this: import core.sys.windows.mmsystem; void main() { PlaySoundW("C:/base/portavox/som/_fon102.wav"w.ptr, null, SND_FILENAME); } When trying to compile, it returns: OPTLINK (R) for Win32 Release 8.00.17 Copyright

Re: Newbie: can't manage some types...

2016-10-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 31 October 2016 at 11:44:25 UTC, Cleverson Casarin Uliana wrote: Although the above code works, I have an impression that it could be more elegant and concise, but don't know how to improve it... That's OK except for the last line... the length isn't necessarily correct so your

Re: general questions about static this() at module level

2016-10-31 Thread ggdc via Digitalmars-d-learn
On Monday, 31 October 2016 at 04:35:35 UTC, WhatMeWorry wrote: I am fascinated with D's module static this. I have shamelessly stolen Ali's code directly from his book. module cat; static this() { // ... the initial operations of the module ... } static ~this() { // ... the final operations

Newbie: can't manage some types...

2016-10-31 Thread Cleverson Casarin Uliana via Digitalmars-d-learn
Hello all, I'm trying to do two tasks which involves some type conversion, and I'm having dificulties, probably because I haven't yet understood well how such types works. First, I wanted to convert UTF-8 strings to ansi, so it displays correctly at the Windows command prompt. One function to do

Re: Neural Networks / ML Libraries for D

2016-10-31 Thread Relja Ljubobratovic via Digitalmars-d-learn
On Tuesday, 25 October 2016 at 11:17:29 UTC, Saurabh Das wrote: Hello, Are there any good ML libraries for D? In particular, looking for a neural network library currently. Any leads would be appreciated. Thanks, Saurabh There is also Henry Gouk's dnnet library[1]. I'm not sure how far

Re: Neural Networks / ML Libraries for D

2016-10-31 Thread Relja Ljubobratovic via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 12:13:16 UTC, Ilya Yaroshenko wrote: https://github.com/ljubobratovicrelja/mir.experimental.model.rbf Now moved to https://github.com/libmir/mir-neural

Re: strange -fPIC compilation error

2016-10-31 Thread Sebastien Alaiwan via Digitalmars-d-learn
Hello, From GCC 6.2, -fpie is becoming the default setting at compile and at link time. As dmd uses GCC to link, now the code needs to be compiled with a special option. Which means you need, at the moment, to add the following options to your dmd.conf: -defaultlib=libphobos2.so -fPIC (the

Re: strange -fPIC compilation error

2016-10-31 Thread Daniel Kozak via Digitalmars-d-learn
Dne 31.10.2016 v 02:30 Charles Hixson via Digitalmars-d-learn napsal(a): Well, that certainly changed the error messages. With dmd -defaultlib=/usr/lib/x86_64-linux-gnu/libphobos2.so test.d I get: /usr/include/dmd/druntime/import/core/stdc/stdio.d(1121): Error: found 'nothrow' when expecting