Re: various questions

2010-07-28 Thread Jason Spencer
That's COOL! I'll have to look at these closer, but I definitely get what you're doing. Thanks a million. == Quote from bearophile (bearophileh...@lycos.com)'s article > Simpler: > import std.stdio: writeln; > import std.typetuple: TypeTuple; > template Iota(int stop) { > static if (stop <=

Re: various questions

2010-07-28 Thread bearophile
Last version for now, it can be improved further in various ways: import std.typetuple: TypeTuple; import std.metastrings: Format; template Iota(int stop) { static if (stop <= 0) alias TypeTuple!() Iota; else alias TypeTuple!(Iota!(stop-1), stop-1) Iota; } enum string[]

Re: various questions

2010-07-28 Thread bearophile
Simpler: import std.stdio: writeln; import std.typetuple: TypeTuple; template Iota(int stop) { static if (stop <= 0) alias TypeTuple!() Iota; else alias TypeTuple!(Iota!(stop-1), stop-1) Iota; } void foo(T, int N, int M)() { writeln(typeid(T), " ", N, " ", M); } enum

Re: various questions

2010-07-28 Thread bearophile
This is better, probably it can be improves a bit more: import std.stdio: writeln; import std.metastrings: Format; import std.typetuple: TypeTuple; template Iota(int stop) { static if (stop <= 0) alias TypeTuple!() Iota; else alias TypeTuple!(Iota!(stop-1), stop-1) Iota; }

Re: various questions

2010-07-28 Thread bearophile
Jason Spencer: > I had thought of the switch, and it would be too large. Can you give me an > idea of what > the mixin solution would look like? Suppose I have three strings, type, > rows, and cols > that get set at runtime, where type = ["int" | "float" | "short"], rows and > cols = > ["100"

Re: various questions

2010-07-28 Thread Jason Spencer
== Quote from bearophile (bearophileh...@lycos.com)'s article Thanks for all the suggestions! A little more discussion: > > So I need some slick way of mapping the run-time element size, row count, > > and column count into a static array type to instantiate my template with. > A basic brutal wa

Re: various questions

2010-07-28 Thread bearophile
Jason Spencer: > 1. How can I cast a single dimension dynamic array to a multi-dimension > static array? I'm trying to do roughly the following: >auto data = cast(float[100][100])std.file.read(fname, fsize); I have tried a natural implementation, but it doesn't work and I don't know why it

Re: Still unresolved (Was: D1->D2 member call syntax regression?)

2010-07-28 Thread Nick Sabalausky
"Don" wrote in message news:i2q0un$2hu...@digitalmars.com... > Nick Sabalausky wrote: >> >> It still leaves the question though, "Why isn't that working in D2? Bug >> or legitimate reason?". >> >> Jonathan suggested it was deliberate because of the hidden "this" >> parameter, but I'm not convin

Re: Still unresolved (Was: D1->D2 member call syntax regression?)

2010-07-28 Thread Don
Nick Sabalausky wrote: "Nick Sabalausky" wrote in message news:i2pvvi$2g8...@digitalmars.com... "bearophile" wrote in message news:i2p4iq$p...@digitalmars.com... Nick Sabalausky: That's because my original example accidentally made Foo an uninstantiated class template, so the compiler never

Still unresolved (Was: D1->D2 member call syntax regression?)

2010-07-28 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:i2pvvi$2g8...@digitalmars.com... > "bearophile" wrote in message > news:i2p4iq$p...@digitalmars.com... >> Nick Sabalausky: >>> That's because my original example accidentally made Foo an >>> uninstantiated >>> class template, so the compiler never bother

Re: D1->D2 member call syntax regression?

2010-07-28 Thread Nick Sabalausky
"bearophile" wrote in message news:i2p4iq$p...@digitalmars.com... > Nick Sabalausky: >> That's because my original example accidentally made Foo an >> uninstantiated >> class template, so the compiler never bothered to check the semantics... > > Surely here there is no shortage of ways I can pai

Re: D2 map trouble

2010-07-28 Thread Nick Sabalausky
"Philippe Sigaud" wrote in message news:mailman.32.1280323222.13841.digitalmars-d-le...@puremagic.com... > > void foo(string str) > { > str = > std.algorithm.map!q{ > inPattern(a, [digits, letters])? a : '_'; > } > (str); > } > > But then I guess inPattern must be visible from std.algorithm. >

Re: various questions

2010-07-28 Thread Jason Spencer
Forgot a couple of things: - this is all using D2.047. - Another question (in reference to part 2 before): I'd like to support about 4 base types and 5 or 6 different matrix sizes. So that's roughly 20 type combinations for my template. But I decide these based on command-line arguments at run

various questions

2010-07-28 Thread Jason Spencer
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 of the proper size, and template that up for the different sizes I

Re: D2 map trouble

2010-07-28 Thread bearophile
Philippe Sigaud: > Is it on bugzilla? If not present you can add it here: http://d.puremagic.com/issues/show_bug.cgi?id=4264 Bye, bearophile

Re: struct opCall error messages

2010-07-28 Thread Rory Mcguire
Jacob Carlborg wrote: > On 2010-07-26 14:27, Rory Mcguire wrote: >> Hi, >> >> I'm not sure this is in bugzilla, I tried finding something mentioning it >> but coudn't. >> >> Compiling the below code results in the dmd compiler printing: >> struct_bad_error.d(8): Error: 'this' is only defined in no

SIGSEGV in rt_finalize

2010-07-28 Thread Rory Mcguire
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]=='-') { line ~= lines[0]; lines = lines[1..$]; }+/ An

Re: D2 map trouble

2010-07-28 Thread Philippe Sigaud
On Wed, Jul 28, 2010 at 16:51, Pelle wrote: > This is a compiler bug. Easy workaround: > > auto fn = (char a) { ... }; > str = map!fn(str); > Is it on bugzilla? Philippe

Re: D2 map trouble

2010-07-28 Thread Pelle
On 07/28/2010 12:57 AM, Nick Sabalausky wrote: Trying to convert some D1 code to D2: On 2.047, I'm trying to do this: import std.string; void foo(string str) { str = std.algorithm.map!( (char a) { return inPattern(a, [digits, letters])? a : '_'; } )(str); } And I'm getting: delegate

Re: D2 map trouble

2010-07-28 Thread Philippe Sigaud
On Wed, Jul 28, 2010 at 01:06, Nick Sabalausky wrote: > "Nick Sabalausky" wrote in message > news:i2no7g$eu...@digitalmars.com... > > Trying to convert some D1 code to D2: > > > > On 2.047, I'm trying to do this: > > > > import std.string; > > void foo(string str) > > { > > str = > > std.algori

Re: D1->D2 member call syntax regression?

2010-07-28 Thread bearophile
Nick Sabalausky: > That's because my original example accidentally made Foo an uninstantiated > class template, so the compiler never bothered to check the semantics... Surely here there is no shortage of ways I can paint myself as a stupid :-) In Python the () after the class name are optional a