Re: Downloading Files in D

2014-09-11 Thread Nordlöw
On Wednesday, 10 September 2014 at 22:23:11 UTC, Adam D. Ruppe wrote: The curl one should be easiest for just downloading files. The big problems with it are that it can be a pain to get the library working with versioning and stuff and that it sometimes does the wrong thing in advanced use

std.conv checking if to will work

2014-09-11 Thread Robert burner Schadek via Digitalmars-d-learn
I like the to template a lot, but sometimes I want to make sure beforehand that a call to it works. Is there anything in phobos in missed to do that. And I don't want to try catch.

Re: std.conv checking if to will work

2014-09-11 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 11 September 2014 at 08:58:09 UTC, Robert burner Schadek wrote: I like the to template a lot, but sometimes I want to make sure beforehand that a call to it works. Is there anything in phobos in missed to do that. And I don't want to try catch. There's an open request for it, and

Re: std.conv checking if to will work

2014-09-11 Thread Robert burner Schadek via Digitalmars-d-learn
On Thursday, 11 September 2014 at 09:10:03 UTC, monarch_dodra wrote: There's an open request for it, and plans to have a bool maybeTo!(OUT, WHAT)(WHAT what, ref OUT out), but we aren't quite there yet. The idea is that *once* we have that, then to would simply become an enforce!maybeTo.

Re: DUB Dependency Tree Configuration Error

2014-09-11 Thread Nordlöw
On Thursday, 11 September 2014 at 09:53:34 UTC, Nordlöw wrote: I've tried removing ~/.dub/packages with no progres. I'm using dub git master.

Re: DUB Dependency Tree Configuration Error

2014-09-11 Thread Nordlöw
On Thursday, 11 September 2014 at 09:53:34 UTC, Nordlöw wrote: What is wrong? Here's the file https://github.com/nordlow/justd/blob/master/dub.json

DUB Dependency Tree Configuration Error

2014-09-11 Thread Nordlöw
Suddenly running dub triggers the following error Error executing command run: Could not find a valid dependency tree configuration: No match for dependency dchip ~master of fdo If I remove dchip I get the same error for all other packages. What is wrong? I've tried removing

Re: std.range.byLine

