Re: Array literal template parameter?

2012-11-20 Thread Jacob Carlborg
On 2012-11-21 00:22, Maxime Chevalier wrote: I need to pass an array literal as a template parameter. The reference on this website seems to imply this is possible, but doesn't illustrate it. The obvious way doesn't seem to work: mixin template MyTemplate(int[] arr) {} Error: arithmetic/string t

parallelism with message passing

2012-11-20 Thread Joshua Niehus
Hello, Im starting one process in the main thread who in turn is going to kick off another process but has no way of passing along main's Tid, hence the shared(Tid) nonsense. * This works in serial (i.e. change workUnitSize > x.length in mains foreach loop). * It also works when passing the tid

making COW and ownership

2012-11-20 Thread Era Scarecrow
I was thinking briefly and glancing over documentation regarding cluts and non-cluts (Reference vs value types), and considering my BitArray implementation. I was having a problem trying to solve how to avoid duplicating it unless it actually was needed; And I've come to a possible solution.

Re: runtime static arrays

2012-11-20 Thread bearophile
Jonathan M Davis: One serious problem posed by them is that the size then can't be part of the type, meaning that you can't possibly pass them around. If you did, you'd just be passing dynamic arrays around. Take a look at my code, few posts above. When a VLA is passed to a function, it "de

Re: runtime static arrays

2012-11-20 Thread Jonathan M Davis
On Wednesday, November 21, 2012 02:26:35 bearophile wrote: > Namespace: > > Is there an official statement why Walter dislike them? > > In the last years I remember no comments from him about this > topic. But he has not closed my enhancement request. One serious problem posed by them is that the

Re: runtime static arrays

2012-11-20 Thread bearophile
Namespace: Is there an official statement why Walter dislike them? In the last years I remember no comments from him about this topic. But he has not closed my enhancement request. Bye, bearophile

Re: runtime static arrays

2012-11-20 Thread Namespace
Is there an official statement why Walter dislike them?

Re: runtime static arrays

2012-11-20 Thread bearophile
Jonathan M Davis: Personally though, I wish that the length of static arrays could be set at runtime and don't really understand why you can't (aside from the fact that you can't in standard C - gcc will let you though). Variable Length Arrays are part of the standard in C since C99, and th

Re: Array literal template parameter?

2012-11-20 Thread bearophile
Maxime Chevalier: I need to pass an array literal as a template parameter. The reference on this website seems to imply this is possible, but doesn't illustrate it. The obvious way doesn't seem to work: It's a known compiler bug, already in Bugzilla. In the meantime this is a workaround: te

Re: runtime static arrays

2012-11-20 Thread Jonathan M Davis
On Wednesday, November 21, 2012 00:30:16 Namespace wrote: > Yeah, but it's inconvenient to use a struct instead of a built in > solution. ;) But if the built-in solution doesn't do what you want, then that's what you have to do. And the only built-in solutions are to either have a static array w

Re: Array literal template parameter?

2012-11-20 Thread Timon Gehr
On 11/21/2012 12:22 AM, Maxime Chevalier wrote: I need to pass an array literal as a template parameter. The reference on this website seems to imply this is possible, but doesn't illustrate it. The obvious way doesn't seem to work: mixin template MyTemplate(int[] arr) {} Error: arithmetic/strin

Re: runtime static arrays

2012-11-20 Thread Namespace
It's pretty trivial to create a struct which uses malloc and free to create a dynamic array of the exact size that you want with deterministic destruction, and you can easily overload the indexing and slicing operators - though clearly, as if with static arrays, you'd have to be careful with sl

Array literal template parameter?

2012-11-20 Thread Maxime Chevalier
I need to pass an array literal as a template parameter. The reference on this website seems to imply this is possible, but doesn't illustrate it. The obvious way doesn't seem to work: mixin template MyTemplate(int[] arr) {} Error: arithmetic/string type expected for value-parameter, not int[]

Re: runtime static arrays

2012-11-20 Thread Ali Çehreli
On 11/20/2012 02:59 PM, Jonathan M Davis wrote: > On Tuesday, November 20, 2012 14:52:56 Ali Çehreli wrote: >> This is a surprisingly promising start: :) > How is that any different from just using a static array? I know, I know... That surprising start surprised me too. :p Ali

