math.pow fails at compile-time; is this a bug?

2012-08-19 Thread Caligo
template T(){ enum a = pow(3.0, 2); enum b = pow(3, 2.0); } unittest { alias T!() t; } compiling that I get: /home/b/phobos/std/math.d(2369): Error: Cannot convert real to ushort* at compile time /home/b/phobos/std/math.d(3292):called from here: isNaN(y)

Re: Static Associative Arrays

2012-04-08 Thread Caligo
On Sat, Apr 7, 2012 at 11:01 PM, Jonathan M Davis jmdavisp...@gmx.com wrote: What do you mean my static associative arrays? Are you asking why you can't initialize a static variable which is an AA at compile time? e.g. - Jonathan M Davis The same way I can create a static array: int[4] =

Static Associative Arrays

2012-04-07 Thread Caligo
I'm not questioning the design, but I would like to know the reason: given the fact that associative arrays are built into the language, why don't we have static associative arrays?

Why can't I have overloading and generics?

2012-03-09 Thread Caligo
struct B { } struct C { } struct D { } struct A { ref A foo(B item) { /* do something special. */ return this; } ref A foo(T)(T item) if(is(T == C) || is(T == D)) { /* nothing special, do the same for C and D. */ return this;

Why constructs can not be private?

2012-03-06 Thread Caligo
module A; private struct A { } private A a; private mixin template magic() { } private void foo() { } //- module B; import A; void main() { A b; // #1 works b = a; // #2 ERROR foo(); // #3 ERROR } struct B{ mixin magic; // #4 works } What's the point of

A very strange bug. DMD 2.058 64-bit Linux

2012-02-26 Thread Caligo
bug.d 88 @trusted: import std.datetime : benchmark; import std.stdio: writefln, writeln; alias double Real; void ben(alias fun)(string msg, uint n = 1_000_000) { auto b = benchmark!fun(n); writefln( %s %s ms, msg, b[0].to!(msecs, int)); }

Re: A very strange bug. DMD 2.058 64-bit Linux

2012-02-26 Thread Caligo
Thanks. I have reported the bug: http://d.puremagic.com/issues/show_bug.cgi?id=7595

Re: 2.058 broke my build. Is this a bug?

2012-02-24 Thread Caligo
That was a typo, and it doesn't change anything. Here is a shorter version: 88 import std.datetime; import std.stdio; struct A{ auto fun(A a){ return 0; } } void bench(alias fun)(string msg, uint n = 1_000_000){ auto b = benchmark!fun(n);

Re: 2.058 broke my build. Is this a bug?

2012-02-24 Thread Caligo
Is there another workaround than the one I've posted? http://d.puremagic.com/issues/show_bug.cgi?id=7577 On Fri, Feb 24, 2012 at 8:44 PM, James Miller ja...@aatch.net wrote: Hmm it seems that the delegate is being implicitly marked as system, and im not sure why benchmark is @safe. I'd say

Re: 2.058 broke my build. Is this a bug?

2012-02-24 Thread Caligo
I found another workaround: mark the module as trusted.

2.058 broke my build. Is this a bug?

2012-02-23 Thread Caligo
88 import std.datetime : benchmark; import std.stdio : writefln; struct A(int r, int c){ public: alias float[r * c] Data; Data _data; auto opBinary(A a){ float t; foreach(i; 0..r*c) foreach(j; 0..r*c) t += this[i,j];

Re: floating-WTF - Compiler-BUG with 64bit

2012-01-28 Thread Caligo
I've already reported, and it's been fixed in the latest: http://d.puremagic.com/issues/show_bug.cgi?id=7376 On Sat, Jan 28, 2012 at 9:56 AM, sclytrack sclytr...@fake.com wrote: On 01/25/2012 01:12 AM, Timon Gehr wrote: On 01/24/2012 10:28 PM, %u wrote: Shouldn't this go into

Re: floating-WTF - Compiler-BUG with 64bit

2012-01-28 Thread Caligo
On Sat, Jan 28, 2012 at 2:04 PM, sclytrack sclytr...@hotmail.com wrote: Now I've waisted Walter's precious time. I feel so sad now :-( I should have made a post about the fact that I had already bug reported it, but I forgot. Sorry.

Re: floating-WTF

2012-01-24 Thread Caligo
On Tue, Jan 24, 2012 at 6:51 AM, Dejan Lekic dejan.le...@gmail.com wrote: No, it is not a bug. Here is a hint: import std.stdio; int main() {  float f;  writeln(f);  return 0; } /+--- output --+ nan +--- end of output ---+/ wow, what a great hint. sorry, but I'm not

Re: floating-WTF - Compiler-BUG with 64bit

2012-01-24 Thread Caligo
How did you compile it? As in my original post, it matters how you compile it. In this case (I'm on a 64-bit GNU/Linux system), compiling with '-inline' doesn't trigger the bug.

floating-WTF

2012-01-23 Thread Caligo
alias double Real; //alias float Real; // simple linear interpolation; I partitioned the internals to help me figure out what was happening. Real lerp(Real t, Real a, Real b){ Real s1 = (1.0 - t) * a; Real s2 = t * b; Real rt1 = s1 + s2; Real rt2 = ((1.0 - t) * a) + (t * b);

no-argument constructor: is this a bug?

2012-01-22 Thread Caligo
struct A(uint samples){ float[samples] _data = void; this(float val = 0.0f){ fill(_data[], val); } } auto a = A!8(); a._data is filled with garbage instead of zeros because the no-argument constructor is called instead of the one that I've defined.

Re: out default argument of void

2012-01-04 Thread Caligo
On Wed, Jan 4, 2012 at 4:40 PM, Jesse Phillips jessekphillip...@gmail.com wrote: Out parameters are initialized. The declaration you want is: bool fun(double theta, A a = A.init, B b = B.init, C c = C.init){ /* ... */ } In my case A, B, and C are structs, so that works the way I wanted it.

Re: typedef deprecated - now what ?

2011-12-30 Thread Caligo
On Fri, Dec 30, 2011 at 4:35 AM, Stephan s...@extrawurst.org wrote: is there a template or something in phobos to get the same typesafe behaviour of good old typedef ? S. Get over it, move on, and hope they fix the thousands of bugs left in DMD. P.S. use `alias`.

Re: IDE with renaming possibility

2011-11-06 Thread Caligo
On Sun, Nov 6, 2011 at 9:28 AM, Jabba Laci jabba.l...@gmail.com wrote: Hi, I'm new to D, I just started to read the book of Andrei. As an IDE, I use Eclipse with the DDT plugin. However, I don't find an important feature: renaming variables/functions/etc. If it's not in DDT, what IDE do

Re: Is this a bug?

2011-09-14 Thread Caligo
On Tue, Sep 13, 2011 at 6:22 PM, Jonathan M Davis jmdavisp...@gmx.comwrote: On Tuesday, September 13, 2011 15:34 Caligo wrote: On Tue, Sep 13, 2011 at 4:47 AM, Jonathan M Davis jmdavisp...@gmx.comwrote: On Monday, September 12, 2011 23:15:19 Caligo wrote: On Mon, Sep 12, 2011 at 10:44

Re: Is this a bug?

2011-09-13 Thread Caligo
On Tue, Sep 13, 2011 at 4:47 AM, Jonathan M Davis jmdavisp...@gmx.comwrote: On Monday, September 12, 2011 23:15:19 Caligo wrote: On Mon, Sep 12, 2011 at 10:44 PM, Jonathan M Davis jmdavisp...@gmx.comwrote: On Monday, September 12, 2011 22:38:25 Caligo wrote: Great. So is it a known bug

Is this a bug?

2011-09-12 Thread Caligo
Trying to help someone on SO, I ran into problems. On a 64-bit Linux machine, with DMD 2.055 This gives: '/Internal error: ../ztc/cg87.c 202' void main(){ auto f = (double m){ static double sum = 0.0; return sum += m * m; }; double[] a = array(map!f(iota(1.0, 25.0, 1.0))); writeln(a); }

Re: Is this a bug?

2011-09-12 Thread Caligo
Great. So is it a known bug? On Mon, Sep 12, 2011 at 10:35 PM, Jonathan M Davis jmdavisp...@gmx.comwrote: On Monday, September 12, 2011 22:31:33 Caligo wrote: Trying to help someone on SO, I ran into problems. On a 64-bit Linux machine, with DMD 2.055 This gives: '/Internal error

Re: Is this a bug?

2011-09-12 Thread Caligo
On Mon, Sep 12, 2011 at 10:44 PM, Jonathan M Davis jmdavisp...@gmx.comwrote: On Monday, September 12, 2011 22:38:25 Caligo wrote: Great. So is it a known bug? I don't know. You'd have to search bugzilla: d.puremagic.com/issues - Jonathan M Davis Searching bugzilla (horrible technology

Re: D with gmp via swig

2011-08-14 Thread Caligo
Shouldn't there be an interface to GMP and MPFR in Phobos by default?

Re: incompatible types!

2011-04-05 Thread Caligo
It's just frustrating, that's all. Writing thousands of lines of code and having everything stop because of a compiler bug is just frustrating. I know progress is being made, and all that is appreciated. But, I don't remember ever hearing anything about D2 being in beta. If anything, I

Re: The is expression

2011-04-01 Thread Caligo
On Fri, Apr 1, 2011 at 5:14 PM, enuhtac enuhtac_li...@gmx.de wrote: Hello, the is expression is a great feature of D - but its use is not very intuitive, at least for me. I'm trying to write a template that figures out if the template parameter is of a given type. This is the type I would

Re: template template parameter

2011-03-31 Thread Caligo
I should have been more clear, but my actual question is how do I access the parameters of a template parameter. My example works, but I wanted to know if there is a different and perhaps a better of doing it. In your example it would look something like this: struct SomeContainer(T, int x, int

Module Searching Roots

2011-03-27 Thread Caligo
I'm in directory ~/root and I have 't1.d' in ~/root/src/core directory, and nothing else. I run: 'gdc -O3 -o t1 t1.d -B./src/core' but I get gdc: t1.d: No such file or directory gdc: no input files I've tried different paths, but I can't get it work. What's the problem?

Re: inline functions

2011-03-26 Thread Caligo
On Sat, Mar 26, 2011 at 3:47 AM, Jonathan M Davis jmdavisp...@gmx.com wrote: On 2011-03-26 01:06, Caligo wrote: On Fri, Mar 25, 2011 at 11:56 PM, Jonathan M Davis jmdavisp...@gmx.com wrote: On 2011-03-25 21:21, Caligo wrote: On Fri, Mar 25, 2011 at 10:49 PM, Jonathan M Davis jmdavisp

is(T : long) vs is(T == long)

2011-03-26 Thread Caligo
What is the difference between this: template isNumerik(T){ enum bool isNumerik = is(T : long) || is(T : real); } and this: template isNumerik(T){ enum bool isNumerik = is(T == long) || is(T == real); } They both work and I can't find anywhere in the book where it talks about the :

Re: is(T : long) vs is(T == long)

2011-03-26 Thread Caligo
:-) thanks.

Re: inline functions

2011-03-26 Thread Caligo
I've changed my code since I posted this, so here is something different that shows performance difference: module t1; struct Vector{ private: double x = void; double y = void; double z = void; public: this(in double x, in double y, in double z){ this.x = x; this.y = y;

Re: inline functions

2011-03-25 Thread Caligo
On Fri, Mar 25, 2011 at 10:49 PM, Jonathan M Davis jmdavisp...@gmx.com wrote: On 2011-03-25 19:04, Caligo wrote: T[3] data; T dot(const ref Vector o){     return data[0] * o.data[0] + data[1] * o.data[1] + data[2] * o.data[2]; } T LengthSquared_Fast(){ return data[0] * data[0] + data[1

C++ to D: mutable

2011-03-24 Thread Caligo
Greetings, I have a C++ class that I would like to rewrite it in D. The class has members that are declared as 'mutable'. How do I achieve the same effect in D? if not, what is recommended?

Running GDC

2011-03-21 Thread Caligo
I updated my gdc repo and now I can't run the new build; it can't find the includes and the libs. This is what I've come up with so far: -I/../D/gdc/Bin/usr/local/include/d2/4.4.5/ -I/../D/gdc/Bin/usr/local/include/d2/4.4.5/x86_64-unknown-linux-gnu/ What's the rest?

Re: Points and Vectors in 3D

2011-03-13 Thread Caligo
On Sun, Mar 13, 2011 at 9:11 AM, Simen kjaeraas simen.kja...@gmail.comwrote: Spacen Jasset spacenjas...@yahoo.co.uk wrote: Can't see a fitting operator in D. Multiplication (*) is ambiguous at best and no other operator seems fitting. I agree. It's just better do define 'dot' and 'cross'.

struct construct with array

2011-03-12 Thread Caligo
struct Test{ public double[3] ar_; this(double[3] ar){ this.ar_ = ar; } } void main(){ double[3] v1 = [1.0, 2.0, 3.0]; double[3] v2 = [2.0, 3.0, 4.0]; auto t1 = Test(v1[0..$] + v2[0..$]); // error } I want to add those two arrays and call the constructor in one line, but

Points and Vectors in 3D

2011-03-12 Thread Caligo
Given everything that D offers, what would be the best way to implement a Point and a Vector type? The same (x, y, z) can be used to represent vectors, but a point represents a position, whereas a vector represents a direction. So, would you define two different structs for each? or define and

Re: Mixins: to!string cannot be interpreted at compile time

2011-03-11 Thread Caligo
On Tue, Mar 1, 2011 at 1:15 PM, Peter Lundgren lundg...@rose-hulman.eduwrote: That worked, thanks. This is interesting because the example used in The D Programming Language on page 83 gets away with it just fine. I had no problem running this: result ~= to!string(bitsSet(b)) ~ , ; How

Re: Mixins: to!string cannot be interpreted at compile time

2011-03-11 Thread Caligo
On Fri, Mar 11, 2011 at 11:48 AM, Caligo iteronve...@gmail.com wrote: On Tue, Mar 1, 2011 at 1:15 PM, Peter Lundgren lundg...@rose-hulman.eduwrote: That worked, thanks. This is interesting because the example used in The D Programming Language on page 83 gets away with it just fine. I

Re: Starting with D

2011-02-06 Thread Caligo
On Sun, Feb 6, 2011 at 5:35 PM, Julius n0r3...@web.de wrote: Hi there, i'm all new to D but not new to programming in general. I'd like to try D but i didn't find a nice tutorial yet. I don't want to read a whole book, I just want to get the basics so I can start. Can you help me find

Re: TDPL dictionary example - error

2010-12-24 Thread Caligo
I forgot to ask, what version of DMD are you using? 2010/12/24 Mariusz Gliwiński alienballa...@gmail.com Friday 24 December 2010 @ 06:24:34 Caligo: Greetings, I just joined here, so sorry if this has been posted before. I'm reading TDPL and the example on page 8 doesn't compile. I'm

TDPL dictionary example - error

2010-12-23 Thread Caligo
Greetings, I just joined here, so sorry if this has been posted before. I'm reading TDPL and the example on page 8 doesn't compile. I'm using the latest GDC with GCC 4.4.5. I've checked the errata, but nothing for this error. import std.stdio; import std.string; void main(){

Re: TDPL dictionary example - error

2010-12-23 Thread Caligo
No, GDC supports D1 and D2. Version 2.051 I think. I know I've compiled mine with D2 support. 2010/12/24 Mariusz Gliwiński alienballa...@gmail.com Friday 24 December 2010 @ 06:24:34 Caligo: Greetings, I just joined here, so sorry if this has been posted before. I'm reading TDPL