Re: Using in as a parameter qualifier

2013-05-30 Thread Ali Çehreli
On 05/30/2013 10:36 PM, Shriramana Sharma wrote: > struct pair { It is more common to start type names with a capital letter: Pair. >double x,y ; >this () {} That is not allowed. In D, every type has the .init property, which is its default value. >this (double x, double y) { th

Re: Why do i have to add to the counter when using for loop to perfectly get result?

2013-05-30 Thread estew
Well, after a quick glance at the code you're iterating N times but only printing N-1 times. When counter == peak the loop does nothing so you'd get something like: chosen=5 for(int counter = 0; counter < chosen ; ++counter){ // note +1 removed } counter = 0, 1, 2, [3]NO_PRINT, 4 *0 ***1

Using in as a parameter qualifier

2013-05-30 Thread Shriramana Sharma
Hello people. I have a pair type defined as : struct pair { double x,y ; this () {} this (double x, double y) { this.x = x ; this.y = y ; } } Consider a function that operates on a pair: double abs2 ( pair a ) { return a.x * a.x + a.y * a.y ; } In C++ the function signature would be: dou

Why do i have to add to the counter when using for loop to perfectly get result?

2013-05-30 Thread Tori
/* licenced under the wtfpl license :D... as if i even understand how to license*/ import std.stdio; void main(){ //yeah... im making a diamond pattern out off asterisks writeln("Pick a number that is odd"); int chosen; bool oddnoteven = false; while(o

Re: Exception isn't thrown as expected

2013-05-30 Thread Alexandr Druzhinin
31.05.2013 10:49, Marco Leise пишет: The code that you haven't shown reads: int main(string[] args) { SomeClass c; auto t = c.getObjectType(); return 0; } You have to fix that! You mean I didn't initialize c? If even so, it should throw an exception, no hanging, I

Re: Exception isn't thrown as expected

2013-05-30 Thread Marco Leise
Am Fri, 31 May 2013 10:26:49 +0700 schrieb Alexandr Druzhinin : > 31.05.2013 8:59, Adam D. Ruppe пишет: > > three questions come to mind: > > > > 1) what operating system and 32 bit or 64 bit? > > 2) what D compiler? > > 3) are you sure you didn't catch the exception somewhere up the chain > > and

Re: double vs real

2013-05-30 Thread Marco Leise
Am Fri, 31 May 2013 07:02:11 +0530 schrieb Shriramana Sharma : > Thanks to all who replied. > > On Thu, May 30, 2013 at 10:07 PM, Diggory wrote: > > > > Since D does all operations at highest possible precision anyway (even for > > double or float) it only makes a difference when the value is be

Re: Duplicating multidimensional array

2013-05-30 Thread Ali Çehreli
On 05/30/2013 04:48 PM, Ali Çehreli wrote: > For classes, there is no syntax for copying. The type may have annotated > a member function that it is the duplication function or we may know by > convention that dup() is the equivalent of array .dup. Kenji Hara responded to another thread on the m

Re: Exception isn't thrown as expected

2013-05-30 Thread Alexandr Druzhinin
31.05.2013 8:59, Adam D. Ruppe пишет: three questions come to mind: 1) what operating system and 32 bit or 64 bit? 2) what D compiler? 3) are you sure you didn't catch the exception somewhere up the chain and silence the message that way? 1) win7 64 2) dmd 32 3) I don't catch explicitly. To ens

Re: Exception isn't thrown as expected

2013-05-30 Thread Adam D. Ruppe
three questions come to mind: 1) what operating system and 32 bit or 64 bit? 2) what D compiler? 3) are you sure you didn't catch the exception somewhere up the chain and silence the message that way?

Re: and/or/not/xor operators

2013-05-30 Thread bearophile
Ali Çehreli: I don't have a preference on the topic but it would still be incomplete, right? There are many other operators that don't have keywords. Beside the && || ! I think it's much better to not replace the other operators with keywords. Perhaps that's why not many people use them.

Re: and/or/not/xor operators

2013-05-30 Thread bearophile
Shriramana Sharma: Um why really? "No one uses them in C++"? How come? I agree that Walter has succesfully produced/marketed a C++ compiler for a long time, but really, "no one uses"?!!! I use, for one. And it does tremendously increase the readability of a program. Otherwise why would there

Exception isn't thrown as expected

