Is this a bug?

2014-05-04 Thread Alex via Digitalmars-d-learn
Hello, I am trying to use the std.log module that is here: https://github.com/linkrope/log.d And I encountered a segmentation fault using dmd 2.065 on a Linux 64 platform. The reduced test case is this: // import

Trailing commas in constructor arguments?

2014-05-04 Thread Gary Willoughby via Digitalmars-d-learn
In the following snippet is the line marked WOAH legal? The compiler doesn't complain about the trailing comma in the constructor arguments. import std.stdio; class Foo { public this(string foo) { } } void main(string[] args) { auto foo = new Foo(bar, ); // --

Re: Trailing commas in constructor arguments?

2014-05-04 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 4 May 2014 at 10:04:26 UTC, Gary Willoughby wrote: In the following snippet is the line marked WOAH legal? The compiler doesn't complain about the trailing comma in the constructor arguments. import std.stdio; class Foo { public this(string foo) { } } void

Re: Is this a bug?

2014-05-04 Thread Mike Parker via Digitalmars-d-learn
On 5/4/2014 6:42 PM, Alex wrote: Hello, I am trying to use the std.log module that is here: https://github.com/linkrope/log.d And I encountered a segmentation fault using dmd 2.065 on a Linux 64 platform. The reduced test case is this:

Re: Is this a bug?

2014-05-04 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 4 May 2014 at 09:42:17 UTC, Alex wrote: Hello, I am trying to use the std.log module that is here: https://github.com/linkrope/log.d And I encountered a segmentation fault using dmd 2.065 on a Linux 64 platform. The reduced test case is this:

Re: Is this a bug?

2014-05-04 Thread monarch_dodra via Digitalmars-d-learn
On Sunday, 4 May 2014 at 10:28:30 UTC, Mike Parker wrote: The current implementation of the GC will run destructors on any objects still resident on the heap during termination. There is no way to guarantee the order in which those destructors will be run. Most likely, what you're seeing is

Re: Is this a bug?

2014-05-04 Thread bearophile via Digitalmars-d-learn
monarch_dodra: As rule of thumb, you can't allocate during a GC cleaning cycles, and class destructors are usually called during a GC cleaning cycle. This means it is usually unsafe to call *anything* that could potentially allocate in a destructor. So it could be a good idea to have

Re: const ref parameters and r-value references

2014-05-04 Thread via Digitalmars-d-learn
On Friday, 2 May 2014 at 21:29:51 UTC, Mark Isaacson wrote: Auto ref parameters seem to be just what I need. Thanks! I'd still be curious if anyone has additional information regarding the rationale at play (I'm spoiled, reading TDPL and having each decision explained in text). I had the

Re: const ref parameters and r-value references

2014-05-04 Thread Timon Gehr via Digitalmars-d-learn
On 05/04/2014 12:58 PM, Marc Schütz schue...@gmx.net wrote: This means that you will still get a (bit-wise) copy if you pass in an r-value. But semantically, this is a move, not a copy, so it is potentially cheaper than a copy (if your type has an expensive postblit). It can be constructed

Re: const ref parameters and r-value references

2014-05-04 Thread via Digitalmars-d-learn
On Sunday, 4 May 2014 at 11:15:59 UTC, Timon Gehr wrote: On 05/04/2014 12:58 PM, Marc Schütz schue...@gmx.net wrote: This means that you will still get a (bit-wise) copy if you pass in an r-value. But semantically, this is a move, not a copy, so it is potentially cheaper than a copy (if your

Re: const ref parameters and r-value references

2014-05-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Fri, 02 May 2014 08:17:06 + Mark Isaacson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I'm in the process of learning/practicing D and I noticed something that seems peculiar coming from a C++ background: If I compile and run: void fun(const ref int x) {

Re: const ref parameters and r-value references

2014-05-04 Thread bearophile via Digitalmars-d-learn
Jonathan M Davis: Andrei suggested auto ref to fix this problem, and Walter implemented it, but he misunderstood what Andrei had meant, I missed this detail of the story :-) Walter has suggested that we just redefine ref itself to do what I just described rather than using auto ref or

Re: Conversion and Assignment on EnumUnion and EnumChain

2014-05-04 Thread Nordlöw
I would now like to define rules for assignments and implicit conversions with the following checks I believe I found a good solution through struct wrappers. See update at: https://github.com/nordlow/justd/blob/master/enums.d

Template mixins has no effect

