Unit tests and segfaults

2012-12-06 Thread Russel Winder
What is the right idiom for testing that a function call does segfault when you want it to? -- Russel. = Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.win...@ekiga.net 41 Buckmaster Roadm: +44 7770 465

Re: Unit tests and segfaults

2012-12-06 Thread Jonathan M Davis
On Thursday, December 06, 2012 09:02:29 Russel Winder wrote: What is the right idiom for testing that a function call does segfault when you want it to? Why would you _want_ a function to segfault? That's like asking how to write a function which tests that a computer is off after you pull the

Re: Unit tests and segfaults

2012-12-06 Thread Alex Rønne Petersen
On 06-12-2012 11:31, Jonathan M Davis wrote: On Thursday, December 06, 2012 09:02:29 Russel Winder wrote: What is the right idiom for testing that a function call does segfault when you want it to? Why would you _want_ a function to segfault? That's like asking how to write a function which

Re: C# implementation of Nullable (May)

2012-12-06 Thread bearophile
Jesse Phillips: It seems to be similar to that of std.typecons.Nullable with the following differences. Recently I've written something about Nullable: http://d.puremagic.com/issues/show_bug.cgi?id=9086 Bye, bearophile

More templated type argument inference

2012-12-06 Thread bearophile
Currently this code is not supported: void foo(T)(T x, T function(T) f) {} void main() { foo(1, (int a) = a * a); // OK foo(1, a = a * a); // Error } With the latest alpha compiler it gives: test.d(4): Error: template test.foo does not match any function template declaration.

Re: More templated type argument inference

2012-12-06 Thread Maxim Fomin
On Thursday, 6 December 2012 at 13:04:05 UTC, bearophile wrote: Currently this code is not supported: void foo(T)(T x, T function(T) f) {} void main() { foo(1, (int a) = a * a); // OK foo(1, a = a * a); // Error } With the latest alpha compiler it gives: test.d(4): Error:

Re: More templated type argument inference

2012-12-06 Thread bearophile
Maxim Fomin: The second is template lambda and templates have void type. What you suggest here? In D template functions become functions if they are passed where the D compiler can infer their full type. This is correct code: void foo(int function(int) f) {} void main() { foo(a = a *

Re: More templated type argument inference

2012-12-06 Thread Maxim Fomin
On Thursday, 6 December 2012 at 13:04:05 UTC, bearophile wrote: Currently this code is not supported: void foo(T)(T x, T function(T) f) {} void main() { foo(1, (int a) = a * a); // OK foo(1, a = a * a); // Error } I forgot there is int here, so T in lambda should be deduced as

error with reading file name

2012-12-06 Thread Suliman
I am trying to create simple app that would read user input and open file with such name, but every time when I run it's crash with error std.file.FileException@std\file.d(294): \1.txt import std.stdio; import std.string; import std.file; void main() { string getfilename() {

Re: MS ODBC encoding issue

2012-12-06 Thread Regan Heath
On Thu, 06 Dec 2012 01:26:32 -, Sam Hu samhudotsa...@gmail.com wrote: Known issues: Under console reading Access table recordsets works fine ,inserting a new record which contains only English characters works fine as well,but inserting new record which contains Chinese character will

Re: Appending immutable char implicit cast to int, bug or feature?

2012-12-06 Thread ixid
I don't know where that cast occurs but I wanted to state the obvious: Operator ~ is defined only for arrays. Would having it also work for individual units to make an array be a plausible enhancement request? It would seem like a natural use of the operator.

Re: More templated type argument inference

2012-12-06 Thread bearophile
Philippe Sigaud: Doesn't that mean you're asking the compiler to have a full unification engine? Your example is simple, but the general case is more complicated: I think the general case doesn't require a whole program type inference, just a local one. But maybe it's too much complex to

Re: error with reading file name

2012-12-06 Thread Ali Çehreli
On 12/06/2012 07:52 AM, Suliman wrote: I am trying to create simple app that would read user input and open file with such name, but every time when I run it's crash with error std.file.FileException@std\file.d(294): \1.txt import std.stdio; import std.string; import std.file; void main() {

Re: error with reading file name

2012-12-06 Thread bearophile
Suliman: I am trying to create simple app that would read user input and open file with such name, but every time when I run it's crash with error std.file.FileException@std\file.d(294): \1.txt Try to declutter your code as much as possible, then print the file name before trying to call

Re: error with reading file name

2012-12-06 Thread Suliman
I had put next try-catch block yo my code void readfile(string name) { try { auto filearray = read(name); writeln(name); writeln(filearray);

constructor is not callable using argument types ()

2012-12-06 Thread Suliman
I am learning D classes and I am getting error when I am try to make instance of class. erorr: C:\code\main.d(9): Error: constructor GetFileName.GetFileName.this (string name) is not callable using argument types () http://www.everfall.com/paste/id.php?xie09xz9upth

Re: constructor is not callable using argument types ()

2012-12-06 Thread Simen Kjaeraas
On 2012-12-06, 20:17, Suliman wrote: I am learning D classes and I am getting error when I am try to make instance of class. erorr: C:\code\main.d(9): Error: constructor GetFileName.GetFileName.this (string name) is not callable using argument types ()

Re: constructor is not callable using argument types ()

2012-12-06 Thread Suliman
Am I right that my variant of code would be valid for C#? How can I assign value to name in such manner?

Re: constructor is not callable using argument types ()

2012-12-06 Thread Suliman
When I should use keyword this? I dropped it from my class and now I can make instance of class without in sych way: auto file = new GetFileName(); file.name = test;

Re: Type polymorphism and type variance

2012-12-06 Thread Ali Çehreli
On 12/06/2012 12:08 PM, js.mdnq wrote: On Thursday, 6 December 2012 at 03:22:55 UTC, Ali Çehreli wrote: The following comment is relevant: /* Although this can be a polymorphic type, I am assuming that all of the edge * handlers will produce the same type of result. */ struct

Re: C# implementation of Nullable (May)

2012-12-06 Thread Michael
On Wednesday, 5 December 2012 at 00:10:30 UTC, Jesse Phillips wrote: This article goes over a Nullable/Optional/Maybe implementation for C#. http://twistedoakstudios.com/blog/Post1130_when-null-is-not-enough-an-option-type-for-c

Visual D - Solution with Static Lib and Console App.

2012-12-06 Thread Nekroze
Ok so I have the need to make a static library that will be reused in multiple future projects. My thinking was that in future solutions i can just add an existing project, my static library project, so it would grab it and just work. However i cannot seem to get it to work. I have a

Re: Visual D - Solution with Static Lib and Console App.

2012-12-06 Thread Rainer Schuetze
On 06.12.2012 22:03, Nekroze wrote: Ok so I have the need to make a static library that will be reused in multiple future projects. My thinking was that in future solutions i can just add an existing project, my static library project, so it would grab it and just work. However i cannot seem

Re: constructor is not callable using argument types ()

2012-12-06 Thread Simen Kjaeraas
On 2012-12-06, 20:48, Suliman wrote: When I should use keyword this? I dropped it from my class and now I can make instance of class without in sych way: auto file = new GetFileName(); file.name = test; Indeed. If you have not defined a constructor, the language defines one for you, which

Re: Visual D - Solution with Static Lib and Console App.

2012-12-06 Thread Nekroze
On Thursday, 6 December 2012 at 21:28:38 UTC, Rainer Schuetze wrote: On 06.12.2012 22:03, Nekroze wrote: Ok so I have the need to make a static library that will be reused in multiple future projects. My thinking was that in future solutions i can just add an existing project, my static

Re: Visual D - Solution with Static Lib and Console App.

2012-12-06 Thread Rainer Schuetze
On 06.12.2012 23:00, Nekroze wrote: On Thursday, 6 December 2012 at 21:28:38 UTC, Rainer Schuetze wrote: On 06.12.2012 22:03, Nekroze wrote: Ok so I have the need to make a static library that will be reused in multiple future projects. My thinking was that in future solutions i can just

Re: Visual D - Solution with Static Lib and Console App.

2012-12-06 Thread Nekroze
On Thursday, 6 December 2012 at 22:06:43 UTC, Rainer Schuetze wrote: On 06.12.2012 23:00, Nekroze wrote: On Thursday, 6 December 2012 at 21:28:38 UTC, Rainer Schuetze wrote: On 06.12.2012 22:03, Nekroze wrote: Ok so I have the need to make a static library that will be reused in multiple

Re: Visual D - Solution with Static Lib and Console App.

2012-12-06 Thread Rainer Schuetze
On 06.12.2012 23:14, Nekroze wrote: On Thursday, 6 December 2012 at 22:06:43 UTC, Rainer Schuetze wrote: On 06.12.2012 23:00, Nekroze wrote: On Thursday, 6 December 2012 at 21:28:38 UTC, Rainer Schuetze wrote: On 06.12.2012 22:03, Nekroze wrote: Ok so I have the need to make a static

Re: Visual D - Solution with Static Lib and Console App.

2012-12-06 Thread Nekroze
On Thursday, 6 December 2012 at 22:26:07 UTC, Rainer Schuetze wrote: On 06.12.2012 23:14, Nekroze wrote: On Thursday, 6 December 2012 at 22:06:43 UTC, Rainer Schuetze wrote: On 06.12.2012 23:00, Nekroze wrote: On Thursday, 6 December 2012 at 21:28:38 UTC, Rainer Schuetze wrote: On

Re: MS ODBC encoding issue

2012-12-06 Thread Sam Hu
On Thursday, 6 December 2012 at 16:44:01 UTC, Regan Heath wrote: On Thu, 06 Dec 2012 01:26:32 -, Sam Hu samhudotsa...@gmail.com wrote: Known issues: Under console reading Access table recordsets works fine ,inserting a new record which contains only English characters works fine as

Re: error with reading file name

2012-12-06 Thread ollie
On Thu, 06 Dec 2012 16:52:20 +0100, Suliman wrote: I am trying to create simple app that would read user input and open file with such name, but every time when I run it's crash with error std.file.FileException@std\file.d(294): \1.txt After a call to readln, the string returned has

Re: error with reading file name

2012-12-06 Thread Ali Çehreli
On 12/06/2012 10:39 PM, ollie wrote: On Thu, 06 Dec 2012 16:52:20 +0100, Suliman wrote: I am trying to create simple app that would read user input and open file with such name, but every time when I run it's crash with error std.file.FileException@std\file.d(294): \1.txt After a call to