Re: is there "this"?

2016-11-01 Thread Konstantin Kutsevalov via Digitalmars-d-learn
On Wednesday, 2 November 2016 at 02:33:10 UTC, Konstantin Kutsevalov wrote: On Wednesday, 2 November 2016 at 02:20:43 UTC, rikki cattermole wrote: On 02/11/2016 3:17 PM, Konstantin Kutsevalov wrote: The question is simple. Is there something like "this" word for classes? For example: ```

Re: is there "this"?

2016-11-01 Thread Konstantin Kutsevalov via Digitalmars-d-learn
On Wednesday, 2 November 2016 at 02:20:43 UTC, rikki cattermole wrote: On 02/11/2016 3:17 PM, Konstantin Kutsevalov wrote: The question is simple. Is there something like "this" word for classes? For example: ``` class CLS { int numberValue; public this(numberValue) {

Re: is there "this"?

2016-11-01 Thread rikki cattermole via Digitalmars-d-learn
On 02/11/2016 3:17 PM, Konstantin Kutsevalov wrote: The question is simple. Is there something like "this" word for classes? For example: ``` class CLS { int numberValue; public this(numberValue) { // how can I put the local numberValue to class property? // in

is there "this"?

2016-11-01 Thread Konstantin Kutsevalov via Digitalmars-d-learn
The question is simple. Is there something like "this" word for classes? For example: ``` class CLS { int numberValue; public this(numberValue) { // how can I put the local numberValue to class property? // in some prog language I can do like: //

Re: error

2016-11-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 02, 2016 01:36:23 Concealment via Digitalmars-d-learn wrote: > On Wednesday, 2 November 2016 at 01:32:27 UTC, Adam D. Ruppe > > wrote: > > On Wednesday, 2 November 2016 at 01:27:32 UTC, Concealment > > > > wrote: > >> can someone help me please? > > > > did you import

Re: error

2016-11-01 Thread Concealment via Digitalmars-d-learn
On Wednesday, 2 November 2016 at 01:32:27 UTC, Adam D. Ruppe wrote: On Wednesday, 2 November 2016 at 01:27:32 UTC, Concealment wrote: can someone help me please? did you import anything? `import core.stdc.stdlib;` I think will fix that one, but generally you need an import to use lib

Re: error

2016-11-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 2 November 2016 at 01:27:32 UTC, Concealment wrote: can someone help me please? did you import anything? `import core.stdc.stdlib;` I think will fix that one, but generally you need an import to use lib functions.

error

2016-11-01 Thread Concealment via Digitalmars-d-learn
void main(string[] args) { srand(time(null)); int p1 = rand() % 7; p1++; i compiled this program i wrote... but it keeps giving me an error main.d(17): Error: undefined identifier 'time' can someone help me please?

Re: Benchmarking Time Unit

2016-11-01 Thread Stefan Koch via Digitalmars-d-learn
On Tuesday, 1 November 2016 at 22:55:36 UTC, Nordlöw wrote: On Tuesday, 1 November 2016 at 20:54:34 UTC, Steven Schveighoffer wrote: MonoTime has about 5-10 % fluctuations on my laptop. Is this as good as it gets? This is not clear. What is this a percentage of? It percentage of execution

Re: Benchmarking Time Unit

2016-11-01 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 1 November 2016 at 20:54:34 UTC, Steven Schveighoffer wrote: MonoTime has about 5-10 % fluctuations on my laptop. Is this as good as it gets? This is not clear. What is this a percentage of? It percentage of execution time. 15 ms +- 2 ms That seems doesn't look like what you

Assistance with DUB

2016-11-01 Thread Alfred Newman via Digitalmars-d-learn
Greetings, I need some help with dub libraries. Executing "dub list" in my machine, I got the following: Packages present in the system and known to dub: colorize ~master: C:\Users\Alfred\AppData\Roaming\dub\packages\colorize-master\colorize\ ... sqlite-d ~master:

Re: strange -fPIC compilation error

2016-11-01 Thread Lodovico Giaretta via Digitalmars-d-learn
On Tuesday, 1 November 2016 at 18:13:32 UTC, TheGag96 wrote: On Monday, 31 October 2016 at 07:16:50 UTC, Sebastien Alaiwan wrote: 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

Re: Benchmarking Time Unit

2016-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/1/16 4:19 PM, Nordlöw wrote: On Tuesday, 1 November 2016 at 18:39:01 UTC, Jonathan M Davis wrote: Alternatively, you can always do something like immutable before = MonoTime.currTime(); // do stuf... immutable after = MonoTime.currTime(); Duration timeSpent = after - before; MonoTime

Re: Benchmarking Time Unit

2016-11-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 01, 2016 20:21:32 Nordlöw via Digitalmars-d-learn wrote: > On Tuesday, 1 November 2016 at 20:19:31 UTC, Nordlöw wrote: > > MonoTime has about 5-10 % fluctuations on my laptop. Is this as > > good as it gets? > > Is > >

Re: Benchmarking Time Unit

2016-11-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 01, 2016 20:19:31 Nordlöw via Digitalmars-d-learn wrote: > On Tuesday, 1 November 2016 at 18:39:01 UTC, Jonathan M Davis > > wrote: > > Alternatively, you can always do something like > > > > immutable before = MonoTime.currTime(); > > // do stuf... > > immutable after =

Re: Benchmarking Time Unit

2016-11-01 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 1 November 2016 at 20:19:31 UTC, Nordlöw wrote: MonoTime has about 5-10 % fluctuations on my laptop. Is this as good as it gets? Is https://dlang.org/phobos/core_time.html#.ClockType.threadCPUTime what I should use if I'm on Linux?

Re: Benchmarking Time Unit

2016-11-01 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 1 November 2016 at 18:39:01 UTC, Jonathan M Davis wrote: Alternatively, you can always do something like immutable before = MonoTime.currTime(); // do stuf... immutable after = MonoTime.currTime(); Duration timeSpent = after - before; MonoTime has about 5-10 % fluctuations on my

Re: strange -fPIC compilation error

2016-11-01 Thread Charles Hixson via Digitalmars-d-learn
On 11/01/2016 10:34 AM, bachmeier via Digitalmars-d-learn wrote: On Tuesday, 1 November 2016 at 17:23:54 UTC, Charles Hixson wrote: On 11/01/2016 12:52 AM, Nordlöw via Digitalmars-d-learn wrote: On Tuesday, 1 November 2016 at 07:15:19 UTC, Mike Parker wrote: but dmd -defaultlib=libphobos2.so

Re: Should I prefer immutable or const?

2016-11-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 01, 2016 17:52:56 Nordlöw via Digitalmars-d-learn wrote: > Should I always, when possible, prefer `immutable` over `const`? > > And does `immutable` increase the possibility of the compiler > doing optimizations, such as common subexpression elimination? > > Or can the

Re: Should I prefer immutable or const?

2016-11-01 Thread ag0aep6g via Digitalmars-d-learn
On 11/01/2016 06:52 PM, Nordlöw wrote: Should I always, when possible, prefer `immutable` over `const`? I'd say: prefer immutable. And does `immutable` increase the possibility of the compiler doing optimizations, such as common subexpression elimination? Or can the compiler infer `const`

Re: Benchmarking Time Unit

2016-11-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 01, 2016 16:53:51 Nordlöw via Digitalmars-d-learn wrote: > Which way of measuring time in std.datetime should I used if I > want to benchmark a function by the amount of time spent in the > current thread, not wall-clock time? That's what std.datetime.benchmark is for,

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

2016-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/1/16 10:08 AM, Steven Schveighoffer wrote: On 10/31/16 3:24 PM, Ali Çehreli wrote: Because it considers the .ptr property of arrays as well: [snip] return bytesHash(bytes.ptr, bytes.length, seed);// <-- HERE bytesHash shouldn't use the pointer value in any way, it should

Re: strange -fPIC compilation error

2016-11-01 Thread TheGag96 via Digitalmars-d-learn
On Monday, 31 October 2016 at 07:16:50 UTC, Sebastien Alaiwan wrote: 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

Re: newbie problem with nothrow

2016-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/1/16 12:24 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, November 01, 2016 12:19:11 Steven Schveighoffer via Digitalmars- d-learn wrote: On 11/1/16 11:54 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, November 01, 2016 10:57:38 Steven Schveighoffer via

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

2016-11-01 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 1 November 2016 at 14:06:08 UTC, Steven Schveighoffer wrote: On 10/31/16 3: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)) ==

Should I prefer immutable or const?

2016-11-01 Thread Nordlöw via Digitalmars-d-learn
Should I always, when possible, prefer `immutable` over `const`? And does `immutable` increase the possibility of the compiler doing optimizations, such as common subexpression elimination? Or can the compiler infer `const` declarations to also be `immutable`?

Re: strange -fPIC compilation error

2016-11-01 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 1 November 2016 at 17:23:54 UTC, Charles Hixson wrote: On 11/01/2016 12:52 AM, Nordlöw via Digitalmars-d-learn wrote: On Tuesday, 1 November 2016 at 07:15:19 UTC, Mike Parker wrote: but dmd -defaultlib=libphobos2.so -fPIC test.d works. It shouldn't be required (as in the default

Re: strange -fPIC compilation error

2016-11-01 Thread Charles Hixson via Digitalmars-d-learn
On 11/01/2016 12:52 AM, Nordlöw via Digitalmars-d-learn wrote: On Tuesday, 1 November 2016 at 07:15:19 UTC, Mike Parker wrote: 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

Re: SQLite

2016-11-01 Thread Alfred Newman via Digitalmars-d-learn
On Friday, 21 October 2016 at 10:50:30 UTC, Vadim Lopatin wrote: On Wednesday, 19 October 2016 at 16:01:37 UTC, Alfred Newman wrote: Hello, I am trying to handle a SQLite3 table with D. During my researchs, I discovered the lib https://dlang.org/phobos/etc_c_sqlite3.html. However, for any

Benchmarking Time Unit

2016-11-01 Thread Nordlöw via Digitalmars-d-learn
Which way of measuring time in std.datetime should I used if I want to benchmark a function by the amount of time spent in the current thread, not wall-clock time?

Re: newbie problem with nothrow

2016-11-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 01, 2016 12:19:11 Steven Schveighoffer via Digitalmars- d-learn wrote: > On 11/1/16 11:54 AM, Jonathan M Davis via Digitalmars-d-learn wrote: > > On Tuesday, November 01, 2016 10:57:38 Steven Schveighoffer via > >> Is there not some assumeNoThrow wrapper somewhere? > > > >

Re: newbie problem with nothrow

2016-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/1/16 11:54 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, November 01, 2016 10:57:38 Steven Schveighoffer via Digitalmars- d-learn wrote: On 10/31/16 6:29 PM, Jonathan M Davis via Digitalmars-d-learn wrote: assert(0, "format threw when it shouldn't be possible.");

Re: newbie problem with nothrow

2016-11-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 01, 2016 10:57:38 Steven Schveighoffer via Digitalmars- d-learn wrote: > On 10/31/16 6:29 PM, Jonathan M Davis via Digitalmars-d-learn wrote: > > On Monday, October 31, 2016 22:20:59 Kapps via Digitalmars-d-learn wrote: > >> Assuming you're sure it'll never throw. To enforce

Re: newbie problem with nothrow

2016-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/31/16 6:29 PM, Jonathan M Davis via Digitalmars-d-learn wrote: 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

Re: newbie problem with nothrow

2016-11-01 Thread Daniel9 via Digitalmars-d-learn
On Monday, 31 October 2016 at 22:29:19 UTC, Jonathan M Davis wrote: 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

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

2016-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/31/16 3:24 PM, Ali Çehreli wrote: 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))); }

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

2016-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/31/16 3: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. IMO, it shouldn't. A string's

Re: splitter trouble

2016-11-01 Thread John Colvin via Digitalmars-d-learn
On Sunday, 30 October 2016 at 23:57:11 UTC, Ali Çehreli wrote: While working on a solution for Alfred Newman's thread, I came up with the following interim solution, which compiled but failed: auto parse(R, S)(R range, S separators) { import std.algorithm : splitter, filter, canFind;

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

2016-11-01 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 31 October 2016 at 22:10:30 UTC, Ali Çehreli wrote: 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)) ==

Re: strange -fPIC compilation error

2016-11-01 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 1 November 2016 at 07:15:19 UTC, Mike Parker wrote: 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. Can this be fed as parameters to the DMD call

Re: strange -fPIC compilation error

2016-11-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 31 October 2016 at 19:20:21 UTC, Charles Hixson wrote: 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. The need to manually add this to dmd.conf is a very

Re: newbie problem with nothrow

2016-11-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 31 October 2016 at 22:20:59 UTC, Kapps wrote: Wrap a body of the function to try {} catch {} and it'll work. 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

Re: newbie problem with nothrow

2016-11-01 Thread Mike Parker 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)