2014-05-04 Thread Nordlöw
I'm trying to improve https://github.com/nordlow/justd/blob/master/enums.d through use of template mixins http://dlang.org/template-mixin.html to improve EnumUnion as follows: struct EnumUnion(E...) { alias OriginalType = CommonOriginalType!E; alias U = UnionEnum!(E);// Wrapped

Re: Math-Parser

2014-05-04 Thread Tim Holzschuh via Digitalmars-d-learn
Am 03.05.2014 21:47, schrieb Timon Gehr via Digitalmars-d-learn: On 05/03/2014 08:20 PM, Tim Holzschuh via Digitalmars-d-learn wrote: Let me know if you also want hints on how to get the logic right. Would be very nice! While 2*2 works, 2+2 throws an Error because the number-method gets an

Re: Is this a bug?

2014-05-04 Thread Mike Parker via Digitalmars-d-learn
On 5/4/2014 7:39 PM, monarch_dodra wrote: Really??? I knew there was no guarantee in which order the destructor were run, but at the very least, I thought you had a guarantee of dependency ordering? Furthermore, the order in which the garbage collector calls destructors for unreference

strange error with std.net.curl

2014-05-04 Thread Suliman via Digitalmars-d-learn
I am trying to compile next code: import std.net.curl; import std.stdio; void main() { writeln(get(https://google.com/;)); } and got next error http://www.everfall.com/paste/id.php?y37dr6qmu54h

Signals far from Slots

2014-05-04 Thread Jim Hewes via Digitalmars-d-learn
Is there a good way to connect signals and slots when the objects are far apart? All tutorials for signals and slots show the objects being readily accessible by the main() function. But what if they're not? Is there an elegant design? For example, here's a typical minimal demo:

Re: Reading ELF Files

2014-05-04 Thread yazd via Digitalmars-d-learn
On Friday, 2 May 2014 at 15:25:55 UTC, Nordlöw wrote: On Friday, 2 May 2014 at 10:42:40 UTC, yazd wrote: On Thursday, 1 May 2014 at 17:31:52 UTC, Nordlöw wrote: Here you go, https://github.com/yazd/elf-d. Thanks! Anytime. By the way, if you need more stuff out of it or help, post an issue

Re: Reading ELF Files

2014-05-04 Thread Nordlöw
On Sunday, 4 May 2014 at 18:11:45 UTC, yazd wrote: On Friday, 2 May 2014 at 15:25:55 UTC, Nordlöw wrote: On Friday, 2 May 2014 at 10:42:40 UTC, yazd wrote: On Thursday, 1 May 2014 at 17:31:52 UTC, Nordlöw wrote: Here you go, https://github.com/yazd/elf-d. Thanks! Anytime. By the way, if

Re: const ref parameters and r-value references

2014-05-04 Thread Mark Isaacson via Digitalmars-d-learn
Thanks for the insights! I suppose we'll get a chance to see where things stand at this year's dconf. It's quite interesting that D's concept of r-values seems less developed than C++. Here's hoping that that only results in a better thought out solution.

Re: Is this a bug?

2014-05-04 Thread Alex via Digitalmars-d-learn
On Sunday, 4 May 2014 at 10:28:30 UTC, Mike Parker wrote: On 5/4/2014 6:42 PM, Alex wrote: Hello, I am trying to use the std.log module that is here: https://github.com/linkrope/log.d And I encountered a segmentation fault using dmd 2.065 on a Linux 64 platform. The reduced test case is

Re: Is this a bug?

2014-05-04 Thread bearophile via Digitalmars-d-learn
Alex: Why the compiler does not complain or, I've just asked something related to this in the main D newsgroup, take a look there for answers. Today D has means to complain statically. But I don't know the fate of D class destructors. Bye, bearophile

Re: Template mixins has no effect

2014-05-04 Thread Nordlöw
What is wrong? For some reason the mixin declarations for op* are not imported into the calling scope when others are. Compiler bug?

C++ std::map equivalent? (An in-order iterable associative container)

2014-05-04 Thread Mark Isaacson via Digitalmars-d-learn
I'm looking for a means to associate a key with a value and iterate over said container in-order. My natural choice in C++ would be std::map. When I look in std.container, I see that there is a RedBlackTree implementation, however this does not associate a key with a value (it is the

Re: C++ std::map equivalent? (An in-order iterable associative container)

2014-05-04 Thread bearophile via Digitalmars-d-learn
Mark Isaacson: 2) Create a wrapper struct that contains key and value and whose comparison operator is defined only on the key. This would essentially be doing what the C++ implementation does. Until we have a tree-based associative map, use a tuple for the key-value and define a less

Re: C++ std::map equivalent? (An in-order iterable associative container)

2014-05-04 Thread Mark Isaacson via Digitalmars-d-learn
On Sunday, 4 May 2014 at 21:40:04 UTC, bearophile wrote: Mark Isaacson: 2) Create a wrapper struct that contains key and value and whose comparison operator is defined only on the key. This would essentially be doing what the C++ implementation does. Until we have a tree-based associative

Re: C++ std::map equivalent? (An in-order iterable associative container)

2014-05-04 Thread bearophile via Digitalmars-d-learn
Mark Isaacson: Got it, no native support. Most unfortunate. What native support are you talking about? I've always been vehemently against losing self-documentation via the std::pair/tuple based solution to the problem. What self documentation are you losing in D? I ended up rolling my

Re: C++ std::map equivalent? (An in-order iterable associative container)

2014-05-04 Thread Dicebot via Digitalmars-d-learn
On Sunday, 4 May 2014 at 21:40:04 UTC, bearophile wrote: Mark Isaacson: 2) Create a wrapper struct that contains key and value and whose comparison operator is defined only on the key. This would essentially be doing what the C++ implementation does. Until we have a tree-based associative

