Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Maxim Fomin
On Saturday, 13 October 2012 at 22:34:19 UTC, H. S. Teoh wrote: OK, before this thread devolves into a shouting match, I'd like to understand what was the rationale behind this restriction. What were the reasons behind not allowing a non-member function to overload an operator? What are the

Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Maxim Fomin
On Saturday, 13 October 2012 at 17:01:27 UTC, Tommi wrote: Another way to describe my reasoning... According to TDPL, if var is a variable of a user-defined type, then: ++var gets rewritten as: var.opUnary!++() Not always. If user-defined type has an alias this to integer member, than

COM Example work for anyone?

2012-10-14 Thread Jesse Phillips
The dmd compiler comes with some example code. One of the examples is for COM. Does this work for anyone else? The dll registration code is failing: SetKeyAndValue() failed. Other output looks good: OLE 2 initialized hMod = 268435456 LoadLibraryA() succeeded pfn = 100033E0, fn =

Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Tommi
On Sunday, 14 October 2012 at 06:22:03 UTC, Maxim Fomin wrote: On Saturday, 13 October 2012 at 17:01:27 UTC, Tommi wrote: Another way to describe my reasoning... According to TDPL, if var is a variable of a user-defined type, then: ++var gets rewritten as: var.opUnary!++() Not always. If

Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Maxim Fomin
On Saturday, 13 October 2012 at 19:50:02 UTC, Timon Gehr wrote: On 10/13/2012 06:02 PM, Maxim Fomin wrote: ... Different groups of people have different mind and same things produce different sense on them. From my point of view operator overloading methods are special functions and not

Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Maxim Fomin
On Sunday, 14 October 2012 at 07:01:30 UTC, Tommi wrote: Actually, it seems that alias this has precedence over UFCS. So, a free function opUnary wouldn't ever suit better than an actual method opUnary of the thing referred to by that alias this. http://dpaste.dzfl.pl/d0a4431d Free function

Re: equivalent of c++ private inheritance with using