2014-09-11 Thread monarch_dodra via Digitalmars-d-learn
On Wednesday, 10 September 2014 at 23:01:44 UTC, Nordlöw wrote: On Wednesday, 10 September 2014 at 22:45:08 UTC, Nordlöw wrote: auto byLine(Range)(Range input) if (isForwardRange!Range) { import std.algorithm: splitter; import std.ascii: newline; static if (newline.length == 1) {

Re: std.conv checking if to will work

2014-09-11 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 11 September 2014 at 09:33:20 UTC, Robert burner Schadek wrote: On Thursday, 11 September 2014 at 09:10:03 UTC, monarch_dodra wrote: There's an open request for it, and plans to have a bool maybeTo!(OUT, WHAT)(WHAT what, ref OUT out), but we aren't quite there yet. The idea is

alias this cast

2014-09-11 Thread andre via Digitalmars-d-learn
Hi, I am 80% sure, the failing assertion is correct but please have a look. Second assertion fails. Kind regards André class A{} class B{} class C : B { A a; alias a this; this() { a = new A(); } } void main() { B b

Re: alias this cast

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 11 Sep 2014 11:40:05 + andre via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Hi, I am 80% sure, the failing assertion is correct but please have a look. No it is not assert(cast(A)cast(C)b); // this is OK b is B so it does not know about having alias to A;

std.algorithm.reduce on an array of structs

2014-09-11 Thread Colin via Digitalmars-d-learn
I have this test code: struct Thing { uint x; } void main(){ uint[] ar1 = [1, 2, 3, 4, 5]; auto min1 = ar1.reduce!((a,b) = a b); writefln(%s, min1); // prints 1 as expected Thing[] ar2 = [Thing(1), Thing(2), Thing(4)]; auto min2 = ar2.reduce!((a,b) = a.x b.x); // -

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 13:06:05 UTC, Colin wrote: I have this test code: struct Thing { uint x; } void main(){ uint[] ar1 = [1, 2, 3, 4, 5]; auto min1 = ar1.reduce!((a,b) = a b); writefln(%s, min1); // prints 1 as expected Thing[] ar2 = [Thing(1), Thing(2),

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread via Digitalmars-d-learn
On Thursday, 11 September 2014 at 13:06:05 UTC, Colin wrote: I have this test code: struct Thing { uint x; } void main(){ uint[] ar1 = [1, 2, 3, 4, 5]; auto min1 = ar1.reduce!((a,b) = a b); writefln(%s, min1); // prints 1 as expected Thing[] ar2 = [Thing(1), Thing(2),

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread via Digitalmars-d-learn
On Thursday, 11 September 2014 at 13:28:37 UTC, Marc Schütz wrote: On Thursday, 11 September 2014 at 13:06:05 UTC, Colin wrote: I have this test code: struct Thing { uint x; } void main(){ uint[] ar1 = [1, 2, 3, 4, 5]; auto min1 = ar1.reduce!((a,b) = a b); writefln(%s, min1); //

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Colin via Digitalmars-d-learn
On Thursday, 11 September 2014 at 13:27:39 UTC, Daniel Kozak wrote: On Thursday, 11 September 2014 at 13:06:05 UTC, Colin wrote: I have this test code: struct Thing { uint x; } void main(){ uint[] ar1 = [1, 2, 3, 4, 5]; auto min1 = ar1.reduce!((a,b) = a b); writefln(%s, min1);

Re: Downloading Files in D

2014-09-11 Thread Jacob Carlborg via Digitalmars-d-learn
On 11/09/14 00:05, Nordlöw wrote: I'm asking because I've read somewhere that there have been complaints about the curl wrapper. If you don't want to worry about dependencies on libcurl you can use Tango [1] [2]. You can see how I use Tango to download files in DVM [3] [1]

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 14:18:31 UTC, Colin wrote: Ah ok. I get it. Thanks daniel! a quiet better version: import std.stdio; import std.algorithm; struct Thing { uint x; alias x this; } void main(){ uint[] ar1 = [1, 2, 3, 4, 5]; auto min1 =

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 14:39:53 UTC, Daniel Kozak wrote: On Thursday, 11 September 2014 at 14:18:31 UTC, Colin wrote: Ah ok. I get it. Thanks daniel! a quiet better version: import std.stdio; import std.algorithm; struct Thing { uint x; alias x this; } void

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread bearophile via Digitalmars-d-learn
Daniel Kozak: You can just use min: import std.stdio, std.algorithm; struct Thing { uint x; alias x this; } alias minimum = reduce!min; void main() { immutable ar1 = [10, 20, 30, 40, 50]; ar1.minimum.writeln; immutable ar2 = [Thing(10), Thing(20), Thing(40)];

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 11 Sep 2014 14:49:02 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Daniel Kozak: You can just use min: import std.stdio, std.algorithm; struct Thing { uint x; alias x this; } alias minimum = reduce!min; void main() {

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 14:56:00 UTC, Daniel Kozak via Digitalmars-d-learn wrote: V Thu, 11 Sep 2014 14:49:02 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Daniel Kozak: You can just use min: import std.stdio, std.algorithm; struct Thing {

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 15:07:03 UTC, Daniel Kozak wrote: or use alias minimum = reduce!a b; ;) ok this one does not work

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 11 September 2014 at 14:56:00 UTC, Daniel Kozak via Digitalmars-d-learn wrote: V Thu, 11 Sep 2014 14:49:02 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Daniel Kozak: You can just use min: import std.stdio, std.algorithm; struct Thing {

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 11 September 2014 at 15:29:18 UTC, Daniel Kozak wrote: On Thursday, 11 September 2014 at 15:07:03 UTC, Daniel Kozak wrote: or use alias minimum = reduce!a b; ;) ok this one does not work Yeah, it's actually reduce!a b ? a : b

Re: alias this cast

2014-09-11 Thread andre via Digitalmars-d-learn
I am not sure. b is C but everything not in super class B is hidden. Using cast I can cast b to a full C. The cast cast(C)b has the same information about b like the cast cast(A)b: The memory area of b knows compatitibility to C and also the alias. For me, using alias this, the object b has

Re: alias this cast

2014-09-11 Thread Ali Çehreli via Digitalmars-d-learn
On 09/11/2014 09:18 AM, andre wrote: I am not sure. b is C but everything not in super class B is hidden. Using cast I can cast b to a full C. The cast cast(C)b has the same information about b like the cast cast(A)b: The memory area of b knows compatitibility to C and also the alias.

How can I use AVX instructions in D inline asm?

2014-09-11 Thread John via Digitalmars-d-learn
Hi. Now I try to use SSE/AVX instructions in D inline asm. I have a trouble about this. In http://dlang.org/iasm.html , AVX seems to be supported according to SIMD section in the paeg. But there is no AVX opcodes, like vaddps, in Opcodes section in the page. So I have assumed addps can be

Re: Downloading Files in D

2014-09-11 Thread Nordlöw
On Thursday, 11 September 2014 at 14:30:39 UTC, Jacob Carlborg wrote: If you don't want to worry about dependencies on libcurl you can use Tango [1] [2]. You can see how I use Tango to download files in DVM [3] Ok, thanks. And I guess vibe.d can do this aswell without external dependencies,

Re: Downloading Files in D

2014-09-11 Thread Danyal Zia via Digitalmars-d-learn
On Thursday, 11 September 2014 at 17:37:24 UTC, Nordlöw wrote: Ok, thanks. And I guess vibe.d can do this aswell without external dependencies, right? I'm also interested to know how this can be done with vibe.d...

Re: Downloading Files in D

2014-09-11 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 11 September 2014 at 17:37:24 UTC, Nordlöw wrote: On Thursday, 11 September 2014 at 14:30:39 UTC, Jacob Carlborg wrote: If you don't want to worry about dependencies on libcurl you can use Tango [1] [2]. You can see how I use Tango to download files in DVM [3] Ok, thanks. And I

UDAs in Place of alias.thised Wrapper Structs

2014-09-11 Thread Nordlöw
Are the pros to using - UDAs instead of - wrapper structs - alias this to provide extra semantic information like units of measurement in terms of compilation speed memory usage and expressivity I'm asking because I'm planning on converting my

Re: std.range.byLine

2014-09-11 Thread Nordlöw
On Thursday, 11 September 2014 at 10:19:17 UTC, monarch_dodra wrote: Well, the issue is that this isn't very portable for *reading*, as even on linux, you may read files with \r\n line endings (It's standard for csv files, for example), or read \n terminated files on windows. The issue is that

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Meta via Digitalmars-d-learn
On Thursday, 11 September 2014 at 14:49:03 UTC, bearophile wrote: void main() { //... immutable ar2 = [Thing(10), Thing(20), Thing(40)]; ar2.minimum.writeln; } Bye, bearophile Even better: void main { immutable(Thing)[] ar2 = [10, 20, 40];

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Colin via Digitalmars-d-learn
On Thursday, 11 September 2014 at 14:49:03 UTC, bearophile wrote: Daniel Kozak: You can just use min: import std.stdio, std.algorithm; struct Thing { uint x; alias x this; } alias minimum = reduce!min; void main() { immutable ar1 = [10, 20, 30, 40, 50];

Re: std.range.byLine

2014-09-11 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 11 September 2014 at 20:03:26 UTC, Nordlöw wrote: On Thursday, 11 September 2014 at 10:19:17 UTC, monarch_dodra wrote: Well, the issue is that this isn't very portable for *reading*, as even on linux, you may read files with \r\n line endings (It's standard for csv files, for

Re: std.range.byLine

2014-09-11 Thread Nordlöw
On Thursday, 11 September 2014 at 21:29:16 UTC, monarch_dodra wrote: Bummer... Anyway, it shouldn't be too hard to express this in a new range.

Re: std.range.byLine

2014-09-11 Thread Nordlöw
On Thursday, 11 September 2014 at 21:29:16 UTC, monarch_dodra wrote: Hum... no, those are the correct splitting elements. However, I don't think that would actually work, as find will privilege the first whole element to match as a hit, so \r\n never be hit (rather, it will be hit twice, in

Re: std.range.byLine

2014-09-11 Thread Nordlöw
On Thursday, 11 September 2014 at 21:54:39 UTC, Nordlöw wrote: Anyway, it shouldn't be too hard to express this in a new range. I guess what we need is a variant of splitter with a more greedy alias template parameter that will digest two or one bytes.

Re: std.range.byLine

2014-09-11 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Sep 11, 2014 at 10:31:33PM +, Nordlöw via Digitalmars-d-learn wrote: On Thursday, 11 September 2014 at 21:54:39 UTC, Nordlöw wrote: Anyway, it shouldn't be too hard to express this in a new range. I guess what we need is a variant of splitter with a more greedy alias template

Re: DUB: link to local library

2014-09-11 Thread rcor via Digitalmars-d-learn
Finally got it: { name: test, importPaths: [ext/dallegro5], lflags: [-Lext/dallegro5], libs: [ allegro, allegro_acodec, allegro_audio, allegro_font, allegro_ttf, allegro_image, allegro_color, allegro_primitives ], dependencies: { dallegro5: ~master

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Meta via Digitalmars-d-learn
On Thursday, 11 September 2014 at 21:28:59 UTC, Colin wrote: Using the alias x this solution would work, but my actual struct is not a simple struct, so the comparison isn't exactly (a.x b.x). You could always override opCmp as well: http://dlang.org/operatoroverloading.html#compare

Is º an unicode alphabetic character?

2014-09-11 Thread AsmMan via Digitalmars-d-learn
what's an unicode alphabetic character? I misunderstood isAlpha(), I used to think it's to validate letters like a, b, è, é .. z etc but isAlpha('º') from std.uni module return true. How can I validate only the letters of an unicode alphabet in D or should I write one? I know I can do: bool

profiling issues

2014-09-11 Thread Vlad Levenfeld via Digitalmars-d-learn
I've got a library I've been building up over a few projects, and I've only ever run it under debug unittest and release (with dub buildOptions). Lately I've needed to control the performance more carefully, but unfortunately trying to compile with dub --profile gives me some strange errors:

Idiomatic async programming like C# async/await

2014-09-11 Thread Cliff via Digitalmars-d-learn
(New to D, old hand at software engineering...) I come from .NET and have made heavy use of the async/await programming paradigm there. In particular, the Task mechanism (futures/promises) lets one encapsulate the future result of some work and pass that around. D seems to have something

Re: Is º an unicode alphabetic character?

2014-09-11 Thread Ali Çehreli via Digitalmars-d-learn
On 09/11/2014 08:04 PM, AsmMan wrote: what's an unicode alphabetic character? Alphabetic is defined as Lu + Ll + Lt + Lm + Lo + Nl + Other_Alphabetic, all of which are explained here: http://www.unicode.org/Public/5.1.0/ucd/UCD.html#General_Category_Values I misunderstood isAlpha(), I