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

2014-11-04 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 3 November 2014 at 22:26:14 UTC, Jack wrote: I'll try and think about this for a while Thanks for the help sir. No worries. I don't really know what else to suggest without seeing a little code. Do you have a simple full program that shows the error happening?

Re: Templates for structures

2014-11-04 Thread novice2 via Digitalmars-d-learn
On Monday, 3 November 2014 at 14:53:29 UTC, Ali Çehreli wrote: It sounds possible but I don't understand it yet. Can you give an example of the input and output to the D code? Ali Thank you Ali. I realized, that my wishes look like serialization. So i decide read and learn code from existent

Re: Struct template

2014-11-04 Thread Meta via Digitalmars-d-learn
On Monday, 3 November 2014 at 17:05:21 UTC, John Colvin wrote: static if (is(typeof(T) == int)) should be static if (is(T == int)) T is already a type. I thought this was supposed to produce an error message rather than fail silently... I'm positive this used to be an error. Did it

isRangeOf ?

2014-11-04 Thread bearophile via Digitalmars-d-learn
Sometimes I have a function that needs an iterable: void foo(Range)(Range data) if (isForwardRange!Range is(Unqual!(ForeachType!Range) == int)) {} So is it a good idea to add a isRangeOf template to Phobos? void foo(Range)(Range data) if (isRangeOf!(Range, int)) {} Bye, bearophile

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

2014-11-04 Thread Jack via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 08:30:34 UTC, Gary Willoughby wrote: On Monday, 3 November 2014 at 22:26:14 UTC, Jack wrote: I'll try and think about this for a while Thanks for the help sir. No worries. I don't really know what else to suggest without seeing a little code. Do you have a

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

2014-11-04 Thread Mike Parker via Digitalmars-d-learn
On 11/4/2014 7:34 PM, Jack wrote: On Tuesday, 4 November 2014 at 08:30:34 UTC, Gary Willoughby Here's the main file: http://codepad.org/hu4r0ExB and Here's the module: http://codepad.org/ikXAzfdg Dependencies are DerelictSDL and Tkd. It's the most simple one I got that reproduces the

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Kagamin via Digitalmars-d-learn
https://issues.dlang.org/show_bug.cgi?id=12990 this?

Re: manually call opUnary

2014-11-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 04, 2014 07:19:03 Algo via Digitalmars-d-learn wrote: Is it possible? As in { int a; a.opUnary!++(); } no property 'opUnary' for type 'int' opUnary only exists when it's been declared on a user-defined type. The way to use it generically is to use the

Re: isRangeOf ?

2014-11-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 04, 2014 09:40:58 bearophile via Digitalmars-d-learn wrote: Sometimes I have a function that needs an iterable: void foo(Range)(Range data) if (isForwardRange!Range is(Unqual!(ForeachType!Range) == int)) {} So is it a good idea to add a isRangeOf template to Phobos?

Re: isRangeOf ?

2014-11-04 Thread bearophile via Digitalmars-d-learn
Jonathan M Davis: That loses the ability to test which type of range you're talking about. Yes, one can think about templates like isForwardRangeOf, etc. But for such specialized cases I think using isForwardRange+is(ElementType) is acceptable and avoids adding too many templates to

Re: Pointer across threads

2014-11-04 Thread Chris via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 12:47:11 UTC, Chris wrote: The following struct DATA { short* data; size_t len; } // data and len are provided by a C function // ... auto data = mymodule.getSpeechData(); // cast to immutable, because of concurrency immutable short* tmp =

Pointer across threads

2014-11-04 Thread Chris via Digitalmars-d-learn
The following struct DATA { short* data; size_t len; } // data and len are provided by a C function // ... auto data = mymodule.getSpeechData(); // cast to immutable, because of concurrency immutable short* tmp = cast(immutable)(data.data); auto proc = spawn(processData, thisTid);

Re: Reading unicode string with readf (%s)

2014-11-04 Thread anonymous via Digitalmars-d-learn
On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: Hi! The following code does not correctly handle Unicode strings. - import std.stdio; void main () { string s; readf (%s, s); write (s); } - Example input (Test. in cyrillic): - Тест. -

Re: Pointer across threads

