Jump to page: 1 218  
Page
Thread overview
Why D const is annoying
Dec 10, 2011
Mehrdad
Dec 10, 2011
Mehrdad
Dec 10, 2011
Timon Gehr
Apr 28, 2012
SomeDude
Apr 28, 2012
SomeDude
Dec 10, 2011
Timon Gehr
Dec 10, 2011
bearophile
Dec 10, 2011
Timon Gehr
Dec 10, 2011
bearophile
Dec 10, 2011
Mehrdad
Dec 10, 2011
Timon Gehr
Dec 10, 2011
Timon Gehr
Dec 12, 2011
Kai Meyer
Dec 12, 2011
Jonathan M Davis
Dec 10, 2011
Jonathan M Davis
Dec 10, 2011
bearophile
Dec 11, 2011
Graham St Jack
Dec 10, 2011
Mehrdad
Dec 10, 2011
Mehrdad
Dec 10, 2011
so
Dec 10, 2011
Mehrdad
Dec 10, 2011
Timon Gehr
Dec 10, 2011
Mehrdad
Re: Why D <strike>const</strike> is annoying
Dec 10, 2011
Mehrdad
Dec 10, 2011
Mehrdad
Dec 10, 2011
Timon Gehr
Dec 10, 2011
Walter Bright
Dec 10, 2011
Mehrdad
Dec 10, 2011
Walter Bright
Dec 10, 2011
Mehrdad
Dec 10, 2011
Walter Bright
Dec 10, 2011
Timon Gehr
Dec 10, 2011
Trass3r
Dec 10, 2011
Mehrdad
Dec 10, 2011
Jonathan M Davis
Dec 10, 2011
Bernard Helyer
Dec 10, 2011
Jakob Ovrum
Dec 10, 2011
David Nadlinger
Dec 10, 2011
Trass3r
Dec 10, 2011
Walter Bright
Apr 28, 2012
SomeDude
Dec 10, 2011
Mehrdad
Dec 10, 2011
Mehrdad
Dec 10, 2011
Walter Bright
Dec 10, 2011
Mehrdad
Dec 10, 2011
Walter Bright
Dec 11, 2011
Mafi
Dec 11, 2011
Walter Bright
Dec 11, 2011
Mafi
Dec 11, 2011
Timon Gehr
Dec 11, 2011
Mafi
Dec 13, 2011
Jesse Phillips
Dec 13, 2011
Timon Gehr
Dec 12, 2011
Timon Gehr
Dec 12, 2011
Timon Gehr
Dec 12, 2011
Timon Gehr
Dec 12, 2011
Timon Gehr
Dec 10, 2011
Mehrdad
Dec 10, 2011
Timon Gehr
Dec 10, 2011
Mehrdad
Dec 10, 2011
Timon Gehr
Dec 10, 2011
Mehrdad
Dec 10, 2011
Mehrdad
Dec 10, 2011
Trass3r
Dec 10, 2011
Mehrdad
Dec 10, 2011
Trass3r
Dec 10, 2011
Mehrdad
Apr 28, 2012
SomeDude
Dec 10, 2011
Walter Bright
Dec 10, 2011
Mehrdad
Dec 11, 2011
Mehrdad
Apr 28, 2012
SomeDude
Dec 11, 2011
Mehrdad
Apr 28, 2012
SomeDude
Re: More bugs...
Apr 28, 2012
Mehrdad
Apr 28, 2012
Mehrdad
Apr 28, 2012
James Miller
Apr 28, 2012
Mehrdad
Apr 28, 2012
Max Samukha
Apr 28, 2012
Timon Gehr
Apr 28, 2012
Max Samukha
Apr 28, 2012
Timon Gehr
Apr 28, 2012
Timon Gehr
Apr 28, 2012
SomeDude
Apr 29, 2012
James Miller
Apr 29, 2012
SomeDude
May 01, 2012
Mehrdad
May 01, 2012
Mehrdad
May 01, 2012
Timon Gehr
May 01, 2012
Mehrdad
May 01, 2012
Timon Gehr
May 01, 2012
Mehrdad
May 01, 2012
Timon Gehr
May 01, 2012
Mehrdad
May 01, 2012
Timon Gehr
May 02, 2012
Mehrdad
May 02, 2012
Timon Gehr
May 01, 2012
Robert Clipsham
May 02, 2012
Mehrdad
May 02, 2012
Mehrdad
May 02, 2012
Artur Skawina
May 02, 2012
Mehrdad
May 02, 2012
Jonathan M Davis
May 02, 2012
Mehrdad
May 02, 2012
Jonathan M Davis
May 02, 2012
Chris Cain
May 02, 2012
Mehrdad
May 02, 2012
Chris Cain
May 02, 2012
Chris Cain
May 02, 2012
Mehrdad
May 02, 2012
Jonathan M Davis
May 02, 2012
Mehrdad
May 02, 2012
Jonathan M Davis
May 02, 2012
Mehrdad
May 02, 2012
Jonathan M Davis
May 02, 2012
Mehrdad
May 02, 2012
Michel Fortin
May 02, 2012
Mehrdad
May 02, 2012
Jacob Carlborg
May 02, 2012
Mehrdad
May 02, 2012
Timon Gehr
May 02, 2012
Mehrdad
May 02, 2012
Jacob Carlborg
May 02, 2012
Timon Gehr
May 02, 2012
Chris Cain
May 02, 2012
Jacob Carlborg
May 02, 2012
Chris Cain
May 02, 2012
Mehrdad
May 02, 2012
Chris Cain
May 02, 2012
Mehrdad
May 02, 2012
Chris Cain
May 02, 2012
Jonathan M Davis
When is casting const() away actually necessary? (Used to be: Re: Why D const is annoying)
May 02, 2012
Mehrdad
May 02, 2012
David Nadlinger
May 03, 2012
David Nadlinger
May 04, 2012
Oleg Kuporosov
May 03, 2012
Mehrdad
May 02, 2012
Jonathan M Davis
May 02, 2012
Mehrdad
May 02, 2012
Jonathan M Davis
May 02, 2012
Mehrdad
May 02, 2012
Mehrdad
May 02, 2012
Jonathan M Davis
May 02, 2012
Mehrdad
May 02, 2012
Jonathan M Davis
May 02, 2012
Mehrdad
May 02, 2012
Jonathan M Davis
May 02, 2012
Timon Gehr
May 02, 2012
Mehrdad
May 02, 2012
H. S. Teoh
May 02, 2012
bearophile
May 02, 2012
H. S. Teoh
May 02, 2012
bearophile
May 02, 2012
SomeDude
May 02, 2012
bearophile
May 02, 2012
Mehrdad
May 02, 2012
Mehrdad
May 02, 2012
Mehrdad
May 02, 2012
Mehrdad
May 02, 2012
bearophile
December 10, 2011
I just thought I'd give D another try, after having given up on it for a while.