2013-05-30 Thread Alexandr Druzhinin
Hello I have code like this: class SomeClass { ubyte[] data_; ... auto getObjectType() const { if(data_ is null) { writeln("throwing"); throw new Exception("Here the exception should be thrown!"); } KeyHeaderHelper value_header;

Re: and/or/not/xor operators

2013-05-30 Thread Ali Çehreli
On 05/30/2013 06:41 PM, Shriramana Sharma wrote: > "no one uses"?!!! I use, for one. Are there others in the team? Without getting into the argument of whether they are useful, you are the first person that I know who uses them. :) I have been programming in C since 1988 and in C++ since 1997

Re: and/or/not/xor operators

2013-05-30 Thread Shriramana Sharma
Thanks to all who replied. On Thu, May 30, 2013 at 10:18 PM, bearophile wrote: > > But Walter refused them time ago on the basis that no one uses them in C++. > So you can ask for them in the main D newsgroup, but I don't think you will > see them in D... Um why really? "No one uses them in C++"

Re: double vs real

2013-05-30 Thread Shriramana Sharma
Thanks to all who replied. On Thu, May 30, 2013 at 10:07 PM, Diggory wrote: > > Since D does all operations at highest possible precision anyway (even for > double or float) it only makes a difference when the value is being stored > to memory and then read back again. But isn't this true for ev

Re: Duplicating multidimensional array

2013-05-30 Thread Joseph Rushton Wakeling
On 05/31/2013 01:48 AM, Ali Çehreli wrote: > Copying structs is trivial because they already have copy semantics: > > T b = a; // b is a copy of a > > However, that depends on correctly implemented copy semantics on T. By "complex structs" I meant things like structs containing arrays -- a

Re: My first D program

2013-05-30 Thread Shriramana Sharma
Thanks to all those who kindly replied. On Thu, May 30, 2013 at 9:57 PM, Regan Heath wrote: > > The D standard library is currently statically linked. This will change > shortly/eventually. Ah OK -- should have thought of that. So whatever is in libc.so or libstdc++.so doesn't get counted to th

Re: Duplicating multidimensional array

2013-05-30 Thread Ali Çehreli
On 05/30/2013 03:02 PM, Joseph Rushton Wakeling wrote: > I would never have thought of that trick with the second template parameter. Phobos is a source of ideas. ;) > I guess it might fall over with complex structs or classes, though. :-\ Copying structs is trivial because they already have

Re: double vs real

2013-05-30 Thread Joseph Rushton Wakeling
On 05/30/2013 06:45 PM, bearophile wrote: > Regarding speed in theory double and real > should give the same, but in practice theory and practice often differ. In my experience, using real slows things down, though the degree depends on use-case (mine involves lots of iterations and calculations o

Re: double vs real

2013-05-30 Thread Marco Leise
Am Thu, 30 May 2013 17:47:14 +0530 schrieb Shriramana Sharma : > Hello. I like that D exposes to me the real type to maximally utilize > the machine's numerical precision. Since I am writing a program > (currently in C++ but I am thinking of moving to D) that has to handle > lots of fractional num

Re: Duplicating multidimensional array

2013-05-30 Thread Joseph Rushton Wakeling
On 05/30/2013 09:36 AM, Ali Çehreli wrote: > What do you think about the following recursive template solution? I have > tested > it only with arrays of int. :/ Very impressed -- I would never have thought of that trick with the second template parameter. It's really nice to see these kinds of e

Re: Automatic attribute inference of functions

2013-05-30 Thread Steven Schveighoffer
On Thu, 30 May 2013 16:24:35 -0400, Sebastian Graf wrote: Hi, I wonder if there are any plans to allow automatic inference of function attributes. I think it's a big hassle having to pollute function declarations with things like @safe, nothrow, pure, etc. let alone rembering them all.

Automatic attribute inference of functions

2013-05-30 Thread Sebastian Graf
Hi, I wonder if there are any plans to allow automatic inference of function attributes. I think it's a big hassle having to pollute function declarations with things like @safe, nothrow, pure, etc. let alone rembering them all. I know this is done for anonymous functions on a best effort bas

Re: how to pipe contents of a D string to a std.process.Pipe (without resorting to any escaping)

2013-05-30 Thread Steven Schveighoffer
On Thu, 30 May 2013 14:40:21 -0400, Timothee Cour wrote: I want to pipe the contents of a D string to the stdin of a pipe created with one of the std.process functions. I want to avoiding resorting to escaping the string. How would i do that? Thanks use rawWrite -Steve

Re: Consume an entire range

2013-05-30 Thread bearophile
Brad Anderson: Have any links? http://d.puremagic.com/issues/show_bug.cgi?id=9674 Is forEach real? It's just an idea. Bye, bearophile

Re: and/or/not/xor operators

2013-05-30 Thread John Colvin
On Thursday, 30 May 2013 at 16:18:44 UTC, Shriramana Sharma wrote: Hello. I have always loved the readability of C++'s and/or/not/xor word-like logical operators but It doesn't seem to be available in D. Isn't this possible in D? I tried doing: alias && and ; import std.stdio ; void main () {

how to pipe contents of a D string to a std.process.Pipe (without resorting to any escaping)

2013-05-30 Thread Timothee Cour
I want to pipe the contents of a D string to the stdin of a pipe created with one of the std.process functions. I want to avoiding resorting to escaping the string. How would i do that? Thanks

Re: Consume an entire range

2013-05-30 Thread Jonathan M Davis
On Thursday, May 30, 2013 19:58:45 Brad Anderson wrote: > Is forEach real? I sought it out because it'd be a better fit > but came up empty (it's not in std.range or std.algorithm). No. The normal thing would be to just use an actual foreach loop. - Jonathan M Davis