2014-11-04 Thread anonymous via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 12:47:11 UTC, Chris wrote: The following struct DATA { short* data; size_t len; } // data and len are provided by a C function // ... auto data = mymodule.getSpeechData(); // cast to immutable, because of concurrency immutable short* tmp =

Re: Pointer across threads

2014-11-04 Thread Chris via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 14:01:16 UTC, anonymous wrote: On Tuesday, 4 November 2014 at 12:47:11 UTC, Chris wrote: The following struct DATA { short* data; size_t len; } // data and len are provided by a C function // ... auto data = mymodule.getSpeechData(); // cast to immutable,

Re: Pointer across threads

2014-11-04 Thread Chris via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 14:36:19 UTC, Chris wrote: On Tuesday, 4 November 2014 at 14:01:16 UTC, anonymous wrote: On Tuesday, 4 November 2014 at 12:47:11 UTC, Chris wrote: The following struct DATA { short* data; size_t len; } // data and len are provided by a C function // ... auto

Re: Pointer across threads

2014-11-04 Thread anonymous via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 14:36:19 UTC, Chris wrote: I'm still curious, though, how D handles this internally, because data.data is still mutable while the other reference to the same address (tmp) is not. What if I change data.data while the other thread is being executed? Changing

Re: Pointer across threads

2014-11-04 Thread Chris via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 14:47:49 UTC, anonymous wrote: On Tuesday, 4 November 2014 at 14:36:19 UTC, Chris wrote: I'm still curious, though, how D handles this internally, because data.data is still mutable while the other reference to the same address (tmp) is not. What if I change

Re: Pointer across threads

2014-11-04 Thread thedeemon via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 14:36:19 UTC, Chris wrote: I'm still curious, though, how D handles this internally, because data.data is still mutable while the other reference to the same address (tmp) is not. What if I change data.data while the other thread is being executed? immutable is

Re: Pointer across threads

2014-11-04 Thread Chris via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 16:07:11 UTC, thedeemon wrote: On Tuesday, 4 November 2014 at 14:36:19 UTC, Chris wrote: I'm still curious, though, how D handles this internally, because data.data is still mutable while the other reference to the same address (tmp) is not. What if I change

Re: Pointer across threads

2014-11-04 Thread Dicebot via Digitalmars-d-learn
There is assumeUnique which effectively does cast to immutable but is more clear to the reader in a sense why breaking type system was considered legit. I recommend using it over raw cast.

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 3 November 2014 at 20:03:03 UTC, Ali Çehreli wrote: On 11/03/2014 11:47 AM, Ivan Kazmenko wrote: On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: readf (%s, s); Worth noting: this reads to end-of-file (not end-of-line or whitespace), and reading the whole file

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Monday, 3 November 2014 at 20:10:02 UTC, Gary Willoughby wrote: On Monday, 3 November 2014 at 19:47:17 UTC, Ivan Kazmenko wrote: So, if there is an idiomatic way to read the whole file into a string which is Unicode-compatible, it would be great to learn that, too. Maybe something like

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 11:46:24 UTC, Kagamin wrote: https://issues.dlang.org/show_bug.cgi?id=12990 this? Similar, but not quite that. Bugs 12990 and 1448 (linked from there) seem to have Windows console as an important part of the process. For me, the example does not work even

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

2014-11-04 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 10:34:19 UTC, Jack wrote: No worries. I don't really know what else to suggest without seeing a little code. Do you have a simple full program that shows the error happening? Here's the main file: http://codepad.org/hu4r0ExB and Here's the module:

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 13:01:48 UTC, anonymous wrote: On Monday, 3 November 2014 at 19:37:20 UTC, Ivan Kazmenko wrote: Hi! The following code does not correctly handle Unicode strings. - import std.stdio; void main () { string s; readf (%s, s); write (s); }

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

2014-11-04 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 18:22:49 UTC, Gary Willoughby wrote: On Tuesday, 4 November 2014 at 10:34:19 UTC, Jack wrote: No worries. I don't really know what else to suggest without seeing a little code. Do you have a simple full program that shows the error happening? Here's the main

rndtonl

2014-11-04 Thread Laeeth Isharc via Digitalmars-d-learn
what am I doing wrong here? import std.math; import std.stdio; void main() { real fac; fac=1.2; fac=rndtonl(fac); } [root@fedorabox util]# dmd bug.d bug.o: In function `_Dmain': bug.d:(.text._Dmain+0x3b): undefined reference to `rndtonl' collect2: error: ld returned 1