Lo and behold... the same old kind of problem from a year ago is still here. :(

Simple stuff like this:

    import std.algorithm;
    void main() {
        const arr = [1, 2, 3];
        reduce!"a*b"(arr);   // You'd think it'd work...
    }

Results in ridiculously annoying errors like:
    // algorithm.d(728): Error: can only initialize const member _field_field_0 inside constructor

I **HIGHLY** suggest that priority be given to simple problems like these, instead of OMG-so-cool-libraries. It really doesn't matter if there is an uber-awesome collections/CURL/whatever library out there, when problems like these exist. If a 2-line piece of code needs a workaround, then (IMO) people simply won't care about anything else that's more complicated.

I'll post more as I find them. (I'd found plenty a few months ago, now I just need to find them again.)
Too lazy/busy studying to post as a bug. And it feels a bit better when I add the complaint. :P

(Sorry for being so critical but at least I tried to make it constructive...)
December 10, 2011
Moar coming... hey look, it's ANOTHER const-ness issue! :(

import std.algorithm;
struct Matrix
{
    size_t[] _lengths;
    @property inout(size_t)[] lengths() inout { return _lengths; }
    @property size_t length() inout { return reduce!q{a*b}(lengths); }
}

// Error: template std.algorithm.reduce!("a*b").reduce(Args...) if (Args.length > 0 && Args.length <= 2 && isIterable!(Args[__dollar - 1])) does not match any function template declaration
// Error: template std.algorithm.reduce!("a*b").reduce(Args...) if (Args.length > 0 && Args.length <= 2 && isIterable!(Args[__dollar - 1])) cannot deduce template function from argument types !()(inout(uint[2u]))
December 10, 2011
On 12/10/2011 10:43 AM, Mehrdad wrote:
> Moar coming... hey look, it's ANOTHER const-ness issue! :(
>
> import std.algorithm;
> struct Matrix
> {
> size_t[] _lengths;
> @property inout(size_t)[] lengths() inout { return _lengths; }
> @property size_t length() inout { return reduce!q{a*b}(lengths); }
> }
>
> // Error: template std.algorithm.reduce!("a*b").reduce(Args...) if
> (Args.length > 0 && Args.length <= 2 && isIterable!(Args[__dollar - 1]))
> does not match any function template declaration
> // Error: template std.algorithm.reduce!("a*b").reduce(Args...) if
> (Args.length > 0 && Args.length <= 2 && isIterable!(Args[__dollar - 1]))
> cannot deduce template function from argument types !()(inout(uint[2u]))