Re: runtime static arrays

2012-11-20 Thread Jonathan M Davis
On Tuesday, November 20, 2012 14:52:56 Ali Çehreli wrote: > On 11/20/2012 02:46 PM, Namespace wrote: > > Something like: > > scope int[8] arr; > > or > > scope int[i] arr; > > > > would be cool. You get an resizeable array which capactiy is all the > > time equal to his length. And it is destroyed

Re: runtime static arrays

2012-11-20 Thread Jonathan M Davis
On Tuesday, November 20, 2012 23:46:39 Namespace wrote: > Something like: > scope int[8] arr; > or > scope int[i] arr; > > would be cool. You get an resizeable array which capactiy is all > the time equal to his length. And it is destroyed after the > liftetime of the scope. > > Maybe some stuff

Re: runtime static arrays

2012-11-20 Thread Ali Çehreli
On 11/20/2012 02:46 PM, Namespace wrote: Something like: scope int[8] arr; or scope int[i] arr; would be cool. You get an resizeable array which capactiy is all the time equal to his length. And it is destroyed after the liftetime of the scope. Maybe some stuff for Remus... This is a surprisi

Re: runtime static arrays

2012-11-20 Thread bearophile
Namespace: scope int[8] arr; or scope int[i] arr; See also: http://d.puremagic.com/issues/show_bug.cgi?id=5348 Bye, bearophile

Re: runtime static arrays

2012-11-20 Thread Namespace
Something like: scope int[8] arr; or scope int[i] arr; would be cool. You get an resizeable array which capactiy is all the time equal to his length. And it is destroyed after the liftetime of the scope. Maybe some stuff for Remus...

Re: hash design problem: both string and int[] keys

2012-11-20 Thread Charles Hixson
Charles Hixson wrote: Ali Çehreli wrote: On 11/20/2012 11:39 AM, Charles Hixson wrote: > I'm trying to figure out how to construct an associative array whose > keys will be a combination of strings and immutable int[]'s, but every > approach I've looked at has run into problems. Can you show s

Re: hash design problem: both string and int[] keys

2012-11-20 Thread Jonathan M Davis
On Tuesday, November 20, 2012 12:42:50 Charles Hixson wrote: > > > It should be relatively > > > easy, as strings are really just an immutable list of ints, > > > > A list of dchars is more accurate of course, but yes, dchar can be > > casted to int. > > Well, longs anyway. Which is a minor pr

Re: hash design problem: both string and int[] keys

2012-11-20 Thread Charles Hixson
Ali Çehreli wrote: On 11/20/2012 11:39 AM, Charles Hixson wrote: > I'm trying to figure out how to construct an associative array whose > keys will be a combination of strings and immutable int[]'s, but every > approach I've looked at has run into problems. Can you show some code? Sorry, I'm

Re: hash design problem: both string and int[] keys

2012-11-20 Thread Ali Çehreli
On 11/20/2012 11:39 AM, Charles Hixson wrote: > I'm trying to figure out how to construct an associative array whose > keys will be a combination of strings and immutable int[]'s, but every > approach I've looked at has run into problems. Can you show some code? > It should be relatively > easy

Re: runtime static arrays

2012-11-20 Thread Namespace
Yes, but I could also use alloca. What I mean is the shortness of int[4] arr or for (int i = 0; i < 42; i += 4) { int[i] arr; } I take a look at the std.container Array.

hash design problem: both string and int[] keys

2012-11-20 Thread Charles Hixson
I'm trying to figure out how to construct an associative array whose keys will be a combination of strings and immutable int[]'s, but every approach I've looked at has run into problems. It should be relatively easy, as strings are really just an immutable list of ints, but I haven't been able

Re: runtime static arrays

2012-11-20 Thread Ali Çehreli
On 11/20/2012 06:25 AM, Namespace wrote: Is there any need for 'smart' or 'compressed' arrays? In my last projects I had some situations where I need an array, but only for one scope. But I could not use static arrays, because I didn't know the size at compile time. So I used 'alloca'. But 'allo

Re: template library like Jinja

