Re: How to pack types with variables in one message to send it to another thread? [tuple]

2014-09-07 Thread hane via Digitalmars-d-learn
On Sunday, 7 September 2014 at 10:42:37 UTC, MarisaLovesUsAll wrote: Hi! I'm trying to make my program multithreaded, and I was stuck at messaging between threads. I need to pack types and variables into one message. Will I use Tuples or something? e.g. class Sprite {}; send(tid, Sprite,

Re: writeln() assertion failed in hybrid x64

2014-09-05 Thread hane via Digitalmars-d-learn
On Thursday, 4 September 2014 at 15:10:22 UTC, Jorge A. S. wrote: I'm having an error related to yours: when I call writeln function in a closed stdout I will get a segfault message. Example: import std.stdio; void main() { stdout.close(); write(hello\n); } The code above will crash

Re: writeln() assertion failed in hybrid x64

2014-09-05 Thread hane via Digitalmars-d-learn
On Friday, 5 September 2014 at 07:22:23 UTC, hane wrote: On Thursday, 4 September 2014 at 15:10:22 UTC, Jorge A. S. wrote: I'm having an error related to yours: when I call writeln function in a closed stdout I will get a segfault message. Example: import std.stdio; void main() {

Re: Cross-module inlining with separate compilation?

2014-08-25 Thread hane via Digitalmars-d-learn
On Tuesday, 26 August 2014 at 04:34:39 UTC, ketmar via Digitalmars-d-learn wrote: On Mon, 25 Aug 2014 21:07:06 + ponce via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Is there a way to have cross-module inlining but with separate compilation? Like with link-time

Re: 'idiomatic' porting of c and or c++ code that does NULL checking

2014-08-23 Thread hane via Digitalmars-d-learn
On Saturday, 23 August 2014 at 10:19:59 UTC, nikki wrote: I am learning SDL by following the lazyfoo SDL2 tuorials, I am alos new to D so I have a question: I the lazyfoo tutorials there are many functions that have a bool success whiich gets set at various places when something goes wrong

Re: How to realize isSortedRange?

2014-08-20 Thread hane via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 07:18:12 UTC, Kagamin wrote: http://dlang.org/phobos/std_traits.html#TemplateOf Or isInstanceOf. static if (__traits(isSame, TemplateOf!R, SortedRange)) static if (isInstanceOf!(SortedRange, R))

Re: delegates GC allocations

2014-08-20 Thread hane via Digitalmars-d-learn
On Wednesday, 20 August 2014 at 14:44:39 UTC, Etienne wrote: I've been hearing that delegates get a context pointer which will be allocated on the GC. Is this also true for delegates which stay in scope? e.g. void addThree() { int val; void addOne() { val++;

Re: Member access of __gshared global object

2014-08-06 Thread hane via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 04:14:51 UTC, Puming wrote: 1. The only way that I can initialize it is to assign a value. But I want to initialize an empty AA, is that possible? workaround: string[string] aa; assert(aa is null); aa[] = ; aa.remove(); assert(aa !is null);

Re: extern (C++, N) is it implemented?

2014-08-06 Thread hane via Digitalmars-d-learn
On Wednesday, 6 August 2014 at 06:50:59 UTC, Alexandr Druzhinin wrote: This dlang.org/cpp_interface.html says I can do the following // c++ namespace N { void someCppFunction(); } // d extern (C++, N) void someCppFunction(); but this http://dpaste.dzfl.pl/e2242263e1dc says I can't Is

Re: [dmd 2.066] Is scope with nothrow regression?

2014-07-06 Thread hane via Digitalmars-d-learn
On Sunday, 6 July 2014 at 12:31:42 UTC, NCrashed wrote: ``` void bar() { throw new Exception(); } void foo() nothrow { scope(failure) {} bar(); } void main() {} ``` Doesn't compile with 2.066: ``` source/app.d(9): Error: 'app.bar' is not nothrow source/app.d(6): Error:

Re: [dmd 2.066] Is scope with nothrow regression?

2014-07-06 Thread hane via Digitalmars-d-learn
On Sunday, 6 July 2014 at 22:03:21 UTC, hane wrote: On Sunday, 6 July 2014 at 12:31:42 UTC, NCrashed wrote: ``` void bar() { throw new Exception(); } void foo() nothrow { scope(failure) {} bar(); } void main() {} ``` Doesn't compile with 2.066: ``` source/app.d(9):

Re: Why does this work?

2014-06-23 Thread hane via Digitalmars-d-learn
On Monday, 23 June 2014 at 08:30:44 UTC, h_zet wrote: import std.typecons; auto foo2(R)(R foopara){ return tuple(foopara, is(R==int)); } void main(){ auto tuple(a,b) = foo2(1); } I'm expecting some error such as can not act as left value but when I compiled this, no error occured.

Re: Create const regex?

2014-06-07 Thread hane via Digitalmars-d-learn
On Saturday, 7 June 2014 at 11:33:35 UTC, Meta wrote: On Saturday, 7 June 2014 at 00:48:59 UTC, hane wrote: On Friday, 6 June 2014 at 15:42:41 UTC, Meta wrote: You should not do this, as it will create a new regex everywhere you use it. Unlike const or immutable, enum in this situation is

Re: Create const regex?

2014-06-06 Thread hane via Digitalmars-d-learn
On Friday, 6 June 2014 at 12:01:55 UTC, AntonSotov wrote: const r1 = regex(bla); matchFirst( big string, r1 ); // ERROR! immutable r2 = regex(bla); // ERROR! Why can I not use const/immutable regex? I think it's a Phobos bug that can't use regex as immutable. You can use const regex with

Re: Create const regex?

2014-06-06 Thread hane via Digitalmars-d-learn
On Friday, 6 June 2014 at 15:42:41 UTC, Meta wrote: You should not do this, as it will create a new regex everywhere you use it. Unlike const or immutable, enum in this situation is more or less like a C macro. #define r1 regex(bla) I see. Thanks.

Re: Why std.algorithm.sort can't be applied to char[]?

2014-05-13 Thread hane via Digitalmars-d-learn
On Monday, 12 May 2014 at 14:56:46 UTC, John Colvin wrote: char[] is a rather special type of array: the language has unicode support and iterates over it by code-point (i.e. not guaranteed to be a single char per iteration). If you want to sort chars and are assuming ASCII, you can just use

Why std.algorithm.sort can't be applied to char[]?

2014-05-12 Thread hane via Digitalmars-d-learn
and is there any way to sort char array with algorithm.sort? --- import std.algorithm; import std.range; void main() { int[] arr = [5, 3, 7]; sort(arr); // OK char[] arr2 = ['z', 'g', 'c']; sort(arr2); // error sort!q{ a[0] b[0] }(zip(arr, arr2)); // error } --- I don't know what's

Re: AES encryption with openssl bindings

2014-04-26 Thread hane via Digitalmars-d-learn
AES_set_decrypt_key is needed before AES_decrypt. AES_set_decrypt_key(chunk.ptr, 128, wctx);