http://d.puremagic.com/issues/show_bug.cgi?id=6809
December 10, 2011
On 12/10/2011 10:37 AM, Mehrdad wrote:
> I just thought I'd give D another try, after having given up on it for a
> while.
>
> Lo and behold... the same old kind of problem from a year ago is still
> here. :(
>
> Simple stuff like this:
>
> import std.algorithm;
> void main() {
> const arr = [1, 2, 3];
> reduce!"a*b"(arr); // You'd think it'd work...
> }
>
> Results in ridiculously annoying errors like:
> // algorithm.d(728): Error: can only initialize const member
> _field_field_0 inside constructor
>
> I **HIGHLY** suggest that priority be given to simple problems like
> these, instead of OMG-so-cool-libraries.

It is a *library bug*. Just have a look at the source code.

> It really doesn't matter if
> there is an uber-awesome collections/CURL/whatever library out there,
> when problems like these exist. If a 2-line piece of code needs a
> workaround, then (IMO) people simply won't care about anything else
> that's more complicated.
>
> I'll post more as I find them. (I'd found plenty a few months ago, now I
> just need to find them again.)
> Too lazy/busy studying to post as a bug. And it feels a bit better when
> I add the complaint. :P
>
> (Sorry for being so critical but at least I tried to make it
> constructive...)

Just slice the const array to get a range. The specialization for ranges does not have the bug.

import std.algorithm;
void main() {
    const arr = [1, 2, 3];
    reduce!"a*b"(arr[]);   // It works.
}
December 10, 2011
... and another...

struct S(T, int N)
{ public auto opBinary(string op)(in S!(T, N) other) const { return this; } }
void main() { S!(int, 1) m; m = m * m; }

Error: 'm' is not of arithmetic type, it is a Matrix!(int,1)
Error: 'm' is not of arithmetic type, it is a Matrix!(int,1)
December 10, 2011
On Sat, 10 Dec 2011 12:18:31 +0200, Mehrdad <wfunction@hotmail.com> wrote:

> ... and another...
>
> struct S(T, int N)
> { public auto opBinary(string op)(in S!(T, N) other) const { return this; } }
> void main() { S!(int, 1) m; m = m * m; }
>
> Error: 'm' is not of arithmetic type, it is a Matrix!(int,1)
> Error: 'm' is not of arithmetic type, it is a Matrix!(int,1)

Oh fantastic, so you are writing the first bug-free software of our time?
December 10, 2011
On 12/10/2011 2:28 AM, so wrote:
> On Sat, 10 Dec 2011 12:18:31 +0200, Mehrdad <wfunction@hotmail.com> wrote:
>
>> ... and another...
>>
>> struct S(T, int N)
>> { public auto opBinary(string op)(in S!(T, N) other) const { return this; } }
>> void main() { S!(int, 1) m; m = m * m; }
>>
>> Error: 'm' is not of arithmetic type, it is a Matrix!(int,1)
>> Error: 'm' is not of arithmetic type, it is a Matrix!(int,1)
>
> Oh fantastic, so you are writing the first bug-free software of our time?

Nope, sorry. :(
I'm listing a bunch of bugs I've found. And yes, I'm [semi-]complaining about them in the process.
December 10, 2011
... and another...

struct Matrix(T, size_t N = 1)
{ public auto mul(Matrix!(T, N) other) const { return this; } }

void main()
{
    Matrix!(int, 2) m;
    m.mul(m);
}

annoy.d(7): Error: function annoy.Matrix!(int,2).Matrix.mul (Matrix!(int,N) other) const is not callable using argument types (Matrix!(int,2))
annoy.d(7): Error: cannot implicitly convert expression (m) of type Matrix!(int,2) to Matrix!(int,N)
December 10, 2011
... and another...

struct S(L...) {
    enum N = L[0];
    S!(N) me() { return this; }
}
alias S!(1) S2;

annoy.d(3): Error: template instance annoy.S!(N) recursive expansion
December 10, 2011
Timon Gehr:

> Just slice the const array to get a range. The specialization for ranges does not have the bug.
> 
> import std.algorithm;
> void main() {
>      const arr = [1, 2, 3];
>      reduce!"a*b"(arr[]);   // It works.
> }

Wasn't arr a range already?

Bye,
bearophile
« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10 11