Re: Reading unicode string with readf (%s)

2014-11-04 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 18:09:48 UTC, Ivan Kazmenko wrote: On Monday, 3 November 2014 at 20:10:02 UTC, Gary Willoughby wrote: On Monday, 3 November 2014 at 19:47:17 UTC, Ivan Kazmenko wrote: So, if there is an idiomatic way to read the whole file into a string which is

Re: rndtonl

2014-11-04 Thread Adam D. Ruppe via Digitalmars-d-learn
I think rndtonl is a C library function that isn't always present in the system. It doesn't work on my computer either and I can't find any documentation about it. It is probably not meant to be called by end users.

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

2014-11-04 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 10:34:19 UTC, Jack wrote: Here's the main file: http://codepad.org/hu4r0ExB and Here's the module: http://codepad.org/ikXAzfdg Dependencies are DerelictSDL and Tkd. It's the most simple one I got that reproduces the error. If you change the way SDL is

The interface's 'in' contract passes if it makes a virtual function call

2014-11-04 Thread Ali Çehreli via Digitalmars-d-learn
Perhaps I am expecting too much from the current 'in' contract design and implementation. ;) Still, the virtual function call in the following interface's 'in' contract should be dispatched to the implementaion in the derived class, right? It seems like mere presence of that virtual

Re: The interface's 'in' contract passes if it makes a virtual function call

2014-11-04 Thread bearophile via Digitalmars-d-learn
Ali Çehreli: Perhaps I am expecting too much from the current 'in' contract design and implementation. ;) The in contract is named pre-condition, or precondition. Bye, bearophile

Efficient file search and extract

2014-11-04 Thread Sativa via Digitalmars-d-learn
Is there a very easy way to search a file for a string, then extract to a new file everything from that match on to the end of the file? I basically want to remove a header from a file(it's length is not fixed though). It seems I'm having to convert bytes to chars to strings and back and

Re: The interface's 'in' contract passes if it makes a virtual function call

2014-11-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/4/14 3:01 PM, Ali Çehreli wrote: Perhaps I am expecting too much from the current 'in' contract design and implementation. ;) Still, the virtual function call in the following interface's 'in' contract should be dispatched to the implementaion in the derived class, right? It seems like

Re: The interface's 'in' contract passes if it makes a virtual function call

2014-11-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/4/14 3:26 PM, Steven Schveighoffer wrote: On 11/4/14 3:01 PM, Ali Çehreli wrote: Perhaps I am expecting too much from the current 'in' contract design and implementation. ;) Still, the virtual function call in the following interface's 'in' contract should be dispatched to the

Re: The interface's 'in' contract passes if it makes a virtual function call

2014-11-04 Thread Ali Çehreli via Digitalmars-d-learn
On 11/04/2014 12:41 PM, Steven Schveighoffer wrote: Yep. I debugged it. It's calling toHash instead. Yeah, you were spot on. :) I did a different experiment. I added a number of functions to the interface (before virtualCheck()) and implementations to the class: interface I { // ...

Re: Efficient file search and extract

2014-11-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 04, 2014 20:12:21 Sativa via Digitalmars-d-learn wrote: Is there a very easy way to search a file for a string, then extract to a new file everything from that match on to the end of the file? I basically want to remove a header from a file(it's length is not fixed

Re: UDA failling to build when using delegate

2014-11-04 Thread bioinfornatics via Digitalmars-d-learn
On Tuesday, 4 November 2014 at 00:32:52 UTC, bioinfornatics wrote: On Monday, 3 November 2014 at 23:53:53 UTC, bioinfornatics wrote: Dear, why this code fail to build http://dpaste.dzfl.pl/8ef3898b05d2 ? I try to have a structure which is used to fill information from a file. And I use

Re: UDA failling to build when using delegate

2014-11-04 Thread Ali Çehreli via Digitalmars-d-learn
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, there is a bug somewhere and sometimes you have to use a 'value' as a

Re: The interface's 'in' contract passes if it makes a virtual function call

2014-11-04 Thread Ali Çehreli via Digitalmars-d-learn
On 11/04/2014 12:26 PM, Steven Schveighoffer wrote: This looks like a dmd bug. Posted: https://issues.dlang.org/show_bug.cgi?id=13687 Ali