Re: std.file.read returns void[] why?

2014-04-18 Thread monarch_dodra via Digitalmars-d-learn
On Thursday, 17 April 2014 at 21:27:44 UTC, Steven Schveighoffer wrote: On Thu, 17 Apr 2014 17:04:25 -0400, monarch_dodra monarchdo...@gmail.com wrote: void[] will only make sense once you've accepted that void.sizeof == 1. It is already accepted that when we talk about length in a void[],

Re: std.file.read returns void[] why?

2014-04-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 18 Apr 2014 02:04:16 -0400, monarch_dodra monarchdo...@gmail.com wrote: On Thursday, 17 April 2014 at 21:27:44 UTC, Steven Schveighoffer wrote: On Thu, 17 Apr 2014 17:04:25 -0400, monarch_dodra monarchdo...@gmail.com wrote: void[] will only make sense once you've accepted that

Re: Dynamically Sized Structs

2014-04-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 18 Apr 2014 00:05:03 -0400, Kagamin s...@here.lot wrote: Well, it's proof of concept of bound checked variable-size struct, I wrote it in a minute. It even compiles and runs. Please take no offense :) I just was pointing out a difference between a hand-managed and hand-written

Re: std.file.read returns void[] why?

2014-04-18 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 18 April 2014 at 13:08:04 UTC, Steven Schveighoffer wrote: I admit, I didn't think C's void had a size ;) I'm pretty sure it doesn't in D, but then again... -Steve Yeah... static assert(void.sizeof == 1); passes :/ So in any case, long story short: void[]: This is an un-typed

Re: Dynamically Sized Structs

2014-04-18 Thread Kagamin via Digitalmars-d-learn
Oh, and I don't believe, that a variable-size struct can be emplaced inside fixed-size struct or class. Only as a smart pointer from the example.

Re: Dynamically Sized Structs

2014-04-18 Thread Kagamin via Digitalmars-d-learn
I mean, it doesn't cover all scenarios, but can be extended to support them. The indexes array does just that: it's emplaced without indirection, but still is bound checked.

Re: Dynamically Sized Structs

2014-04-18 Thread Kagamin via Digitalmars-d-learn
On Friday, 18 April 2014 at 13:10:28 UTC, Steven Schveighoffer wrote: Note, you could probably, with mixin magic, make a version that could be emplaced inside a struct or class without an extra indirection. Speaking about mixin magic, you probably suggest to do it overly generically, though

On Concurrency

2014-04-18 Thread Nordlöw
Could someone please give some references to thorough explainings on these latest concurrency mechanisms - Go: Goroutines - Coroutines (Boost): - https://en.wikipedia.org/wiki/Coroutine - http://www.boost.org/doc/libs/1_55_0/libs/coroutine/doc/html/coroutine/intro.html - D:

Re: Dynamically Sized Structs

2014-04-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Fri, 18 Apr 2014 12:59:35 -0400, Kagamin s...@here.lot wrote: Oh, and I don't believe, that a variable-size struct can be emplaced inside fixed-size struct or class. Only as a smart pointer from the example. It goes at the end. Then you need to allocate the whole thing with that in

Re: On Concurrency

2014-04-18 Thread Nordlöw
Correction: The references I gave _are_ theoretically thorough, so I'm satisified with these for now. I'm however still interested in the D-specific questions I asked.

Reducing an array

2014-04-18 Thread Tim Holzschuh via Digitalmars-d-learn
Hi there, I try to remove all equal elements of an array, thus [2,2] -- [2]. I thought this maybe would be possible with std.algorithm.reduce, but at least the way I tried it doesn't work: arr.reduce( (a,b) = a != b ); Is there a simple solution using Phobos-functions? Thank you, Tim

Re: Reducing an array

2014-04-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thu, 17 Apr 2014 09:46:25 -0400, Tim Holzschuh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi there, I try to remove all equal elements of an array, thus [2,2] -- [2]. I thought this maybe would be possible with std.algorithm.reduce, but at least the way I tried it

Re: Reducing an array

2014-04-18 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 18 April 2014 at 20:27:20 UTC, Steven Schveighoffer wrote: Note also that what it returns is not an array, but a lazily iterated range over the array. If you want another array, this is the code I would use: arr.sort(); arr = arr.uniq.array(); -Steve Out of curiosity, if the

Re: Reducing an array

2014-04-18 Thread bearophile via Digitalmars-d-learn
monarch_dodra: Out of curiosity, if the requirement was to *also* preserve ordering (eg: remove all non-first elements), how would you go at it? [2, 1, 1, 3, 2, 3] = [2, 1, 3]; Maybe std.algorithm's `makeIndex` would help here? Bonus points for doing it inplace. This preserves ordering

arrays in DMD V2

2014-04-18 Thread steven kladitis via Digitalmars-d-learn
import std.stdio; void main() { inta0[]; inta1[][]; string a2[][]; string a3[][string]; string a4[][string][string]; //string a4[string][string][string]; is this the same as above inta5[][string][string][string]; inta6[string][int][string][float]; int

Re: arrays in DMD V2

2014-04-18 Thread Jesse Phillips via Digitalmars-d-learn
On Saturday, 19 April 2014 at 00:27:32 UTC, steven kladitis wrote: import std.stdio; void main() { inta0[]; inta1[][]; string a2[][]; string a3[][string]; string a4[][string][string]; //string a4[string][string][string]; is this the same as above int

Re: arrays in DMD V2

2014-04-18 Thread steven kladitis via Digitalmars-d-learn
Thanks, I am trying to understand what I am doing. The docs seem unclear to me on how to initialize these. I think there are three ways. with brackets , the other with foreach or direct assignments. -- here is a longer version -- uncomment out the assignments to see the errors I get. -- I am

Re: arrays in DMD V2

2014-04-18 Thread steven kladitis via Digitalmars-d-learn
import std.stdio; void main() { inta0[]; inta1[][]; string a2[][]; string a3[][string]; string a4[][string][string]; //string a4[string][string][string]; is this the same as above inta5[][string][string][string]; inta6[string][int][string][float]; int