Floating point literal definition

2016-02-29 Thread ric maicle via Digitalmars-d-learn
I'm currently reading about floating point literal and came to this part: FloatLiteral: ... Integer ImaginarySuffix Integer FloatSuffix ImaginarySuffix Integer RealSuffix ImaginarySuffix Going to the Integer link, it is defined as: Integer: ...

Re: Member Access Based On A Runtime String

2016-02-29 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 05:05:40 UTC, Jack Stouffer wrote: In Python, I can do this: my_obj = Obj() string_from_func = func() setattr(my_obj, string_from_func, 100) Say func() returns "member1" or "member2", the setattr would then set either one of those to 100. Is there any

Re: ErrnoException

2016-02-29 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 01:31:56 UTC, Jirka wrote: Ok, that would throw some OOM exception instead so I wouldn't need to bother with it, is there something else in the GC that would override it during class instance allocation? I am finding it weird that ErrnoException doesn't let you

Re: Backslash escaping weirdness

2016-02-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 04:48:01 UTC, Adam D. Ruppe wrote: On Tuesday, 1 March 2016 at 04:18:11 UTC, Nicholas Wilson wrote: What is causing these errors? I'm using \t and \n in string all over the place and they work. I don't think there's enough context to know for sure... but my guess

Member Access Based On A Runtime String

2016-02-29 Thread Jack Stouffer via Digitalmars-d-learn
In Python, I can do this: my_obj = Obj() string_from_func = func() setattr(my_obj, string_from_func, 100) Say func() returns "member1" or "member2", the setattr would then set either one of those to 100. Is there any equivalent in D?

Re: Backslash escaping weirdness

2016-02-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 1 March 2016 at 04:18:11 UTC, Nicholas Wilson wrote: What is causing these errors? I'm using \t and \n in string all over the place and they work. I don't think there's enough context to know for sure... but my guess is you forgot to close one of the quotes a couple lines above.

Backslash escaping weirdness

