Re: D equivalent of C++ reinterpret cast?

2010-09-20 Thread bearophile
Ali Çehreli: > I remember being a part of a discussion where D'is unions were told to > be exactly the same as C's. That means, results of using a union is only > specified when it's used through one its members. Writing to one member > and reading from another is unspecified. It is clear that

Re: Applying a tuple to a function (and more)

2010-09-20 Thread bearophile
Philippe Sigaud: > Oh, but you can iterate on an expression tuple alright, even when all its > elements have different types. I don't know why bearophile doesn't like that. I like the iteration on typetuples (the nomenclature here is a mess, see bug 4113), but you have to use such iteration with

Re: pure member functions

2010-09-20 Thread Don
Steven Schveighoffer wrote: On Mon, 20 Sep 2010 15:45:10 -0400, Don wrote: bearophile wrote: Jonathan M Davis: I assume that if you declare a member function as pure, then all of its parameters - including the invisible this - are included in that. That is, if all of them - including the i

Re: pure member functions

2010-09-20 Thread Steven Schveighoffer
On Mon, 20 Sep 2010 15:45:10 -0400, Don wrote: bearophile wrote: Jonathan M Davis: I assume that if you declare a member function as pure, then all of its parameters - including the invisible this - are included in that. That is, if all of them - including the invisible this - have the sa

Re: pure member functions

2010-09-20 Thread Don
bearophile wrote: Jonathan M Davis: I assume that if you declare a member function as pure, then all of its parameters - including the invisible this - are included in that. That is, if all of them - including the invisible this - have the same value, then the result will be the same. This

Re: Applying a tuple to a function (and more)

2010-09-20 Thread Philippe Sigaud
On Sun, Sep 19, 2010 at 18:33, Juanjo Alvarez wrote: > Philippe Sigaud wrote: > > > What languages are you used to? You seem to do quite well with genericity > > :) > > What I've done profesionally and personally in the last year would be 90% > Python, 5% Java and 5% C++. So yes, since Python is

Re: Copying a delegate

2010-09-20 Thread Jonathan M Davis
On Monday, September 20, 2010 04:08:11 Kagamin wrote: > Jonathan M Davis Wrote: > > I don't think that there's anything Phobos can do > > about it. It's a limitation of delegates. > > If the range doesn't support copying, it shouldn't pretend to support it, > and algorithms relying on copy won't c

Re: Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-20 Thread Jonathan M Davis
On Monday, September 20, 2010 04:11:05 Steven Schveighoffer wrote: > You don't want a deep copy of a range. All you want to copy is the > iteration state, not the data. > > save is definitely supposed to be shallow. I.e. you should copy the range > itself, not what the range points to. That mak

Re: Where is module dstats.all for dflplot?

2010-09-20 Thread Lars T. Kyllingstad
On Sat, 18 Sep 2010 07:15:35 -0400, Sam Hu wrote: > Greetings! > > I want to have a try on dflplot.But I don't find module dstats.all which > is used by dflplot.d,could anybody let me where it is? > > Thank you. Hi! David Simcha (the dflplot author) has changed the name of the library to Plo

Re: Purity with references and pointers

2010-09-20 Thread Kagamin
Jonathan M Davis Wrote: > If a pure function takes a reference/pointer, does that state that the result > of > the function will be the same on two calls to it if the reference/pointer > points > to the same data in both cases or if the data itself is unchanged? > > If it's a matter of pointi

Re: D equivalent of C++ reinterpret cast?

2010-09-20 Thread Steven Schveighoffer
On Sun, 19 Sep 2010 13:39:38 -0400, Bradley Mitchell wrote: Hello, I'm trying to implement the Quake 3 fast inverse square root algorithm which requires casting from int to float without modifying the stored bits. A C++ reinterpret cast seems to accomplish this just fine but so far I hav

Re: Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-20 Thread Steven Schveighoffer
On Sat, 18 Sep 2010 17:20:31 -0400, Jonathan M Davis wrote: On Saturday 18 September 2010 09:58:15 Steven Schveighoffer wrote: In reality, you cannot make save const, unless you want to do a deep copy (but I recommend against that, save should be a quick operation). Well, I was trying

Re: Copying a delegate

2010-09-20 Thread Kagamin
Jonathan M Davis Wrote: > I don't think that there's anything Phobos can do > about it. It's a limitation of delegates. If the range doesn't support copying, it shouldn't pretend to support it, and algorithms relying on copy won't compile.

Re: Purity with references and pointers

2010-09-20 Thread Don
Simen kjaeraas wrote: Jonathan M Davis wrote: Except that since when is anything implictly convertable to immutable? Implicitly converted to const, yes. That happens often enough, but immutable? Anything that does not contain pointers or references to non-immutable data is implicitly conver

Re: Copying a delegate

2010-09-20 Thread Jonathan M Davis
On Monday 20 September 2010 01:08:25 Kagamin wrote: > Jonathan M Davis Wrote: > > delegate by definition has context which is not going to be copied. So, > > any functon pointer or delegate that you have must refer to a function > > which is logically pure, otherwise any algorithm that relies on sa

Re: Copying a delegate

2010-09-20 Thread Kagamin
Jonathan M Davis Wrote: > delegate by definition has context which is not going to be copied. So, any > functon pointer or delegate that you have must refer to a function which is > logically pure, otherwise any algorithm that relies on save is not going to > work > correctly. If phobos cause

Re: D equivalent of C++ reinterpret cast?

2010-09-20 Thread Kagamin
Juanjo Alvarez Wrote: > Unions are not allowed in SafeD, so I guess they are considered > unsafe in D. They're safer in this particular case. Note how original poster forgot about taking and address.