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)
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] =
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?
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;
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
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));
}
Thanks. I have reported the bug:
http://d.puremagic.com/issues/show_bug.cgi?id=7595
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);
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
I found another workaround: mark the module as trusted.
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];
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
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.
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
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.
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);
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.
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.
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`.
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
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
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
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);
}
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
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
Shouldn't there be an interface to GMP and MPFR in Phobos by default?
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
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
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
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?
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
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 :
:-) thanks.
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;
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
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?
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?
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 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
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
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
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
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
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
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(){
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
46 matches
Mail list logo