Re: various questions

2010-07-29 Thread Rory Mcguire
Jason Spencer wrote: > Ok, I've gone over this, adapted it, and mostly understand it. I just > have one question left: > > == Quote from bearophile (bearophileh...@lycos.com)'s article >> template Iota(int stop) { >> ... >> alias TypeTuple!(Iota!(stop-1), stop-1) Iota; >> } >> ... >>

Re: Wanting an immutable associative array in a class

2010-07-29 Thread bearophile
RedZone: > But it would be nice if I could have the array reference itself be immutable > and not just the array's contents. Is there any way I could do this? Let's say your code is as your second example: class Foo { private: immutable int[string] bar; public: this() {

Wanting an immutable associative array in a class

2010-07-29 Thread RedZone
Hello, I have a class wherein I want an immutable associative array. I tried to do it like this: class Foo { private: immutable int[char[]] Bar = ["AB":1, "CD":2, "EF":3]; public: this() { ... } ... } But the compiler tells me that ["AB":1, "CD":2, "EF":3] i

Errors with typeid

2010-07-29 Thread bearophile
This is wrong D2 code, with one bug I've created yesterday, it generates an interesting sequence of error messages: http://ideone.com/MUkrN Is this example worth for Bugzilla? template Tuple(T...) { alias T Tuple; } void main() { alias Tuple!(int) foo; auto x = typeid(foo[int]); } Bye,

Re: alias = compile-time variants?

2010-07-29 Thread bearophile
Jason Spencer: > In writing templates that make heavy use of alias parameters, does > anyone else feel uneasy about whether the caller will pass a type, a > value, or a schmoo? Normally D is a mostly statically typed language (objects have a dynamic type), but sometimes template juggling is purel

Re: various questions

2010-07-29 Thread Jason Spencer
Ok, I've gone over this, adapted it, and mostly understand it. I just have one question left: == Quote from bearophile (bearophileh...@lycos.com)'s article > template Iota(int stop) { > ... > alias TypeTuple!(Iota!(stop-1), stop-1) Iota; > } > ... > foreach (t; Iota!(str_types.length)

alias = compile-time variants?

2010-07-29 Thread Jason Spencer
In writing templates that make heavy use of alias parameters, does anyone else feel uneasy about whether the caller will pass a type, a value, or a schmoo? I'm having a hard time getting my head around how wide-open aliases are and trying to resist the urge to put in thousands of static asserts to

Re: D2: Indexed format specifiers?

2010-07-29 Thread Nick Sabalausky
"Jonathan M Davis" wrote in message news:mailman.49.1280424679.13841.digitalmars-d-le...@puremagic.com... > On Thursday, July 29, 2010 00:54:27 Nick Sabalausky wrote: >> I could have sworn I saw Andrei say somewhere a while ago that Phobos2 >> supported posix-style indexed format specifiers. From

Re: Stack traces on exceptions in D2?

2010-07-29 Thread Nick Sabalausky
"Jacob Carlborg" wrote in message news:i2sfk4$185...@digitalmars.com... > On 2010-07-29 13:44, Don wrote: >> Nick Sabalausky wrote: >>> Is there a way to get stack traces on exceptions in D2? >>> >>> >> It's not yet implemented on Windows. Mainly because Sean hasn't had >> enough free time. > > D

Re: Stack traces on exceptions in D2?

2010-07-29 Thread Jacob Carlborg
On 2010-07-29 13:44, Don wrote: Nick Sabalausky wrote: Is there a way to get stack traces on exceptions in D2? It's not yet implemented on Windows. Mainly because Sean hasn't had enough free time. Does tango have stack traces on windows? Or I guess it doesn't matter, can't use the code fro

Re: various questions

2010-07-29 Thread Steven Schveighoffer
On Wed, 28 Jul 2010 14:52:11 -0400, Jason Spencer wrote: I'm working on a program to do statistics on matrices of different sizes, and I've run into a handful of situations where I just can't seem to find the trick I need. In general, I'm trying to make my functions work on static arrays o

Re: D2: Indexed format specifiers?

2010-07-29 Thread Jonathan M Davis
On Thursday, July 29, 2010 00:54:27 Nick Sabalausky wrote: > I could have sworn I saw Andrei say somewhere a while ago that Phobos2 > supported posix-style indexed format specifiers. From what I could figure > out from some searching that on the web, those are like "%1$s". But this > gives me a For

Re: various questions

2010-07-29 Thread Kagamin
Kagamin Wrote: > Jason Spencer Wrote: > > > If I want to avoid the copy, am I relegated back > > to pointers? > or something like this struct ReferenceArray!(ArrayType) { ArrayType* back; this(byte[] data) { assert(data.length==ArrayType.sizeof); back = cast(ArrayType*)data.ptr;

Re: various questions

2010-07-29 Thread Kagamin
Jason Spencer Wrote: > If I want to avoid the copy, am I relegated back > to pointers? you can make a thin wrapper that will work as a reference-type static array struct ReferenceArray!(ElementType, int columns, int rows) { ElementType[columns][rows]* back; this(byte[] data) { assert(d

Re: SIGSEGV in rt_finalize

2010-07-29 Thread Rory Mcguire
Steven Schveighoffer wrote: > On Wed, 28 Jul 2010 11:45:59 -0400, Rory Mcguire > wrote: > >> Hi guys, >> >> I have a 265 line program that gets a segmentation fault if I don't >> comment >> out this while loop(I am not using delete or anything like it): >> /+ while (lines.length > 0 && line

Re: SIGSEGV in rt_finalize

2010-07-29 Thread Steven Schveighoffer
On Wed, 28 Jul 2010 11:45:59 -0400, Rory Mcguire wrote: Hi guys, I have a 265 line program that gets a segmentation fault if I don't comment out this while loop(I am not using delete or anything like it): /+ while (lines.length > 0 && line.length > 3 && line[3]=='-') { li

Re: Stack traces on exceptions in D2?

2010-07-29 Thread Don
Nick Sabalausky wrote: Is there a way to get stack traces on exceptions in D2? It's not yet implemented on Windows. Mainly because Sean hasn't had enough free time.

Re: Stack traces on exceptions in D2?

2010-07-29 Thread Rory Mcguire
Nick Sabalausky wrote: > "Nick Sabalausky" wrote in message > news:i2rbht$22v...@digitalmars.com... >> "Rory Mcguire" wrote in message >> news:i2rafu$20l...@digitalmars.com... >>> Nick Sabalausky wrote: >>> Is there a way to get stack traces on exceptions in D2? >>> What OS. >>> >>> I'm on

Re: Stack traces on exceptions in D2?

2010-07-29 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:i2rbht$22v...@digitalmars.com... > "Rory Mcguire" wrote in message > news:i2rafu$20l...@digitalmars.com... >> Nick Sabalausky wrote: >> >>> Is there a way to get stack traces on exceptions in D2? >> What OS. >> >> I'm on linux and I get stack traces. > >

D2: Indexed format specifiers?

2010-07-29 Thread Nick Sabalausky
I could have sworn I saw Andrei say somewhere a while ago that Phobos2 supported posix-style indexed format specifiers. From what I could figure out from some searching that on the web, those are like "%1$s". But this gives me a FormatException: "%1$s".format("A"); And this works fine: "%s".f

Re: Stack traces on exceptions in D2?

2010-07-29 Thread Nick Sabalausky
"Rory Mcguire" wrote in message news:i2rafu$20l...@digitalmars.com... > Nick Sabalausky wrote: > >> Is there a way to get stack traces on exceptions in D2? > What OS. > > I'm on linux and I get stack traces. Windows. Must be a debug-only thing though (not sure why I thought otherwise). I've be

Re: Stack traces on exceptions in D2?

2010-07-29 Thread Rory Mcguire
Nick Sabalausky wrote: > Is there a way to get stack traces on exceptions in D2? What OS. I'm on linux and I get stack traces.

Stack traces on exceptions in D2?

2010-07-29 Thread Nick Sabalausky
Is there a way to get stack traces on exceptions in D2?