Re: scope exception do not rise

2014-11-05 Thread Suliman via Digitalmars-d-learn
Replace that with something like writeln("caught") and you will see that it is indeed caught. :) Printing the exception mimicks the default behavior and you (and I) think that the exception is not caught. :) that's work, but I can not understand where I can to look at exception level. If I ri

Re: Complexity guaranties of array append operator

2014-11-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 06, 2014 03:48:26 Dmitriy via Digitalmars-d-learn wrote: > Hello, I'm in the middle of learning D. I can't find any > definitive information about what is the complexity of operator > ~= when used for adding an element to an array. Is it amortized > O(1) or is it implementatio

Complexity guaranties of array append operator

2014-11-05 Thread Dmitriy via Digitalmars-d-learn
Hello, I'm in the middle of learning D. I can't find any definitive information about what is the complexity of operator ~= when used for adding an element to an array. Is it amortized O(1) or is it implementation defined? (I hope it at worst O(n) though I haven't seen any information about tha

Re: rndtonl

2014-11-05 Thread Laeeth Isharc via Digitalmars-d-learn
Thanks, Adam. Should we perhaps make a pull to suggest updating the docs/wiki? As the point below is not what one would infer from the dlang.org library reference page. (If I say we, it's because I don't know what the protocol is, or whether my perception is right). On Tuesday, 4 November

Re: druntime vararg implementation

2014-11-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 06, 2014 00:16:48 Mike via Digitalmars-d-learn wrote: > In that case, a better question is "Why use the standard C > implementation if we have working D code?". Less to maintain. Also, there's less risk of inconsistency with what C is doing. And it's low level stuff anyway wh

Re: druntime vararg implementation

2014-11-05 Thread Mike via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 14:24:00 UTC, Sean Kelly wrote: On Wednesday, 5 November 2014 at 09:45:50 UTC, Mike wrote: Greetings, In core.varar. (https://github.com/D-Programming-Language/druntime/blob/master/src/core/vararg.d), why is the X86 implementation singled out and written in D

Re: undefined reference to `_D5xxxx6yyyyy12__ModuleInfoZ'

2014-11-05 Thread bioinfornatics via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 23:53:57 UTC, Ali Çehreli wrote: On 11/05/2014 03:48 PM, bioinfornatics wrote: Dear, maybe I'm too tired to see my errors or they are a bug. See below I have this: . |-- fasta.d `-- src `-- nicea |-- metadata.d |-- parser.d `--

Re: undefined reference to `_D5xxxx6yyyyy12__ModuleInfoZ'

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn
On 11/05/2014 03:48 PM, bioinfornatics wrote: Dear, maybe I'm too tired to see my errors or they are a bug. See below I have this: . |-- fasta.d `-- src `-- nicea |-- metadata.d |-- parser.d `-- range.d when I try to build it: $ dmd -I./src/ ./fasta.d 2>&1

Re: undefined reference to `_D5xxxx6yyyyy12__ModuleInfoZ'

2014-11-05 Thread Justin Whear via Digitalmars-d-learn
On Wed, 05 Nov 2014 23:48:21 +, bioinfornatics wrote: > Dear, > > maybe I'm too tired to see my errors or they are a bug. See below > > I have this: > . > |-- fasta.d `-- src > `-- nicea > |-- metadata.d |-- parser.d `-- range.d > > when I try to build it: > > $ dmd -I./src

undefined reference to `_D5xxxx6yyyyy12__ModuleInfoZ'

2014-11-05 Thread bioinfornatics via Digitalmars-d-learn
Dear, maybe I'm too tired to see my errors or they are a bug. See below I have this: . |-- fasta.d `-- src `-- nicea |-- metadata.d |-- parser.d `-- range.d when I try to build it: $ dmd -I./src/ ./fasta.d 2>&1 fasta.o:(.rodata+0x1f8): undefined reference to `_

Re: UDA failling to build when using delegate

2014-11-05 Thread bioinfornatics via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 21:57:42 UTC, bioinfornatics wrote: On Tuesday, 4 November 2014 at 22:06:03 UTC, Ali Çehreli wrote: On 11/04/2014 01:58 PM, bioinfornatics wrote: >> test.d(40): Error: type Section!((letter) => letter == '>', >> (letter) => letter == '\x0a') has no value You ha

Re: UDA failling to build when using delegate

2014-11-05 Thread bioinfornatics via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 22:06:03 UTC, Ali Çehreli wrote: On 11/04/2014 01:58 PM, bioinfornatics wrote: >> test.d(40): Error: type Section!((letter) => letter == '>', >> (letter) => letter == '\x0a') has no value You have this line: @Section!(/* ... */) Although that is a type name,

Re: How to turn this C++ into D?

2014-11-05 Thread luminousone via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 20:31:54 UTC, Patrick Jeeves wrote: On Wednesday, 5 November 2014 at 19:44:57 UTC, luminousone wrote: On Wednesday, 5 November 2014 at 19:05:32 UTC, Patrick Jeeves wrote: On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone wrote: unless delete is explicit

Re: Curiously Cyclic Template Pattern causes segfault?

2014-11-05 Thread bearophile via Digitalmars-d-learn
Justin Whear: --any compiler crash is a bug regardless of whether the source is valid D code or not. I suspect that in some cases those compiler crashes are a way for the compiler to tell the programmer that the code was too much hairy and too much hard to understand ;-) Bye, bearophile

Re: Curiously Cyclic Template Pattern causes segfault?

2014-11-05 Thread Justin Whear via Digitalmars-d-learn
On Wed, 05 Nov 2014 20:48:06 +, Patrick Jeeves wrote: > When I tried to test out the following code the compiler segfaulted: > > Is there some rule against doing this or is it a glitch? Please file a bug report on issues.dlang.org --any compiler crash is a bug regardless of whether the sourc

Curiously Cyclic Template Pattern causes segfault?

2014-11-05 Thread Patrick Jeeves via Digitalmars-d-learn
When I tried to test out the following code the compiler segfaulted: interface BarBase { void do_a_thing(); } interface Bar(T) : BarBase { static if(hasMember!(T, "rotation") && is(typeof(T.rotation) == double)) { @property double rotation()

Re: How to turn this C++ into D?

2014-11-05 Thread Patrick Jeeves via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 19:44:57 UTC, luminousone wrote: On Wednesday, 5 November 2014 at 19:05:32 UTC, Patrick Jeeves wrote: On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone wrote: unless delete is explicitly called, I don't believe the destructor would ever be called, it wo

Re: accessing numeric template parameters

2014-11-05 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Monday, 3 November 2014 at 21:17:09 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: struct polynomial(uint base) { private: uint[] N; public: this(uint x) { base = x; } base is part of the type. polynomial is just a 'recipe' for a type, the real struct would be Polynomial!(0), Pol

Re: How to turn this C++ into D?

2014-11-05 Thread luminousone via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 19:05:32 UTC, Patrick Jeeves wrote: On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone wrote: unless delete is explicitly called, I don't believe the destructor would ever be called, it would still have a reference in the static foo_list object that woul

Re: How to turn this C++ into D?

2014-11-05 Thread Patrick Jeeves via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone wrote: unless delete is explicitly called, I don't believe the destructor would ever be called, it would still have a reference in the static foo_list object that would stop it from being collected by the gc. This is exactly why I ask

Re: How to turn this C++ into D?

2014-11-05 Thread luminousone via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 18:18:18 UTC, Ali Çehreli wrote: On 11/05/2014 10:12 AM, Adam D. Ruppe wrote: > On Wednesday, 5 November 2014 at 18:10:38 UTC, Ali Çehreli wrote: >> If so, then that push_back would be adding an incomplete object to the >> list. > > scope(success)? I really like

Re: cannot sort an array of char

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn
On 11/05/2014 10:01 AM, Ali Çehreli wrote: >>> sort (c.byCodeUnit); >>> } >>> >>> But IMO it should. >> >> https://issues.dlang.org/show_bug.cgi?id=13689 > > It can't be a RandomAccessRange because it cannot satisfy random access > at O(1) time. Sorry, I misunderstood (again): code u

Re: scope exception do not rise

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn
On 11/05/2014 06:01 AM, Suliman wrote: > I can't understand what I am missing. Try-catch block also do not handle > exception: I does. This turned out to be very tricky for me. :) > void main() > { > string fname = "app.d1"; //file name with error > string current_folder = (getcwd() ~

Re: How to turn this C++ into D?

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn
On 11/05/2014 10:12 AM, Adam D. Ruppe wrote: > On Wednesday, 5 November 2014 at 18:10:38 UTC, Ali Çehreli wrote: >> If so, then that push_back would be adding an incomplete object to the >> list. > > scope(success)? I really like that! :) But still not for this case because in addition to the p

Re: How to turn this C++ into D?

2014-11-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 18:10:38 UTC, Ali Çehreli wrote: If so, then that push_back would be adding an incomplete object to the list. scope(success)? But the D translation worries me too because the destructor won't run at the same time as the C++ version, unless you make it a scop

Re: How to turn this C++ into D?

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn
On 11/05/2014 10:07 AM, Ali Çehreli wrote: > On 11/05/2014 09:17 AM, Patrick Jeeves wrote: > > > class foo > > { > > static std::list foo_list; > > typedef std::list::iterator iterator; > > public: > > foo() > > { > > foo_list.push_back(this); > > } Argh! I forgot

Re: How to turn this C++ into D?

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn
On 11/05/2014 09:17 AM, Patrick Jeeves wrote: > class foo > { > static std::list foo_list; > typedef std::list::iterator iterator; > public: > foo() > { > foo_list.push_back(this); > } > ~foo() > { > foo_list.remove(this); > } Going completely off-to

Re: cannot sort an array of char

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn
On 11/05/2014 05:44 AM, "Marc Schütz" " wrote: On Wednesday, 5 November 2014 at 13:34:05 UTC, Marc Schütz wrote: On Wednesday, 5 November 2014 at 12:54:03 UTC, Ivan Kazmenko wrote: Hi! This gives an error (cannot deduce template function from argument types): - import std.algorithm; void

Re: How to turn this C++ into D?

2014-11-05 Thread luminousone via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 17:17:11 UTC, Patrick Jeeves wrote: So this is more a stackoverflow question, but I feel like later searchers will be more likely to find it if I put it here. if I have the following C++ code: class foo { static std::list foo_list; typedef std::list::iterator i

How to turn this C++ into D?

2014-11-05 Thread Patrick Jeeves via Digitalmars-d-learn
So this is more a stackoverflow question, but I feel like later searchers will be more likely to find it if I put it here. if I have the following C++ code: class foo { static std::list foo_list; typedef std::list::iterator iterator; public: foo() { foo_list.push_back(this);

Re: scope exception do not rise

2014-11-05 Thread Suliman via Digitalmars-d-learn
Am I right understand that keyword "Exception" is handle universal type of exceptions? catch (Exception) { writeln("inner"); } But in my example with try block can I change it's to something more informative?

Re: druntime vararg implementation

2014-11-05 Thread Sean Kelly via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 09:45:50 UTC, Mike wrote: Greetings, In core.varar. (https://github.com/D-Programming-Language/druntime/blob/master/src/core/vararg.d), why is the X86 implementation singled out and written in D rather than leveraging the standard c library implementation lik

Re: scope exception do not rise

2014-11-05 Thread ketmar via Digitalmars-d-learn
On Wed, 05 Nov 2014 14:09:20 + Gary Willoughby via Digitalmars-d-learn wrote: > That shouldn't matter. See: http://dlang.org/exception-safe.html this indeed matter. and it should. signature.asc Description: PGP signature

Re: Access Violation Tracking

2014-11-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 11:31:01 UTC, bearophile wrote: This was discussed some times, and Walter is against this, but I think he is wrong, and eventually things will change. An access violation already thrown on Win32. Just catch a Throwable in main and write out exception.toString.

Re: scope exception do not rise

2014-11-05 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 14:04:26 UTC, MadProgressor wrote: The scope(failure) is translated to a try catch after the satement you wann monitor. So put it before That shouldn't matter. See: http://dlang.org/exception-safe.html

Re: scope exception do not rise

2014-11-05 Thread MadProgressor via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 12:56:41 UTC, Suliman wrote: void openFile(string fname, string current_folder) { auto file = readText(current_folder ~ fname); scope(failure) { writeln("failure"); } // writeln(file); } if file name do not e

Re: scope exception do not rise

2014-11-05 Thread Suliman via Digitalmars-d-learn
I can't understand what I am missing. Try-catch block also do not handle exception: void main() { string fname = "app.d1"; //file name with error string current_folder = (getcwd() ~"\\"); writeln(current_folder); openFile(fname, current_folder); } void openFile(s

Re: cannot sort an array of char

2014-11-05 Thread via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 13:34:05 UTC, Marc Schütz wrote: On Wednesday, 5 November 2014 at 12:54:03 UTC, Ivan Kazmenko wrote: Hi! This gives an error (cannot deduce template function from argument types): - import std.algorithm; void main () { char [] c; sort (c);

Re: cannot sort an array of char

2014-11-05 Thread via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 12:54:03 UTC, Ivan Kazmenko wrote: Hi! This gives an error (cannot deduce template function from argument types): - import std.algorithm; void main () { char [] c; sort (c); } - Why is "char []" so special that it can't be sorted? For

scope exception do not rise

2014-11-05 Thread Suliman via Digitalmars-d-learn
void openFile(string fname, string current_folder) { auto file = readText(current_folder ~ fname); scope(failure) { writeln("failure"); } // writeln(file); } if file name do not exists, I want to rise scope exception. But it's do not rise, a

cannot sort an array of char

2014-11-05 Thread Ivan Kazmenko via Digitalmars-d-learn
Hi! This gives an error (cannot deduce template function from argument types): - import std.algorithm; void main () { char [] c; sort (c); } - Why is "char []" so special that it can't be sorted? For example, if I know the array contains only ASCII characters, sortin

Re: Access Violation Tracking

2014-11-05 Thread Bauss via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 11:27:02 UTC, thedeemon wrote: On Wednesday, 5 November 2014 at 11:09:42 UTC, Bauss wrote: Is there any way to track down access violations, instead of me having to look through my source code manually. I have a pretty big source code and an access violation h

Re: Access Violation Tracking

2014-11-05 Thread Bauss via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 11:39:21 UTC, Marc Schütz wrote: On Wednesday, 5 November 2014 at 11:09:42 UTC, Bauss wrote: Is there any way to track down access violations, instead of me having to look through my source code manually. I have a pretty big source code and an access violation

Re: Access Violation Tracking

2014-11-05 Thread via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 11:09:42 UTC, Bauss wrote: Is there any way to track down access violations, instead of me having to look through my source code manually. I have a pretty big source code and an access violation happens at runtime, but it's going to be a nightmare looking throu

Re: Access Violation Tracking

2014-11-05 Thread bearophile via Digitalmars-d-learn
Bauss: Is there any way to track down access violations, instead of me having to look through my source code manually. I have a pretty big source code and an access violation happens at runtime, but it's going to be a nightmare looking through it all to find the access violation. Not to ment

Re: Access Violation Tracking

2014-11-05 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 11:09:42 UTC, Bauss wrote: Is there any way to track down access violations, instead of me having to look through my source code manually. I have a pretty big source code and an access violation happens at runtime, but it's going to be a nightmare looking throu

Access Violation Tracking

2014-11-05 Thread Bauss via Digitalmars-d-learn
Is there any way to track down access violations, instead of me having to look through my source code manually. I have a pretty big source code and an access violation happens at runtime, but it's going to be a nightmare looking through it all to find the access violation. Not to mention all t

druntime vararg implementation

2014-11-05 Thread Mike via Digitalmars-d-learn
Greetings, In core.varar. (https://github.com/D-Programming-Language/druntime/blob/master/src/core/vararg.d), why is the X86 implementation singled out and written in D rather than leveraging the standard c library implementation like the others? Mike

Re: [SDL + TKD] Seg fault from creating DirectoryDialog

2014-11-05 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 23:09:33 UTC, Jack wrote: So there must be an incompatibility with the video subsystem and tcl/tk. So it seems. Thank you very much for helping me. You were a big help. Sorry i can't do more. I'm the author of Tkd and would like to get to the bottom of it.