Error building doc's chm

2013-08-24 Thread Nick Sabalausky
Not sure if I'm doing something wrong here, but using DMD 2.063.2 on Win, trying to build the CHM docs like this: git clone https://github.com/D-Programming-Language/druntime.git git clone https://github.com/D-Programming-Language/phobos.git git clone https://githu

Re: std.algorithm's remove

2013-08-24 Thread maarten van damme
I'm not sure if it really is my place to criticize design decisions of a language written by people that devoted their career to computer science while I have only read some books out of boredom :) 2013/8/25 bearophile > maarten van damme: > > > But remove doesn't truly remove from the source

Re: std.algorithm's remove

2013-08-24 Thread maarten van damme
> > (apart from reading the documentation on every single >> trivial function in the std library?) >> > > Before using every function from the standard library you have to read its > documentation, this is sure. You can not assume its behavour to be exactly > the same you hope it to have. This is

Re: std.algorithm's remove

2013-08-24 Thread bearophile
maarten van damme: But remove doesn't truly remove from the source range because the length of the source range stays the same. It's return value is a modified copy of the source range. Filter doesn't really work right away because that would also remove duplicate elements while I only want

Re: std.algorithm's remove

2013-08-24 Thread maarten van damme
Correction, I could really use remove to begin with, only have to dup the range. Still convinced that the remove behaviour is counterintuitive but I assume good reasons exist... 2013/8/25 maarten van damme > But remove doesn't truly remove from the source range because the length > of the sourc

Re: std.algorithm's remove

2013-08-24 Thread bearophile
maarten van damme: Is there any way I could've known this? For me it was "obvious" even before reading the documentation that a remove function is meant to be in-place. But of course you could have different ideas. (apart from reading the documentation on every single trivial function in

Re: std.algorithm's remove

2013-08-24 Thread maarten van damme
But remove doesn't truly remove from the source range because the length of the source range stays the same. It's return value is a modified copy of the source range. Filter doesn't really work right away because that would also remove duplicate elements while I only want to remove at a given inde

Re: std.algorithm's remove

2013-08-24 Thread Brad Anderson
On Sunday, 25 August 2013 at 02:24:30 UTC, maarten van damme wrote: hello, I'm a hobyist-programmer and around where I live there's a group of haskell fanatics. They posted solutions to a recent programming challenge which I find to be a bit ugly. For fun I wanted to implement it in d and a r

std.algorithm's remove