Re: and/or/not/xor operators

2013-05-30 Thread ixid
On Thursday, 30 May 2013 at 16:30:12 UTC, Iain Buclaw wrote: On Thursday, 30 May 2013 at 16:18:44 UTC, Shriramana Sharma wrote: Hello. I have always loved the readability of C++'s and/or/not/xor word-like logical operators but It doesn't seem to be available in D. Isn't this possible in D? I t

Re: Consume an entire range

2013-05-30 Thread Brad Anderson
On Thursday, 30 May 2013 at 11:38:58 UTC, bearophile wrote: Brad Anderson: import std.stdio, std.algorithm, std.array; void eat(R)(R r) { while(!r.empty) { r.front; r.popFront; } } void main() { size_t[dstring] dic; stdin.byLine .joiner(" ") .array .splitt

Re: My first D program

2013-05-30 Thread bearophile
Shriramana Sharma: However I am somewhat taken aback to see the file size -- 335KiB for a simple Hello World? The equivalent C/C++ programs compiled with Clang without any -O options produce binaries of less than 10K! On Windows32 DMD produces binaries for small programs that are often half

Re: and/or/not/xor operators

2013-05-30 Thread bearophile
Shriramana Sharma: Hello. I have always loved the readability of C++'s and/or/not/xor word-like logical operators but It doesn't seem to be available in D. and/or/not are less visually noisy, they look better than the ugly &&/||/! of C/C++/D, and it's much less easy to write & when you need

Re: double vs real

2013-05-30 Thread bearophile
Shriramana Sharma: Hello. I like that D exposes to me the real type to maximally utilize the machine's numerical precision. Since I am writing a program (currently in C++ but I am thinking of moving to D) that has to handle lots of fractional numbers (calculating offset curves and such) I am

Re: and/or/not/xor operators

2013-05-30 Thread Simen Kjaeraas
On 2013-05-30, 13:56, Shriramana Sharma wrote: Hello. I have always loved the readability of C++'s and/or/not/xor word-like logical operators but It doesn't seem to be available in D. Isn't this possible in D? I tried doing: alias && and ; import std.stdio ; void main () { writeln ( tru

Re: double vs real

2013-05-30 Thread Diggory
On Thursday, 30 May 2013 at 16:18:44 UTC, Shriramana Sharma wrote: Hello. I like that D exposes to me the real type to maximally utilize the machine's numerical precision. Since I am writing a program (currently in C++ but I am thinking of moving to D) that has to handle lots of fractional numb

Re: regex with literal (ie automatically replace '(' with '\(', etc) )

2013-05-30 Thread Diggory
Your suggestion does not work; try for yourself by replacing the $$ by \$ in my code. Is that a bug in std.regex' doc? eg: replace("",regex(``),`\$`); => invalid format string in regex replace However everything works fine with $$, see my code above. Either the doc or the code should probably

Re: regex with literal (ie automatically replace '(' with '\(', etc) )

2013-05-30 Thread Dmitry Olshansky
30-May-2013 10:49, Timothee Cour пишет: ok, here it is: https://github.com/timotheecour/dtools/blob/master/dtools/util/util.d#L78 simplified implementation and added missing escape symbols. Any symbol missing? I was basing myself based on http://dlang.org/phobos/std_regex.html, table entry '\c w

Re: and/or/not/xor operators

2013-05-30 Thread Iain Buclaw
On Thursday, 30 May 2013 at 16:18:44 UTC, Shriramana Sharma wrote: Hello. I have always loved the readability of C++'s and/or/not/xor word-like logical operators but It doesn't seem to be available in D. Isn't this possible in D? I tried doing: No, it isn't available... Thank goodness! :)

Re: My first D program