2012-10-14 Thread Dan
On Friday, 12 October 2012 at 23:05:27 UTC, Jonathan M Davis wrote: You can have the variable be private and alias a function which returns by ref instead of the variable itself. Something like class C { @property ref inout(Impl) get() inout { return _impl; } alias get this; private:

What am I doing wrong here?

2012-10-14 Thread Martin
Hey everyone, I'm new to D so bare with me please. I've been trying to figure out what's up with the strange forward refernce errors the compiler (DMD 2.060) is giving me. Here's a code snippet that's generating a forward reference error: public class AliasTestClass(alias func) {

Re: What am I doing wrong here?

2012-10-14 Thread Simen Kjaeraas
On 2012-10-14, 14:28, Martin wrote: Hey everyone, I'm new to D so bare with me please. I've been trying to figure out what's up with the strange forward refernce errors the compiler (DMD 2.060) is giving me. Here's a code snippet that's generating a forward reference error: public class

Re: What am I doing wrong here?

2012-10-14 Thread Martin
On Sunday, 14 October 2012 at 12:58:24 UTC, Simen Kjaeraas wrote: On 2012-10-14, 14:28, Martin wrote: Hey everyone, I'm new to D so bare with me please. I've been trying to figure out what's up with the strange forward refernce errors the compiler (DMD 2.060) is giving me. Here's a code

Re: Ignoring defaults from sc.ini?

2012-10-14 Thread Andrej Mitrovic
On 10/14/12, Benjamin Thaut c...@benjamin-thaut.de wrote: Is there a way to make dmd ignore the default imports and library search paths inside sc.ini? See http://dlang.org/dmd-windows.html#sc_ini

Re: How many std.concurrency receivers?

2012-10-14 Thread Sean Kelly
On Oct 12, 2012, at 2:29 AM, Russel Winder rus...@winder.org.uk wrote: On Thu, 2012-10-11 at 20:30 -0700, Charles Hixson wrote: […] I'm not clear on what Fibers are. From Ruby they seem to mean co-routines, and that doesn't have much advantage. But it also seems as […] I think the

Re: How many std.concurrency receivers?

2012-10-14 Thread Dmitry Olshansky
On 14-Oct-12 20:19, Sean Kelly wrote: On Oct 12, 2012, at 2:29 AM, Russel Winder rus...@winder.org.uk wrote: On Thu, 2012-10-11 at 20:30 -0700, Charles Hixson wrote: […] I'm not clear on what Fibers are. From Ruby they seem to mean co-routines, and that doesn't have much advantage. But it

Re: Ignoring defaults from sc.ini?

2012-10-14 Thread Jacob Carlborg
On Sunday, 14 October 2012 at 09:40:36 UTC, Benjamin Thaut wrote: Is there a way to make dmd ignore the default imports and library search paths inside sc.ini? Currently I have to keep two versions of dmd around, one with a modified sc.ini and one with the original one, which is a bit

Re: COM Example work for anyone?

2012-10-14 Thread Richard Webb
I haven't tried to run it, but as a random guess, does the user your running it as have permissions to write to HKEY_CLASSES_ROOT ?

Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Artur Skawina
On 10/14/12 08:13, Maxim Fomin wrote: The only mentioned reason is to allow writing operator overloading methods outside type scope - just because somebody (currently two people) consider it logical to broaden UFCS usage. It's more than two people... Also, it's not about broadening UFCS

Re: Operator overloading through UFCS doesn't work

2012-10-14 Thread Tommi
On Sunday, 14 October 2012 at 07:14:25 UTC, Maxim Fomin wrote: If this request is approved and compiler has opUnary definition outside type (which suits better then alias this) such function would hijack alias this. Free functions cannot and must not ever hijack, i.e. modify existing

Re: COM Example work for anyone?

2012-10-14 Thread Jesse Phillips
On Sunday, 14 October 2012 at 19:04:22 UTC, Richard Webb wrote: I haven't tried to run it, but as a random guess, does the user your running it as have permissions to write to HKEY_CLASSES_ROOT ? Guess that would be it. Specifically told the program to run as admin and it works. Should have

Re: toStringz note about keeping references

2012-10-14 Thread Jonathan M Davis
On Sunday, October 14, 2012 23:38:48 Andrej Mitrovic wrote: toStringz takes a string (immutable(char)[]), and the GC will not reclaim immutable data until app exit. If the GC never collects immutable data which has no references to it until the app closes, then there's a serious problem.

Re: toStringz note about keeping references

2012-10-14 Thread Jonathan M Davis
On Monday, October 15, 2012 00:51:34 Andrej Mitrovic wrote: On 10/15/12, Jonathan M Davis jmdavisp...@gmx.com wrote: Anything and everything with no references to it any longer should be up for collection. I think this is fuzzy territory and it's a good opportunity to properly document GC

Re: toStringz note about keeping references

2012-10-14 Thread Andrej Mitrovic
On 10/15/12, Jonathan M Davis jmdavisp...@gmx.com wrote: I'd have to see exactly what TDPL says to comment on that accurately Maybe I've misread it. On Page 288 it says: An immutable value is cast in stone: as soon as it's been initialized, you may as well consider it has been burned forever

Re: toStringz note about keeping references

2012-10-14 Thread Ali Çehreli
On 10/14/2012 04:36 PM, Andrej Mitrovic wrote: On 10/15/12, Jonathan M Davisjmdavisp...@gmx.com wrote: I'd have to see exactly what TDPL says to comment on that accurately Maybe I've misread it. On Page 288 it says: An immutable value is cast in stone: as soon as it's been initialized,

Re: toStringz note about keeping references

2012-10-14 Thread Jonathan M Davis
On Monday, October 15, 2012 01:36:27 Andrej Mitrovic wrote: On 10/15/12, Jonathan M Davis jmdavisp...@gmx.com wrote: I'd have to see exactly what TDPL says to comment on that accurately Maybe I've misread it. On Page 288 it says: An immutable value is cast in stone: as soon as it's been

Re: toStringz note about keeping references

2012-10-14 Thread Andrej Mitrovic
On 10/15/12, Jonathan M Davis jmdavisp...@gmx.com wrote: snip Hmm ok, this sheds some light on things. If a C function takes a const pointer and has no documentation about ownership then maybe it's a good guess to say it won't store that pointer anywhere and will only use it as a temporary?

Re: toStringz note about keeping references

2012-10-14 Thread Jonathan M Davis
On Monday, October 15, 2012 02:04:44 Andrej Mitrovic wrote: On 10/15/12, Jonathan M Davis jmdavisp...@gmx.com wrote: snip Hmm ok, this sheds some light on things. If a C function takes a const pointer and has no documentation about ownership then maybe it's a good guess to say it won't

Re: How many std.concurrency receivers?

2012-10-14 Thread Sean Kelly
On Oct 14, 2012, at 9:59 AM, Dmitry Olshansky dmitry.o...@gmail.com wrote: On 14-Oct-12 20:19, Sean Kelly wrote: On Oct 12, 2012, at 2:29 AM, Russel Winder rus...@winder.org.uk wrote: On Thu, 2012-10-11 at 20:30 -0700, Charles Hixson wrote: […] I'm not clear on what Fibers are. From Ruby

Re: To: Johannes Pfau

2012-10-14 Thread Artur Skawina
On 10/15/12 02:14, Andrej Mitrovic wrote: Johannes, are you still working on gobject introspection? libgit has gobject bindings so I remembered you mentioning something about working on gobject for D. FWIW gobject bindings are part of my gtk2 bindings too;

Re: std.stream, BOM, and deprecation

2012-10-14 Thread Nick Sabalausky
On Sat, 13 Oct 2012 18:53:48 -0700 Charles Hixson charleshi...@earthlink.net wrote: If std.stream is being deprecated, what is the correct way to deal with file BOMs. This is particularly concerning utf8 files, which I understand to be a bit problematic, as there isn't, actually, a utf8

Specifying precision in %(...%) print format

2012-10-14 Thread H. S. Teoh
I have an array of reals that I want to format with writefln, but the precision field needs to be passed in a variable. For a single real, it would be writefln(%.*f, precision, x); but when I try this: int precision = ...; real[] array = ...; writefln(%(%.*f, %),

Re: Specifying precision in %(...%) print format

2012-10-14 Thread Ali Çehreli
On 10/14/2012 10:43 PM, H. S. Teoh wrote: I have an array of reals that I want to format with writefln, but the precision field needs to be passed in a variable. For a single real, it would be writefln(%.*f, precision, x); but when I try this: int precision = ...; real[] array =