2013-08-24 Thread maarten van damme
hello, I'm a hobyist-programmer and around where I live there's a group of haskell fanatics. They posted solutions to a recent programming challenge which I find to be a bit ugly. For fun I wanted to implement it in d and a rough version (not correct yet, this was written/hacked in 5 minutes after

Re: Using a range as a reference

2013-08-24 Thread Paolo Invernizzi
On Saturday, 24 August 2013 at 20:24:47 UTC, H. S. Teoh wrote: On Sat, Aug 24, 2013 at 10:02:56PM +0200, Paolo Invernizzi wrote: I've missed it as it is not listed in the tables of the range documentation, like the others, but only in the top-index... That would be a documentation bug. Please

Re: Using a range as a reference

2013-08-24 Thread H. S. Teoh
On Sat, Aug 24, 2013 at 10:02:56PM +0200, Paolo Invernizzi wrote: > On Saturday, 24 August 2013 at 19:51:14 UTC, David wrote: > >do you mean refRange? > >http://dlang.org/phobos/std_range.html#.refRange > > Exactly, thank you! > I've missed it as it is not listed in the tables of the range > docum

Re: Using a range as a reference

2013-08-24 Thread Paolo Invernizzi
On Saturday, 24 August 2013 at 19:51:14 UTC, David wrote: do you mean refRange? http://dlang.org/phobos/std_range.html#.refRange Exactly, thank you! I've missed it as it is not listed in the tables of the range documentation, like the others, but only in the top-index... - Paolo Invernizzi

Re: Using a range as a reference

2013-08-24 Thread David
do you mean refRange? http://dlang.org/phobos/std_range.html#.refRange

Using a range as a reference

2013-08-24 Thread Paolo Invernizzi
Hi all, I've a custom generator, and is modelled as a structure forwardRange, and I want to be able to use it like this, printing the first ten fibonacci: --- struct ForEacher(Range){ Range* r; this(ref Range r_){ r=&r_; } @property bool empty(){ return r.empty; } @property au

Re: is the tools part of the test suite? currently tools/ddemangle doesn't compile on git master

2013-08-24 Thread Timothee Cour
Yes, and it would also help find buggy commits. Actually i'd argue other popular external d packages should be included in autotester (even if those wouldnt be blockers) On Aug 24, 2013 8:35 AM, "H. S. Teoh" wrote: > On Sat, Aug 24, 2013 at 10:08:08AM +0200, David Nadlinger wrote: > > On Saturday

Re: is the tools part of the test suite? currently tools/ddemangle doesn't compile on git master

2013-08-24 Thread H. S. Teoh
On Sat, Aug 24, 2013 at 10:08:08AM +0200, David Nadlinger wrote: > On Saturday, 24 August 2013 at 03:20:42 UTC, Timothee Cour wrote: > >More often than not, the tools submodule ( > >https://github.com/D-Programming-Language/tools) will not build on > >git > >master. So I'm wondering whether it's ev

Re: Wrapping an arbitrary class/struct API

2013-08-24 Thread Joseph Rushton Wakeling
On 24/08/13 15:47, Artur Skawina wrote: This will handle the simple case you described; the opDispatch template will get more complex once it needs to forward other stuff, like fields and properties, or handle ref args properly etc. More specifically, how could I work this out limited to a spec

Re: Wrapping an arbitrary class/struct API

2013-08-24 Thread Artur Skawina
On 08/24/13 15:14, Joseph Rushton Wakeling wrote: > Hello all, > > (This accidentally got posted as a reply to someone else's thread -- I'm > reposting in order to make sure that thread doesn't get diverted.) > > Suppose that I have a struct like e.g.: > > struct A > { > void fo

Re: Wrapping an arbitrary class/struct API

2013-08-24 Thread Joseph Rushton Wakeling
On 24/08/13 15:31, John Colvin wrote: You might want to look at std.typecons.Proxy also, opDispatch is a very powerful tool for doing this sort of thing. Thanks, I'll take a look :-)

Re: Wrapping an arbitrary class/struct API

2013-08-24 Thread John Colvin
On Saturday, 24 August 2013 at 13:14:30 UTC, Joseph Rushton Wakeling wrote: Hello all, (This accidentally got posted as a reply to someone else's thread -- I'm reposting in order to make sure that thread doesn't get diverted.) Suppose that I have a struct like e.g.: struct A {

Wrapping an arbitrary class/struct API

2013-08-24 Thread Joseph Rushton Wakeling
Hello all, (This accidentally got posted as a reply to someone else's thread -- I'm reposting in order to make sure that thread doesn't get diverted.) Suppose that I have a struct like e.g.: struct A { void foo(int n) { ... } void foo(Range)(Range r) { ... } in

Re: templated isNaN

2013-08-24 Thread Joseph Rushton Wakeling
On 24/08/13 14:50, Joseph Rushton Wakeling wrote: static if (isNumeric!T) { return std.math.isNaN(t); } Note that the correct if () condition here depends on how you want your isNaN to behave in certain cases. Using isNumeric will mean isNaN('c') returns true. If you

Re: templated isNaN

2013-08-24 Thread Joseph Rushton Wakeling
On 24/08/13 13:53, Paolo Invernizzi wrote: Someone can suggest me a convenient way to declare an 'isNaN' templated function that plays well with the 'standard.math.isNaN'? The target is to be able to define isNaN functions for my custom structures, and I want to keep the same name... Will this

Re: Wrapping an arbitrary class/struct API

2013-08-24 Thread Paolo Invernizzi
On Saturday, 24 August 2013 at 12:12:29 UTC, Joseph Rushton Wakeling wrote: Hi Joseph, I'm not really a D guru like others, but... ... an I want to wrap it in another struct, B. If I do this manually it would be something like, struct B { private A a; void foo(int n

Re: What's the right way for doing this in D?

2013-08-24 Thread Andrej Mitrovic
On 8/24/13, Namespace wrote: > Until now I used Method A, but because of UFCS and the fact, that > the dot product doesn't affect the object, I thought about which > way would make more sense. I still like Method A but I'm curious > what you think. Note also that UFCS can introduce the function h

Re: Wrapping an arbitrary class/struct API

2013-08-24 Thread Joseph Rushton Wakeling
Whoops -- must have accidentally hit "Reply" there by accident, instead of clicking to send new mail. Didn't mean to hijack someone else's thread. :-(

Wrapping an arbitrary class/struct API

2013-08-24 Thread Joseph Rushton Wakeling
Hello all, Suppose that I have a struct like e.g.: struct A { void foo(int n) { ... } void foo(Range)(Range r) { ... } int bar() { ... } int bar(double x) { ... } // ... and others ... } ... an I want to wrap it in another struct, B. If I do

templated isNaN

2013-08-24 Thread Paolo Invernizzi
Someone can suggest me a convenient way to declare an 'isNaN' templated function that plays well with the 'standard.math.isNaN'? The target is to be able to define isNaN functions for my custom structures, and I want to keep the same name... --- import std.math; bool isNaN(T)(T t) if(is(T==s

Re: pointers, null and Typedef...

2013-08-24 Thread Paolo Invernizzi
On Saturday, 24 August 2013 at 09:19:14 UTC, John Colvin wrote: On Friday, 23 August 2013 at 18:58:49 UTC, Paolo Invernizzi wrote: On Friday, 23 August 2013 at 12:17:08 UTC, John Colvin wrote: so, here's the situation: On 2.063.2 why not something like this: It's const(void*) not just void*

Re: Template alias parameter: error: need 'this' for ...

2013-08-24 Thread Matej Nanut
On Friday, 23 August 2013 at 22:54:33 UTC, Jonathan M Davis wrote: Because without static it's a member variable, which means that you have to have a constructed object to access it (since it's part of the object). When you declare a variable in a class or struct static, then there's only one f

Variant[Variant]

2013-08-24 Thread Jason den Dulk
Hi Straight off, I should ask if Variant[Variant] is a feasable idea. I am writing a serialization module which is trying to make use of this. This is the function Variant unserialize(V:Variant)(ref const(char)[] str) { switch (str[0]) { case 'b': return Variant(uns

Re: What's the right way for doing this in D?

2013-08-24 Thread bearophile
Namespace: I liked to know which of this two methods is more common to you, A or B: Both ways work. I usually prefer the first one because it's more DRY. I use external functions when I write functions that are meant to work on more different structs, or to reduce template bloat when a func

What's the right way for doing this in D?

2013-08-24 Thread Namespace
I liked to know which of this two methods is more common to you, A or B: Method A: import std.stdio; struct Vector2f { public: float x; float y; float dot(ref const Vector2f vec) const { return this.x * vec.x + this.y * vec.y; } } Meth

Re: pointers, null and Typedef...

2013-08-24 Thread John Colvin
On Friday, 23 August 2013 at 18:58:49 UTC, Paolo Invernizzi wrote: On Friday, 23 August 2013 at 12:17:08 UTC, John Colvin wrote: so, here's the situation: On 2.063.2 why not something like this: --- import std.typecons; alias T0 = Typedef!(void*, null, "T0"); alias T1 = Typedef!(void*, null,

alias this bug?

2013-08-24 Thread Timothee Cour
is this a bug? the call to join invalidates the "name" field of A: import std.array; import std.stdio; class A{ string name; this(string name){this.name=name;} alias name this; ~this(){ writeln("deleting"); } } void main(){ auto a=[new A(`foo`)]; assert(a[0].length); wri

Re: How compile program with curl support?

2013-08-24 Thread David
Am 24.08.2013 09:56, schrieb ilya-stromberg: > On Thursday, 22 August 2013 at 16:28:32 UTC, David wrote: >> Can't reproduce this: >> >> ─[dav1d@archbox][/tmp]╼ cat c.d >> import std.net.curl; >> >> void main() {} >> ─[dav1d@archbox][/tmp]╼ dmd c.d -L-lcurl >> ─[dav1d@archbox][/tmp]╼ >> >> So I only

Re: is the tools part of the test suite? currently tools/ddemangle doesn't compile on git master

2013-08-24 Thread David Nadlinger
On Saturday, 24 August 2013 at 03:20:42 UTC, Timothee Cour wrote: More often than not, the tools submodule ( https://github.com/D-Programming-Language/tools) will not build on git master. So I'm wondering whether it's even being tested before pushing commits. In short: no, unfortunately. Dav

Re: How compile program with curl support?

2013-08-24 Thread ilya-stromberg
On Thursday, 22 August 2013 at 16:28:32 UTC, David wrote: Can't reproduce this: ─[dav1d@archbox][/tmp]╼ cat c.d import std.net.curl; void main() {} ─[dav1d@archbox][/tmp]╼ dmd c.d -L-lcurl ─[dav1d@archbox][/tmp]╼ So I only get these errors when *not* linking against curl. It looks like regre