2016-02-29 Thread Nicholas Wilson via Digitalmars-d-learn
line 620: for(auto i = 1; i < pits3.length - 2; i++) { f.write(params3[i].fixup_T,"\t", pits3[i],","); } f.write(params3[$-2].fixup_T,"\t", pits3[$-1]); f.write(")\n\t\t{typeof(return) _p;\n\t\t", m2,"(",mainVarName); for(auto i = 1; i < pits3.length - 2; i++) {

Inline assembly and Profiling

2016-02-29 Thread Matthew Dudley via Digitalmars-d-learn
I'm working on a chess engine side-project, and I'm starting to get into profiling and optimization. One of the optimizations I've made involves some inline assembly, and I ran across some apparently bizarre behavior today, and I just wanted to double-check that I'm not doing something wrong.

Re: ErrnoException

2016-02-29 Thread Jirka via Digitalmars-d-learn
On Monday, 29 February 2016 at 23:41:51 UTC, Chris Wright wrote: On Mon, 29 Feb 2016 21:55:49 +, Jirka wrote: Yes, that I understand, but the "new" operator can lead to other system calls (?), could they overwrite it? Yes. Most obviously, the GC uses malloc, which will set errno to

Re: ErrnoException

2016-02-29 Thread Chris Wright via Digitalmars-d-learn
On Mon, 29 Feb 2016 21:55:49 +, Jirka wrote: > Yes, that I understand, but the "new" operator can lead to other system > calls (?), could they overwrite it? Yes. Most obviously, the GC uses malloc, which will set errno to ENOMEM on failure.

Re: D equivalent of run-time DLLs / Plugins

2016-02-29 Thread Ali Çehreli via Digitalmars-d-learn
On 02/29/2016 02:40 PM, Chris Katko wrote: I want to link to piece of D code at run-time. I want my D program to load, scan for files which are whatever D-equivalent of a DLL/SO is, and load those as well. Calling library functions, and having them call my core functions. It's the same as in

Re: D equivalent of run-time DLLs / Plugins

2016-02-29 Thread Chris Katko via Digitalmars-d-learn
On Monday, 29 February 2016 at 22:12:37 UTC, jmh530 wrote: On Monday, 29 February 2016 at 19:02:27 UTC, Chris Katko wrote: Hello. Dlang newbie here. Does D support run-time loading of D modules? Basically, I'm looking to create an application with a plugin interface. I've seen a few posts,

Re: D equivalent of run-time DLLs / Plugins

2016-02-29 Thread jmh530 via Digitalmars-d-learn
On Monday, 29 February 2016 at 19:02:27 UTC, Chris Katko wrote: Hello. Dlang newbie here. Does D support run-time loading of D modules? Basically, I'm looking to create an application with a plugin interface. I've seen a few posts, but they're dated and it's hard to keep up with "What is

Re: ErrnoException

2016-02-29 Thread Jirka via Digitalmars-d-learn
On Sunday, 28 February 2016 at 14:59:22 UTC, Mike Parker wrote: On Sunday, 28 February 2016 at 13:10:20 UTC, Jirka wrote: I have a question about ErrnoException. When I throw it (throw new ErrnoException()), won't it overwrite the errno value before it can capture it? Its constructor [1]

Re: Initialize associate array

2016-02-29 Thread Adam D. Ruppe via Digitalmars-d-learn
Use a constructor instead.

Re: Initialize associate array

2016-02-29 Thread cym13 via Digitalmars-d-learn
On Monday, 29 February 2016 at 21:03:46 UTC, pham wrote: Should codes below be compiled? import std.stdio; class Test { enum string[string] WorkAA = [ "foo": "work" ]; immutable string[string] NotWorkAA1 = [ "foo": "not

Initialize associate array

2016-02-29 Thread pham via Digitalmars-d-learn
Should codes below be compiled? import std.stdio; class Test { enum string[string] WorkAA = [ "foo": "work" ]; immutable string[string] NotWorkAA1 = [ "foo": "not work" ]; string[string] NotWorkAA2 =

Re: D equivalent of run-time DLLs / Plugins

2016-02-29 Thread Carsten Blüggel via Digitalmars-d-learn
On Monday, 29 February 2016 at 19:02:27 UTC, Chris Katko wrote: Hello. Dlang newbie here. Does D support run-time loading of D modules? Basically, I'm looking to create an application with a plugin interface. I've seen a few posts, but they're dated and it's hard to keep up with "What is

D equivalent of run-time DLLs / Plugins

2016-02-29 Thread Chris Katko via Digitalmars-d-learn
Hello. Dlang newbie here. Does D support run-time loading of D modules? Basically, I'm looking to create an application with a plugin interface. I've seen a few posts, but they're dated and it's hard to keep up with "What is the proper way to do X" when things change rapidly. Last thing I

Re: Assoc Array for Concurrency

2016-02-29 Thread ZombineDev via Digitalmars-d-learn
On Monday, 29 February 2016 at 12:43:39 UTC, Chris wrote: What's the best way to make an assoc array fit for multi-threading? If this is not possible what would be the best alternative? Say, for example, `data` is used by a class that is globally accessible to all threads. E.g. like this:

Re: Why we cannot use string in mixins?

2016-02-29 Thread Jesse Phillips via Digitalmars-d-learn
On Sunday, 28 February 2016 at 03:08:14 UTC, mahdi wrote: Thanks. So the author was plain wrong about using enums instead of strings. The misconception is due to assuming we can use `string` variables at compile time but we cannot (as they are run-time data). Not exactly either.

Re: Combining template conditions and contracts?

2016-02-29 Thread Daniel Kozak via Digitalmars-d-learn
auto square_root(T)(T x) if (isBasicType!T) in { assert(x >= 0); } out (result) { assert((result * result) <= x && (result+1) * (result+1) > x); } body { return cast(long)std.math.sqrt(cast(real)x); } void main() { import std.stdio: writeln; writeln(square_root(2)); } Dne

Re: Combining template conditions and contracts?

2016-02-29 Thread Daniel Kozak via Digitalmars-d-learn
Dne 29.2.2016 v 15:38 Ozan via Digitalmars-d-learn napsal(a): T square_root(T)(T x) if (isBasicType!T) { in { assert(x >= 0); } out (result) { assert((result * result) <= x && (result+1) * (result+1) > x); } body { return cast(long)std.math.sqrt(cast(real)x); } import

Re: Combining template conditions and contracts?

2016-02-29 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 29 February 2016 at 14:38:52 UTC, Ozan wrote: Is it possible to combine template conditions and contracts? Like in the following T square_root(T)(T x) if (isBasicType!T) { in { assert(x >= 0); } out (result) { assert((result * result) <= x && (result+1) * (result+1) > x);

Re: Why file.exists of relative path on Linux always return false?

2016-02-29 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 29 February 2016 at 14:58:46 UTC, Alex Parrill wrote: On Monday, 29 February 2016 at 14:50:51 UTC, Suliman wrote: I am trying to check relative path on Linux for exists. string mypath = "~/Documents/imgs"; ~ is expanded by your shell. It is not a relative path, and system calls

Why file.exists of relative path on Linux always return false?

2016-02-29 Thread Suliman via Digitalmars-d-learn
I am trying to check relative path on Linux for exists. import std.stdio; import std.path; import std.file; import std.string; string mypath = "~/Documents/imgs"; void main() { if(!mypath.exists) { writeln(mypath, " do not exists"); }

Re: Why file.exists of relative path on Linux always return false?

2016-02-29 Thread Alex Parrill via Digitalmars-d-learn
On Monday, 29 February 2016 at 14:50:51 UTC, Suliman wrote: I am trying to check relative path on Linux for exists. import std.stdio; import std.path; import std.file; import std.string; string mypath = "~/Documents/imgs"; void main() { if(!mypath.exists) {

Re: Am I right understand the dub.json system?

2016-02-29 Thread Suliman via Digitalmars-d-learn
On Monday, 29 February 2016 at 13:10:36 UTC, Edwin van Leeuwen wrote: On Monday, 29 February 2016 at 12:45:36 UTC, Suliman wrote: On Monday, 29 February 2016 at 12:34:02 UTC, Edwin van Leeuwen wrote: Should it be like this? http://www.everfall.com/paste/id.php?80k9jsgdx6o3 "versions":

Combining template conditions and contracts?

2016-02-29 Thread Ozan via Digitalmars-d-learn
Is it possible to combine template conditions and contracts? Like in the following T square_root(T)(T x) if (isBasicType!T) { in { assert(x >= 0); } out (result) { assert((result * result) <= x && (result+1) * (result+1) > x); } body { return cast(long)std.math.sqrt(cast(real)x);

Re: Am I right understand the dub.json system?

2016-02-29 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 29 February 2016 at 12:45:36 UTC, Suliman wrote: On Monday, 29 February 2016 at 12:34:02 UTC, Edwin van Leeuwen wrote: Should it be like this? http://www.everfall.com/paste/id.php?80k9jsgdx6o3 "versions": ["VibeCustomMain"], "versions": ["USE_MYSQL"], As far as I know all

Re: Am I right understand the dub.json system?

2016-02-29 Thread Suliman via Digitalmars-d-learn
On Monday, 29 February 2016 at 12:34:02 UTC, Edwin van Leeuwen wrote: On Monday, 29 February 2016 at 12:27:04 UTC, Suliman wrote: For example I have got app that depended on DDBC. In configuration section DDBC related on: "libs-posix": [ "sqlite3", "pq" ] Does it's mean that it will try to

Assoc Array for Concurrency

2016-02-29 Thread Chris via Digitalmars-d-learn
What's the best way to make an assoc array fit for multi-threading? If this is not possible what would be the best alternative? Say, for example, `data` is used by a class that is globally accessible to all threads. E.g. like this: string[string] data; // defined somewhere public string

Re: Am I right understand the dub.json system?

2016-02-29 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 29 February 2016 at 12:27:04 UTC, Suliman wrote: For example I have got app that depended on DDBC. In configuration section DDBC related on: "libs-posix": [ "sqlite3", "pq" ] Does it's mean that it will try to find this 2 libs in any case? Even I do not use them. If I do not

Am I right understand the dub.json system?

2016-02-29 Thread Suliman via Digitalmars-d-learn
For example I have got app that depended on DDBC. In configuration section DDBC related on: "libs-posix": [ "sqlite3", "pq" ] Does it's mean that it will try to find this 2 libs in any case? Even I do not use them. If I do not need them what I should to do? Fix ~/.dub/packages/ddbc and

Re: /usr/bin/ld: cannot find -levent_pthreads

2016-02-29 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-02-29 12:58, Guest62942 wrote: On Monday, 29 February 2016 at 11:48:35 UTC, Suliman wrote: I have never tried to build my code on Linux (Ubuntu). Now I have error: /usr/bin/ld: cannot find -levent /usr/bin/ld: cannot find -levent_pthreads Where I can get this lib?

Re: /usr/bin/ld: cannot find -levent_pthreads

2016-02-29 Thread Guest62942 via Digitalmars-d-learn
On Monday, 29 February 2016 at 11:48:35 UTC, Suliman wrote: I have never tried to build my code on Linux (Ubuntu). Now I have error: /usr/bin/ld: cannot find -levent /usr/bin/ld: cannot find -levent_pthreads Where I can get this lib?

/usr/bin/ld: cannot find -levent_pthreads

2016-02-29 Thread Suliman via Digitalmars-d-learn
I have never tried to build my code on Linux (Ubuntu). Now I have error: /usr/bin/ld: cannot find -levent /usr/bin/ld: cannot find -levent_pthreads Where I can get this lib?

Re: Why .length on Windows is int and on Linux is ulong?

2016-02-29 Thread ag0aep6g via Digitalmars-d-learn
On 29.02.2016 12:06, Suliman wrote: On Windows next code work fine: int len = fullimgurl.length; On Linux DMD get error that: Error: cannot implicitly convert expression (fullimgurl.length) of type ulong to int Why on every OS length have different size? On Windows, the compiler flag -m32 is

Re: Why .length on Windows is int and on Linux is ulong?

2016-02-29 Thread Rikki Cattermole via Digitalmars-d-learn
On 01/03/16 12:06 AM, Suliman wrote: On Windows next code work fine: int len = fullimgurl.length; On Linux DMD get error that: Error: cannot implicitly convert expression (fullimgurl.length) of type ulong to int Why on every OS length have different size? Its not OS dependent, its arch

Why .length on Windows is int and on Linux is ulong?

2016-02-29 Thread Suliman via Digitalmars-d-learn
On Windows next code work fine: int len = fullimgurl.length; On Linux DMD get error that: Error: cannot implicitly convert expression (fullimgurl.length) of type ulong to int Why on every OS length have different size?