2012-11-20 Thread Jacob Carlborg
On 2012-11-20 16:25, Tobias Pankrath wrote: Except for (optional) html escaping it has no special support for any text format. HTML is the biggest use case though. Ok, I didn't know that. -- /Jacob Carlborg

Re: template library like Jinja

2012-11-20 Thread Tobias Pankrath
On 20.11.2012 15:15, Jacob Carlborg wrote: On 2012-11-20 14:31, Tobias Pankrath wrote: I don't want to generate xml/html but code. :-) Isn't Jinja for HTML? It looks like it is. Except for (optional) html escaping it has no special support for any text format. HTML is the biggest use case

Re: runtime static arrays

2012-11-20 Thread bearophile
Namespace: Furthermore dynamic arrays costs more memory as I needed, But maybe this doesn't happen in your case. Am I wrong and dynamic arrays are the solution? Take also a look at the Array of Phobos. Bye, bearophile

runtime static arrays

2012-11-20 Thread Namespace
Is there any need for 'smart' or 'compressed' arrays? In my last projects I had some situations where I need an array, but only for one scope. But I could not use static arrays, because I didn't know the size at compile time. So I used 'alloca'. But 'alloca' has a terrible interface and in som

Re: template library like Jinja

2012-11-20 Thread Jacob Carlborg
On 2012-11-20 14:31, Tobias Pankrath wrote: I don't want to generate xml/html but code. :-) Isn't Jinja for HTML? It looks like it is. -- /Jacob Carlborg

Re: foreach loop + counter iter + Phobos range

2012-11-20 Thread bearophile
bioinfornatics: fastqFile.byFastq() return a Tuple!(ulong,Fastq) in this case foreach fail to aggregate correctly Try to minimize the code that produces this problem, so if it's a real problem it becomes fodder for Bugzilla. Bye, bearophile

Re: foreach loop + counter iter + Phobos range

2012-11-20 Thread bearophile
bioinfornatics: but it seem is not aggregate by the foreach loop :-( Generally if you want to help who gives help you have to show the full code (or its compilable reduction) and copy&paste the error you get... Bye, bearophile

Re: foreach loop + counter iter + Phobos range

2012-11-20 Thread bioinfornatics
On Tuesday, 20 November 2012 at 12:32:45 UTC, bioinfornatics wrote: On Tuesday, 20 November 2012 at 11:33:23 UTC, bearophile wrote: bioinfornatics: what is wrong at line 171 ? i am explicit i said i want a counter iterator and a Fasta struct! See: http://d.puremagic.com/issues/show_bug.cgi?i

Re: template library like Jinja

2012-11-20 Thread Tobias Pankrath
On 20.11.2012 13:48, Jacob Carlborg wrote: On 2012-11-20 12:38, Tobias Pankrath wrote: Is there any template library like Jinja? (jinja.pocoo.org). I'm pretty sure we can do even better by leveraging CTFE and a precompiler, but speed is no concern for me. vibe.d uses Jade templates. Jade: h

Re: template library like Jinja

2012-11-20 Thread Jacob Carlborg
On 2012-11-20 12:38, Tobias Pankrath wrote: Is there any template library like Jinja? (jinja.pocoo.org). I'm pretty sure we can do even better by leveraging CTFE and a precompiler, but speed is no concern for me. vibe.d uses Jade templates. Jade: http://jade-lang.com vibe.d: http://vibed.org

Re: foreach loop + counter iter + Phobos range

2012-11-20 Thread bioinfornatics
On Tuesday, 20 November 2012 at 11:33:23 UTC, bearophile wrote: bioinfornatics: what is wrong at line 171 ? i am explicit i said i want a counter iterator and a Fasta struct! See: http://d.puremagic.com/issues/show_bug.cgi?id=5550 Bye, bearophile thanks i vote up for your request is really

template library like Jinja

2012-11-20 Thread Tobias Pankrath
Is there any template library like Jinja? (jinja.pocoo.org). I'm pretty sure we can do even better by leveraging CTFE and a precompiler, but speed is no concern for me.

Re: foreach loop + counter iter + Phobos range

2012-11-20 Thread bearophile
bioinfornatics: what is wrong at line 171 ? i am explicit i said i want a counter iterator and a Fasta struct! See: http://d.puremagic.com/issues/show_bug.cgi?id=5550 Bye, bearophile