Mimicking C++'s indexing behavior in D associative arrays

2015-02-17 Thread Matt Kline via Digitalmars-d-learn
In C++, the index operator for maps will either return a reference to the existing value if the key can be found, or a reference to a new, default-initialized value if one with the given key cannot be found. In D, an exception is thrown instead when a value with the given key cannot be

Re: Mimicking C++'s indexing behavior in D associative arrays

2015-02-17 Thread Matt Kline via Digitalmars-d-learn
On Wednesday, 18 February 2015 at 00:21:11 UTC, Matt Kline wrote: if (value) { should of course be if (!value) { Sorry for the typo.

Re: BigFloat?

2015-02-17 Thread Vlad Levenfeld via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 14:03:45 UTC, Kagamin wrote: On Tuesday, 17 February 2015 at 09:08:17 UTC, Vlad Levenfeld wrote: For my use case I'm less concerned with absolute resolution than with preserving the information in the smaller operand when dealing with large magnitude

Dividing D Module between multiple files

2015-02-17 Thread Muahmmad Adel via Digitalmars-d-learn
I have searched online and I found no way for dividing D Module between multiple files. While other languages move to making classes distributed on multiple files (like C#'s partial classes), D is moving in the opposite direction, and makes a bigger code unit in one file. Biding every

Re: Dividing D Module between multiple files

2015-02-17 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 18 Feb 2015 07:23:24 + Muahmmad Adel via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I have searched online and I found no way for dividing D Module between multiple files. While other languages move to making classes distributed on multiple files (like C#'s

Re: BigFloat?

2015-02-17 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 09:08:17 UTC, Vlad Levenfeld wrote: On Tuesday, 17 February 2015 at 08:05:49 UTC, Kagamin wrote: Periodic fractions. Or transcendental numbers, for that matter, but arbitrary != infinite. A max_expansion template parameter could be useful here. For my use

Re: Type-Strict Indexes: IndexedBy

2015-02-17 Thread anonymous via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 13:38:41 UTC, Per Nordlöw wrote: This looses most of the meaning of my idea. I still want my range to inherit all the powers of its wrapped range. Is there no way to disable member functions in D? I hadn't thought of @disable. Played around with it a bit. The

Re: Type-Strict Indexes: IndexedBy

2015-02-17 Thread via Digitalmars-d-learn
On Monday, 16 February 2015 at 20:17:55 UTC, anonymous wrote: Remove that `alias _r this;`. You don't want to forward opIndex, so you can't use alias this which forwards everything that doesn't compile. opDispatch may be an option to forward everything but opIndex. This looses most of the

Re: How to pass -rpath=$ORIGIN to the linker via dub?

2015-02-17 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 16 February 2015 at 23:49:31 UTC, 岩倉 澪 wrote: I'm looking to manage my current project with dub, but there is one problem that has been getting in my way. I want to use `-rpath=$ORIGIN`, which I can pass with `-L-rpath=\$ORIGIN` when directly invoking the compiler, but when putting

Re: BigFloat?

2015-02-17 Thread Kagamin via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 09:08:17 UTC, Vlad Levenfeld wrote: For my use case I'm less concerned with absolute resolution than with preserving the information in the smaller operand when dealing with large magnitude differences. What do you mean? As long as you don't change the operand,

Re: Error: getenv cannot be interpreted at compile time

2015-02-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 19:17:42 UTC, Paul wrote: I don't understand the error and Google doesn't help - can it be fixed or am I just using the wrong approach? Trying to create it as a global tries to make it as a static variable which means it constructs at compile time. It can't

Error: getenv cannot be interpreted at compile time

2015-02-17 Thread Paul via Digitalmars-d-learn
I'd like to create a Terminal using terminal.d and make it available across several source files (as a global rather than having to pass it around) but when I define it like this in global scope: Terminal Screen = Terminal(ConsoleOutputType.cellular); I get this error: Error: getenv cannot

Re: what is the offical way to handle multiple list in map() ?

2015-02-17 Thread Ali Çehreli via Digitalmars-d-learn
On 02/16/2015 01:51 AM, Baz wrote: For each language there is a column about handing multiple list, i thought it could be a good idea to see how D handle this: I've updated the page with my understanding: http://en.wikipedia.org/wiki/Map_(higher-order_function) I think they mean walking

Re: Error: getenv cannot be interpreted at compile time

2015-02-17 Thread ketmar via Digitalmars-d-learn
On Tue, 17 Feb 2015 19:56:19 +, Paul wrote: I see, thanks once again :D I don't know why the environment variable isn't accessible at compilation (from a terminal) 'cause you can't execute C code in CTFE. signature.asc Description: PGP signature

Re: A specifier readf() for BigInt

2015-02-17 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 07:20:19 UTC, Ivan Kazmenko wrote: The readf function does not seem to support reading BigInts directly. However, you can read a string and construct a BigInt from it, either by std.conv.to or directly invoking the constructor: import std.algorithm,

Re: Type-Strict Indexes: IndexedBy

2015-02-17 Thread Nordlöw
On Tuesday, 17 February 2015 at 15:02:05 UTC, anonymous wrote: I hadn't thought of @disable. Played around with it a bit. The following code seems to work. I didn't really test it or think very hard about it, though. Superb! I'd like to see this getting into std.typecons. Having this in the

Re: Error: getenv cannot be interpreted at compile time

2015-02-17 Thread Paul via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 19:35:27 UTC, H. S. Teoh wrote: On Tue, Feb 17, 2015 at 07:17:41PM +, Paul via Digitalmars-d-learn wrote: I'd like to create a Terminal using terminal.d and make it available across several source files (as a global rather than having to pass it around) but

Re: Error: getenv cannot be interpreted at compile time

2015-02-17 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Feb 17, 2015 at 07:17:41PM +, Paul via Digitalmars-d-learn wrote: I'd like to create a Terminal using terminal.d and make it available across several source files (as a global rather than having to pass it around) but when I define it like this in global scope: Terminal Screen =

Re: Error: getenv cannot be interpreted at compile time

2015-02-17 Thread Paul via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 19:29:52 UTC, Adam D. Ruppe wrote: On Tuesday, 17 February 2015 at 19:17:42 UTC, Paul wrote: I don't understand the error and Google doesn't help - can it be fixed or am I just using the wrong approach? Trying to create it as a global tries to make it as a

Re: Error: getenv cannot be interpreted at compile time

2015-02-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 20:06:15 UTC, Paul wrote: There doesn't seem to be an alternative to using a pointer as it's rather a large struct to pass to functions as is! yeah, copying is disabled too. The struct isn't big in memory terms (it has few actual data members) but since the

Re: BigFloat?

2015-02-17 Thread Kagamin via Digitalmars-d-learn
Periodic fractions.

Re: Error: getenv cannot be interpreted at compile time

2015-02-17 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Feb 17, 2015 at 07:56:19PM +, Paul via Digitalmars-d-learn wrote: [...] I see, thanks once again :D I don't know why the environment variable isn't accessible at compilation (from a terminal) but that's OS business I guess rather than D related. Even if you *could* access it at

Re: BigFloat?

2015-02-17 Thread Vlad Levenfeld via Digitalmars-d-learn
On Tuesday, 17 February 2015 at 08:05:49 UTC, Kagamin wrote: Periodic fractions. Or transcendental numbers, for that matter, but arbitrary != infinite. A max_expansion template parameter could be useful here. For my use case I'm less concerned with absolute resolution than with preserving