2013-05-30 Thread Regan Heath
On Thu, 30 May 2013 12:13:19 +0100, Shriramana Sharma wrote: Hello. I am new to D and come from some intermediate C/C++ plus some Python programming background. I currently have DMD 2.062 installed on my Kubuntu Raring 64-bit system. 1. Too big binary output? OK so I wrote my first Hello Wo

Re: regex with literal (ie automatically replace '(' with '\(', etc) )

2013-05-30 Thread Dmitry Olshansky
30-May-2013 14:24, Timothee Cour пишет: > According to this: http://dlang.org/phobos/std___regex.html#.replace you can use the same escape sequences for both (\c -> c in the replacement string). Your suggestion does not work; try for yourself by

My first D program

2013-05-30 Thread Shriramana Sharma
Hello. I am new to D and come from some intermediate C/C++ plus some Python programming background. I currently have DMD 2.062 installed on my Kubuntu Raring 64-bit system. 1. Too big binary output? OK so I wrote my first Hello World program: #! /usr/bin/rdmd import std.stdio ; void main() {

and/or/not/xor operators

2013-05-30 Thread Shriramana Sharma
Hello. I have always loved the readability of C++'s and/or/not/xor word-like logical operators but It doesn't seem to be available in D. Isn't this possible in D? I tried doing: alias && and ; import std.stdio ; void main () { writeln ( true and true ) ; } but I get errors: $ dmd foo.d f

double vs real

2013-05-30 Thread Shriramana Sharma
Hello. I like that D exposes to me the real type to maximally utilize the machine's numerical precision. Since I am writing a program (currently in C++ but I am thinking of moving to D) that has to handle lots of fractional numbers (calculating offset curves and such) I am wondering whether/when I

Re: Consume an entire range

2013-05-30 Thread bearophile
Brad Anderson: import std.stdio, std.algorithm, std.array; void eat(R)(R r) { while(!r.empty) { r.front; r.popFront; } } void main() { size_t[dstring] dic; stdin.byLine .joiner(" ") .array .splitter(' ') .filter!(w => !w.empty && w !in dic)

Re: regex with literal (ie automatically replace '(' with '\(', etc) )

2013-05-30 Thread Timothee Cour
> According to this: > http://dlang.org/phobos/std_**regex.html#.replace > you can use the same escape sequences for both (\c -> c in the replacement string). Your suggestion does not work; try for yourself by replacing the $$ by \$ in my code. Is

Re: irrelevant compiler error messages: should stop semantic3 passes after 1st error is encountered

2013-05-30 Thread Timothee Cour
ping. I've posted a bugzilla entry http://d.puremagic.com/issues/show_bug.cgi?id=10177 and finally managed to reduce to a small test case. So will the proposed method improve error reporting? Is there any case where it might hurt? On Mon, May 20, 2013 at 3:24 PM, Timothee Cour wrote: > In a num

Re: Put/watch/play/run dvd movie video to iPad 3

2013-05-30 Thread Raphaël Jakse
Is it written in D ? Where is the Linux version ? 35$ for a stripped down dvd::rip ? Are you kidding ? Keep your ads for you please, you'll lose at this game here. "camcorder" like "camelote" (junk in French ?) Le 30/05/2013 10:12, daisy520 a écrit : When you want to play the DVD movie on your

AnalyzeD

2013-05-30 Thread bioinfornatics
hi Someone know if AnalyzeD could to be used from command line ? i.e http://dconf.org/talks/rohe.html I failed to find AnalyzeD source code thanks

Re: regex with literal (ie automatically replace '(' with '\(', etc) )

2013-05-30 Thread Diggory
On Thursday, 30 May 2013 at 06:50:06 UTC, Timothee Cour wrote: ok, here it is: https://github.com/timotheecour/dtools/blob/master/dtools/util/util.d#L78 simplified implementation and added missing escape symbols. Any symbol missing? I was basing myself based on http://dlang.org/phobos/std_reg

Put/watch/play/run dvd movie video to iPad 3

2013-05-30 Thread daisy520
When you want to play the DVD movie on your beloved iPad 3, there will be a problem that there is no DVD drive in iPad 3. So where is a solution to help us playing DVD movie on iPad 3? iPad 3 supports 1080p mp4, so Aunsoft DVD to iPad 3 ripper can help you out on this matter to convert DVD to i

Re: Duplicating multidimensional array

2013-05-30 Thread Ali Çehreli
On 05/29/2013 10:22 AM, Joseph Rushton Wakeling wrote: > I've been having some trouble trying to work out how to effectively > duplicate a multidimensional array in a way that preserves type qualifiers. Templates preserve type qualifiers. So, as long as the return type is the same as the para