Re: Array slice length confusion

2009-07-08 Thread BCS
Hello Tim, Anyway I like how you can get a slice of array that is just a view into the original. If I modify the slice, it modifies the full original array which can be very useful. If however I modify the length of the slice which I was doing in an attempt to extend the view, it becomes it's ow

Re: Array slice length confusion

2009-07-08 Thread Tim Matthews
Steven Schveighoffer wrote: This is really not a good idea. You've removed one of the core features of the array -- memory safety. Doing this is just asking for memory corruption. You should either re-slice the original array, or create a type that has a reference to the original array so it

Re: Array slice length confusion

2009-07-08 Thread Steven Schveighoffer
On Wed, 08 Jul 2009 23:09:52 -0400, Tim Matthews wrote: Steven Schveighoffer wrote: On Wed, 08 Jul 2009 02:48:31 -0400, Tim Matthews wrote: Was this a design choice, bug, undefined behavior, etc...? design choice. A slice *is* an array in the current design. Increasing the length

Re: Array slice length confusion

2009-07-08 Thread Tim Matthews
Steven Schveighoffer wrote: On Wed, 08 Jul 2009 02:48:31 -0400, Tim Matthews wrote: Was this a design choice, bug, undefined behavior, etc...? design choice. A slice *is* an array in the current design. Increasing the length may or may not make a copy of it. An array slice doesn't know

mkdirRecurse behaving strangly

2009-07-08 Thread Trass3r
I want to extract some files from a game archive providing path strings like "data/ai/campaign/leaders.csv". So I tried mkdirRecurse to create the directory structure, this works fine but also creates folders named after the files, "leaders.csv" in this case. So I added dirname: mkdirRecurse(di

Re: Specify the type but not number of function arguments in an interface?

2009-07-08 Thread downs
Jarrett Billingsley wrote: > On Tue, Jul 7, 2009 at 8:29 AM, downs wrote: >> But then isn't what he asks for kinda impossible by design? I mean, >> interfaces are bound at runtime. That's what they _do_. >> > > Now read *my* post, downs. ;) :blushes:

Retrieve base type of an array (D2)

2009-07-08 Thread AxelS
Here I created a template for getting an arrays base type. I also made the std.string.replaceSlice function accessible with wstrings. May someone could use it or integrate it into phobos... (module std.traits) template ArrayBaseType(A : E[],E) { alias E ArrayBaseType; } (module std.str

Re: assert

2009-07-08 Thread Tim Matthews
Ellery Newcomer wrote: I'm tired and witless just now, but I can't think of any reason why assert should be an expression and not a statement. Any clues? assert only evaluates to void but maybe someone writes something like: module test; import std.stdio; void main() { bool readyForMath

Re: Array slice length confusion

2009-07-08 Thread Tim Matthews
Kagamin wrote: For this I use begin markers: ubyte[] buff=new ubyte[100]; int half=buff.length/2; ubyte[] buff1=buff[0..half]; ubyte[] buff2=buff[half..$]; I actually think this has nothing to do with my OP.

Re: D2 using std.proccess.shell

2009-07-08 Thread Lars T. Kyllingstad
Jesse Phillips wrote: On Tue, 07 Jul 2009 12:04:43 +0200, Lars T. Kyllingstad wrote: Jesse Phillips wrote: I don't know if I'm misunderstanding the use of shell() or if this is a bug. Trying to run some programs with shell error with a could not close file. Sadly it I can come to any reasonabl

Re: assert

2009-07-08 Thread Kagamin
Ellery Newcomer Wrote: > I'm tired and witless just now, but I can't think of any reason why > assert should be an expression and not a statement. > > Any clues? A requirement for assert expression to be inside ExpressionStatement?

Re: Array slice length confusion

2009-07-08 Thread Kagamin
Kagamin Wrote: > Tim Matthews Wrote: > > > Was this a design choice, bug, undefined behavior, etc...? > > Design choice. In order to widen slice to should recreate it from the > original array. For this I use begin markers: ubyte[] buff=new ubyte[100]; int half=buff.length/2; ubyte[] buff1=bu

Re: Array slice length confusion

2009-07-08 Thread Kagamin
Tim Matthews Wrote: > Was this a design choice, bug, undefined behavior, etc...? Design choice. In order to widen slice to should recreate it from the original array.

assert

2009-07-08 Thread Ellery Newcomer
I'm tired and witless just now, but I can't think of any reason why assert should be an expression and not a statement. Any clues?