Re: C++ std::map equivalent? (An in-order iterable associative container)

2014-05-04 Thread Dicebot via Digitalmars-d-learn
On Sunday, 4 May 2014 at 22:25:36 UTC, bearophile wrote: Dicebot: What benefits this gives over definining distinct struct? Sounds like unnecessary complication for me. See the code in my precedent post, what do you think about it? Bye, bearophile Change alias Two =

Re: C++ std::map equivalent? (An in-order iterable associative container)

2014-05-04 Thread bearophile via Digitalmars-d-learn
Dicebot: What benefits this gives over definining distinct struct? Sounds like unnecessary complication for me. See the code in my precedent post, what do you think about it? Bye, bearophile

Re: Math-Parser

2014-05-04 Thread Timon Gehr via Digitalmars-d-learn
On 05/04/2014 04:56 PM, Tim Holzschuh via Digitalmars-d-learn wrote: Am 03.05.2014 21:47, schrieb Timon Gehr via Digitalmars-d-learn: On 05/03/2014 08:20 PM, Tim Holzschuh via Digitalmars-d-learn wrote: Let me know if you also want hints on how to get the logic right. Would be very nice!

Re: C++ std::map equivalent? (An in-order iterable associative container)

2014-05-04 Thread Mark Isaacson via Digitalmars-d-learn
Interesting. I clearly have more to learn about Tuple. I think I concur with Dicebot's alterations for self-documentation. Thanks for all of your suggestions gentlemen.

Re: C++ std::map equivalent? (An in-order iterable associative container)

2014-05-04 Thread Ary Borenszweig via Digitalmars-d-learn
On 5/4/14, 6:04 PM, Mark Isaacson wrote: I'm looking for a means to associate a key with a value and iterate over said container in-order. My natural choice in C++ would be std::map. When I look in std.container, I see that there is a RedBlackTree implementation, however this does not associate

Re: const ref parameters and r-value references

2014-05-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Sun, 04 May 2014 19:08:27 + Mark Isaacson via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Thanks for the insights! I suppose we'll get a chance to see where things stand at this year's dconf. It's quite interesting that D's concept of r-values seems less developed

Re: Math-Parser

2014-05-04 Thread Meta via Digitalmars-d-learn
You could replace all those `op=='+'||op=='-'? ...` with `op.among!('+', '-')? ...`.

Need help with movement from C to D

2014-05-04 Thread Andrey via Digitalmars-d-learn
Guys, could someone help me with suitable template? I have C macro, which calculates the offset of the field in a struct: #define offsetof(type, field) ((long) ((type *)0)-field) A similar D code is, as far as I know, type.field.offsetof Is there an any way to make a corresponding D

Re: Need help with movement from C to D

2014-05-04 Thread Mark Isaacson via Digitalmars-d-learn
On Monday, 5 May 2014 at 03:57:54 UTC, Andrey wrote: Guys, could someone help me with suitable template? I have C macro, which calculates the offset of the field in a struct: #define offsetof(type, field) ((long) ((type *)0)-field) A similar D code is, as far as I know,