Re: dup and arrays

2010-03-27 Thread Philippe Sigaud
On Sat, Mar 27, 2010 at 03:34, strtr st...@spam.com wrote: Ellery Newcomer Wrote: I just noticed that dup does not dup deep. In a two second search I couldn't find any reason for or against, but I'd kinda like it if auto r2 = r.dup; r2[i][j] = 0; r[i][j] = 1; assert(r2[i][j]

generic + numeric + literals = abomination

2010-03-27 Thread so
In C++! I have a type defined in the core library like.. typedef float scalar; //typedef double scalar; // -- whole framework is now double precision Next i instantiate vectors, matrices etc... from templates. typedef vector_tscalar, 3 vector; typedef matrix_tscalar, 3, 3 matrix; Until now

Re: generic + numeric + literals = abomination

2010-03-27 Thread Robert Clipsham
On 27/03/10 10:20, so wrote: In C++! I have a type defined in the core library like.. typedef float scalar; //typedef double scalar; // -- whole framework is now double precision alias float scalar; //alias double scalar; Next i instantiate vectors, matrices etc... from templates. typedef

Re: generic + numeric + literals = abomination

2010-03-27 Thread bearophile
so: Since D is superb, i like to know how you do it in D. If you got a better idea in C++, i would like to hear that too! You know there are float literal too, in C++/D, like: 5.5f I don't think D can help you more than C++ here. Can you explain better what the problem is and what kind of

Re: generic + numeric + literals = abomination

2010-03-27 Thread so
On Sat, 27 Mar 2010 13:52:28 +0200, bearophile bearophileh...@lycos.com wrote: so: Since D is superb, i like to know how you do it in D. If you got a better idea in C++, i would like to hear that too! You know there are float literal too, in C++/D, like: 5.5f I don't think D can help you

Re: generic + numeric + literals = abomination

2010-03-27 Thread so
On Sat, 27 Mar 2010 13:32:24 +0200, Robert Clipsham rob...@octarineparrot.com wrote: On 27/03/10 10:20, so wrote: In C++! I have a type defined in the core library like.. typedef float scalar; //typedef double scalar; // -- whole framework is now double precision alias float scalar;

Re: generic + numeric + literals = abomination

2010-03-27 Thread so
On Sat, 27 Mar 2010 13:52:28 +0200, bearophile bearophileh...@lycos.com wrote: Can you explain better what the problem is and what kind of solution you would like? Bye, bearophile One thing i can think of now is adding another float literal, maybe 'r', for real!, Which means you are

Re: generic + numeric + literals = abomination

2010-03-27 Thread bearophile
so: One thing i can think of now is adding another float literal, maybe 'r', for real!, See here, Unfortunately it's called L not r: http://www.digitalmars.com/d/2.0/lex.html FloatSuffix: f F RealSuffix: L bearophile

Re: generic + numeric + literals = abomination

2010-03-27 Thread Bill Baxter
Note that 'real' is a built in type in D. It's an 80-bit float on x86 procs and 64-bit elsewhere. So .5L is like cast(real).5. Not the solution you were looking for. --bb 2010/3/27 so s...@so.do: On Sat, 27 Mar 2010 15:28:22 +0200, bearophile bearophileh...@lycos.com wrote: so: One thing

Re: generic + numeric + literals = abomination

2010-03-27 Thread so
On Sat, 27 Mar 2010 12:20:38 +0200, so s...@so.do wrote: I haven't seen a single C++ library able to do this properly. (I would just copy it!) This is one of the reasons why something like std::numeric_limitstype::function() exists. Which makes a generic and *clean* numeric code in C++

Re: initializing immutable structs

2010-03-27 Thread Simen kjaeraas
On Fri, 26 Mar 2010 06:35:29 +0100, Paul D. Anderson paul.d.removethis.ander...@comcast.andthis.net wrote: I want to initialize an immutable struct but I'm encountering two difficulties and I can't find the answer in the documentation. (Wouldn't it be nice if someone wrote a book?) You

Re: Never called destructor

2010-03-27 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Don wrote: div0 wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Same as bug 3285 / bug 3516? No, they are for structs, not classes. I had a bit more of a play, and it seems that the scope object is on the stack, so it's memory is

Re: generic + numeric + literals = abomination

2010-03-27 Thread so
On Sat, 27 Mar 2010 15:54:19 +0200, Bill Baxter wbax...@gmail.com wrote: Note that 'real' is a built in type in D. It's an 80-bit float on x86 procs and 64-bit elsewhere. So .5L is like cast(real).5. Not the solution you were looking for. --bb That r for real! was joke. What i mean is a

Re: generic + numeric + literals = abomination

2010-03-27 Thread bearophile
so: When i have the code : scalar m = 0.5fp; I want compiler to implicitly cast it to typeof(scalar). so when the scalar is float, m will be 0.5f. I am starting to understand, sorry if I am a dumb bear :-) Programming in C++/D is usually much less hard than understanding humans. I think

non halting regex

2010-03-27 Thread Ellery Newcomer
Is this program expected to terminate? D 2.042 module test; import std.regex; import std.stdio; void main(){ foreach(m; match(hello world,`.*`)){ writefln(%s[%s]%s,m.pre,m.hit,m.post); } }

Re: generic + numeric + literals = abomination

2010-03-27 Thread Jesse Phillips
I think you would end up creating a scalar class/struct with operator overloading to get the behavior you are looking for. I realize that is more overhead than what you would want but I don't see another way. so wrote: In C++! I have a type defined in the core library like.. typedef float

Re: generic + numeric + literals = abomination

2010-03-27 Thread so
Oh... wait a second. In http://www.digitalmars.com/d/2.0/float.html : Regardless of the type of the operands, floating point constant folding is done in real or greater precision. It is always done following IEEE 754 rules and round-to-nearest is used. Floating point constants are

Re: DMD on x86_64

2010-03-27 Thread Alvin Majik
tried the your approach it worked but compile cpp applications fails. [Sanity Checks - fails] i found my way arround it by installing cross32-gcc and adding CC=/usr/bin/i686-unknown-linux-gnu-gcc to the dmd.conf file I have added the procedure to Wiki4D

Re: generic + numeric + literals = abomination

2010-03-27 Thread biozic
Le 27/03/10 18:18, so a écrit : With this in mind, just one thing bugs me. import std.stdio; struct vector(T) { this(T m) { mm = m; } vector!T opBinary(string s)(T m) if(s==*) { return vector!T(mm * m); } T mm; } void test(T)() { vector!T v = vector!T(0.5); vector!T u = v * 0.3;

Re: generic + numeric + literals = abomination

2010-03-27 Thread bearophile
so: With this in mind, just one thing bugs me. import std.stdio; struct vector(T) { this(T m) { mm = m; } vector!T opBinary(string s)(T m) if(s==*) { return vector!T(mm * m); } T mm; } void test(T)() { vector!T v = vector!T(0.5);

gc

2010-03-27 Thread sclytrack
Is it possible to have multiple gc

Re: generic + numeric + literals = abomination

2010-03-27 Thread so
With one exception yes, i want all 3 test pass with your fix to implicit cast. You know, we are trying to write generic code. Thanks! On Sat, 27 Mar 2010 22:21:46 +0200, bearophile bearophileh...@lycos.com wrote: Are you trying to do this? import std.stdio: writeln; struct Vector(T) {