Re: Declaring run time variables

2014-08-05 Thread splatterdash via Digitalmars-d-learn
On Monday, 4 August 2014 at 22:45:15 UTC, anonymous wrote: On Monday, 4 August 2014 at 22:18:24 UTC, splatterdash wrote: Indeed I do. I'm not sure which type I should use for the common base type, though. MyFileReader is a templated class, so using it plainly did not work. I also tried

Declaring run time variables

2014-08-04 Thread splatterdash via Digitalmars-d-learn
Hello everyone, I'm trying to write a command-line application that can detect whether the input file is gzipped or not. Sounds simple enough, but I can't seem to do it properly in D (this is my first foray to the language). After checking whether the file is gzipped or not, I try to

Re: Declaring run time variables

2014-08-04 Thread anonymous via Digitalmars-d-learn
On Monday, 4 August 2014 at 22:00:18 UTC, splatterdash wrote: ``` File f = File(input_file) // detect gzip ... if (isGzip) { auto fileIter = new MyFileReader!GzipIterator(f) } else { auto fileIter = new MyFileReader!NormalIterator(f) } foreach(string line; fileIter) { // do

Re: Declaring run time variables

2014-08-04 Thread splatterdash via Digitalmars-d-learn
On Monday, 4 August 2014 at 22:09:49 UTC, anonymous wrote: On Monday, 4 August 2014 at 22:00:18 UTC, splatterdash wrote: ``` File f = File(input_file) // detect gzip ... if (isGzip) { auto fileIter = new MyFileReader!GzipIterator(f) } else { auto fileIter = new

Re: Declaring run time variables

2014-08-04 Thread anonymous via Digitalmars-d-learn
On Monday, 4 August 2014 at 22:18:24 UTC, splatterdash wrote: Indeed I do. I'm not sure which type I should use for the common base type, though. MyFileReader is a templated class, so using it plainly did not work. I also tried `InputRange!string` to no avail despite `MyFileReader`