Re: Dub hanging for a long time

2015-02-07 Thread Suliman via Digitalmars-d-learn
I do not use antivirus. It's floated error. I can't reproduce it. But sometime it's appears again.

Re: Issue with template function

2015-02-07 Thread Charles via Digitalmars-d-learn
On Friday, 6 February 2015 at 17:40:31 UTC, ketmar wrote: On Fri, 06 Feb 2015 17:09:28 +, Charles wrote: readString(toBytes!string(test),0,4).writeln; if you'll take a look into druntime sources, you'll find that string is just an alias to `immutable(char)[]`. so you actually

Re: Dub hanging for a long time

2015-02-07 Thread Rikki Cattermole via Digitalmars-d-learn
On 7/02/2015 8:55 p.m., Suliman wrote: Several times I encounter problem when DUB is hanging for a long time It's look like that when I tun DUB from folder of current project it's do not show me nothing, just move cursor on next line for a long time.

Dub hanging for a long time

2015-02-07 Thread Suliman via Digitalmars-d-learn
Several times I encounter problem when DUB is hanging for a long time It's look like that when I tun DUB from folder of current project it's do not show me nothing, just move cursor on next line for a long time. http://img.ctrlv.in/img/15/02/07/54d5c37f6d3c3.png running dub from any other

Using reduce with user types

2015-02-07 Thread Kadir Erdem Demir via Digitalmars-d-learn
I can use filter algorithm with my types easily. struct A { string value; int count; } void main( string[] args ) { A[] aArr; aArr ~= A(HTTP, 3); aArr ~= A(HTTPS, 2); aArr ~= A(UNKNOWN_TCP, 4); aArr.filter!( a = a.count == 2); But I

static alias this

2015-02-07 Thread Mike via Digitalmars-d-learn
Consider this simple example A)- struct StaticRegister { static private uint _value; @property static uint value() { return _value; } @property static void value(uint v) { _value = v; } } void main(string[] s) { StaticRegister = 1;

Re: strange work of GC

2015-02-07 Thread Andrey Derzhavin via Digitalmars-d-learn
If a destroy method is used together with GC inside of my app,it makes my app unstable. In this case I need to choose how to destroy my objects: 1) always manually by method destroy, but without GC; 2) or always automatically by GC, but without using the destroy method. In the first case I

Re: Issue with template function

2015-02-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 6 February 2015 at 17:09:29 UTC, Charles wrote: I'm trying to create a template function that can take in any type of array and convert it to a ubyte array. I'm not concerned with endianness at the moment, but I ran into a roadblock when trying to do this with strings. It already

Re: strange work of GC

2015-02-07 Thread FG via Digitalmars-d-learn
On 2015-02-07 at 12:02, Andrey Derzhavin wrote: If a destroy method is used together with GC inside of my app,it makes my app unstable. In this case I need to choose how to destroy my objects: 1) always manually by method destroy, but without GC; 2) or always automatically by GC, but without

Re: Learning to XML with D

2015-02-07 Thread Arjan via Digitalmars-d-learn
On Friday, 6 February 2015 at 09:15:54 UTC, Derix wrote: So, I set sails to transform a bunch of HTML files with D. This, of course, will happen with the std.xml library. There is this nice example : http://dlang.org/phobos/std_xml.html#.DocumentParser that I put to some use already, however

Re: Using reduce with user types

2015-02-07 Thread Rikki Cattermole via Digitalmars-d-learn
On 8/02/2015 1:47 a.m., Kadir Erdem Demir wrote: I can use filter algorithm with my types easily. struct A { string value; int count; } void main( string[] args ) { A[] aArr; aArr ~= A(HTTP, 3); aArr ~= A(HTTPS, 2); aArr ~= A(UNKNOWN_TCP, 4);

Re: Using reduce with user types

2015-02-07 Thread FG via Digitalmars-d-learn
On 2015-02-07 at 13:47, Kadir Erdem Demir wrote: auto sum = aArr.reduce!((a,b) = a.count + b.count); The line above gives C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(770): Error: cannot implicitly convert expression (__lambda3(result, front(_param_1))) of type int to A

Re: static alias this

2015-02-07 Thread jkpl via Digitalmars-d-learn
Another try E)--- struct StaticRegister { static private uint _value; @property static uint value() { return _value; } @property static void value(uint v) { _value = v; } static uint opCall(){return _value;} alias _value this; } void

Re: Using reduce with user types

2015-02-07 Thread Kadir Erdem Demir via Digitalmars-d-learn
auto sum = aArr.map!`a.count`.reduce!((a,b) = a + b); Rikki Thanks a lot. It works. Function map!a.count(aArr) surprises me a little. Because when I read std.algorithm reference: `Implements the homonym function (also known as transform)`. Which reminds me C++ transform and it will never

internal compiler error with immutable

2015-02-07 Thread Danny via Digitalmars-d-learn
Hi, I'm trying to use immutable class instances and that seems to be really difficult. For example, with the following program I get an internal compiler error: cut- import std.outbuffer : OutBuffer; import std.typecons :

Re: signal handling

2015-02-07 Thread rlonstein via Digitalmars-d-learn
On Friday, 6 February 2015 at 19:40:44 UTC, Danny wrote: Hi, if I want to clean up inside a signal handler and then exit the process (as it would have without me handling it), what do I do? Can I exit() inside a signal handler or should I use a more direct quit now function? (after all, it

Re: signal handling

2015-02-07 Thread Danny via Digitalmars-d-learn
Hi rlonstein, I've now read up on the opengroup pages about signal handling (which references POSIX), and apparently it goes like this: A signal can be delivered to a specific thread or to a process. If it's delivered to a process, a random thread of that process will receive it. If it's

Re: internal compiler error with immutable

2015-02-07 Thread Danny via Digitalmars-d-learn
Hi, I've filed it with gdcproject.org before reading your reply. Will it be forwarded to issues.dlang.org or should I file it there as well? Also, it seems there's a new DMD release underway right now, does it still happen with that? (I tried but can't get it to build - doesn't seem to

Fun with floating point

2015-02-07 Thread Kenny via Digitalmars-d-learn
Hi, D community! I have this program: import std.stdio; import std.conv; int main(string[] argv) { float eps = 1.0f; float f = 0.0f; while (f + eps != f) f += 1.0f; writeln(eps = ~ to!string(eps) ~ , max_f = ~ to!string(f)); return 0; } According to

Re: Fun with floating point

2015-02-07 Thread Kenny via Digitalmars-d-learn
And sory for the typos, cannot find edit functionality here..

Re: Using reduce with user types

2015-02-07 Thread Meta via Digitalmars-d-learn
On Saturday, 7 February 2015 at 13:38:00 UTC, Kadir Erdem Demir wrote: How can I imagine what map does in my mind, because it doesn't matches with the transform concept in my mind? You can think of map as taking a range of something (in this case, an array of A), and calling a user-supplied

Re: internal compiler error with immutable

2015-02-07 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Feb 07, 2015 at 02:35:13PM +, Danny via Digitalmars-d-learn wrote: [...] cut- gdc A.d cc1d: ../../src/gcc/d/dfrontend/statement.c:293: ErrorStatement::ErrorStatement(): Assertion `global.gaggedErrors || global.errors'

Re: strange work of GC

2015-02-07 Thread Andrey Derzhavin via Digitalmars-d-learn
Why do you want to use destroy? The destroy method always calls a dtor of the objects, where I can destroy some object's variables in that order that I need, I think. And this is very good for me, because I have a full control of the object's destroying stage. But if I use the GC, I have no

Re: Issue with template function

2015-02-07 Thread Charles via Digitalmars-d-learn
On Saturday, 7 February 2015 at 12:04:12 UTC, Nicholas Wilson wrote: Are you wanting to to convert each element in arr to a byte thus truncating and losing data (when T.sizeof != 1)? as in toBytes([1,2,3, 42, 500 /*this will be truncated to 244 */]);// T == int here or are you wanting to

Re: Better native D 2D graphics library?

2015-02-07 Thread Gan via Digitalmars-d-learn
On Saturday, 7 February 2015 at 23:29:01 UTC, Namespace wrote: On Saturday, 7 February 2015 at 22:09:03 UTC, Gan wrote: Is there a better D graphics library in the works? I'm using SFML(which is very easy and has lots of features) but it seems to use a lot of ram(if you leave it running for a

Re: Fun with floating point

2015-02-07 Thread Peter Alexander via Digitalmars-d-learn
On Saturday, 7 February 2015 at 21:33:51 UTC, Kenny wrote: The above code snippet works correctly when I use LDC compiler (it finds expected 'f' value and prints it to console). I'm wondering is it a bug in DMD? p.s. the final code used by both compilers: import std.stdio; import std.conv;

Re: Fun with floating point

2015-02-07 Thread Peter Alexander via Digitalmars-d-learn
On Saturday, 7 February 2015 at 23:06:15 UTC, anonymous wrote: On Saturday, 7 February 2015 at 22:46:56 UTC, Ali Çehreli wrote: 1.0 is famously not representable exactly. 1.0 is representable exactly, though. I think he meant 0.1 :-)

Re: Better native D 2D graphics library?

2015-02-07 Thread Namespace via Digitalmars-d-learn
On Saturday, 7 February 2015 at 22:09:03 UTC, Gan wrote: Is there a better D graphics library in the works? I'm using SFML(which is very easy and has lots of features) but it seems to use a lot of ram(if you leave it running for a while on a graphic intensive scene) and trying to make it

Re: Fun with floating point

2015-02-07 Thread Ali Çehreli via Digitalmars-d-learn
On 02/07/2015 01:33 PM, Kenny wrote: The above code snippet works correctly when I use LDC compiler (it finds expected 'f' value and prints it to console). I'm wondering is it a bug in DMD? p.s. the final code used by both compilers: import std.stdio; import std.conv; int main(string[] argv)

Re: Problem with simple Formatted Input example.

2015-02-07 Thread Venkat Akkineni via Digitalmars-d-learn
On Sunday, 8 February 2015 at 00:47:46 UTC, Ali Çehreli wrote: On 02/07/2015 04:42 PM, Ali Çehreli wrote: readf(%s\n, firstName); I see that readf reads the first line of entry *after* I press two Enters on the console. OK, that is related to the '\n' character that you have in

Re: Fun with floating point

2015-02-07 Thread Ali Çehreli via Digitalmars-d-learn
To answer your other question, there is no Edit because this is a newsgroup (see NNTP). The forum interface is supposed to be a convenience but it hides that fact. On 02/07/2015 01:33 PM, Kenny wrote: The above code snippet works correctly There is no right or wrong when you compare

Re: Fun with floating point

2015-02-07 Thread Meta via Digitalmars-d-learn
On Saturday, 7 February 2015 at 16:06:14 UTC, Kenny wrote: Hi, D community! I have this program: import std.stdio; import std.conv; int main(string[] argv) { float eps = 1.0f; float f = 0.0f; while (f + eps != f) f += 1.0f; writeln(eps = ~ to!string(eps) ~

Re: How to write asia characters on console?

2015-02-07 Thread Ali Çehreli via Digitalmars-d-learn
On 02/07/2015 09:57 PM, Lave Zhang wrote: Hi, My first D program is like this: --- import std.stdio; void main(string[] args) { dstring s1 = hello你好d; writeln(s1); } --- But the output is not correct(and my console

Better native D 2D graphics library?

2015-02-07 Thread Gan via Digitalmars-d-learn
Is there a better D graphics library in the works? I'm using SFML(which is very easy and has lots of features) but it seems to use a lot of ram(if you leave it running for a while on a graphic intensive scene) and trying to make it include the dependencies with the compiled executable is

Re: Fun with floating point

2015-02-07 Thread anonymous via Digitalmars-d-learn
On Saturday, 7 February 2015 at 22:46:56 UTC, Ali Çehreli wrote: 1.0 is famously not representable exactly. 1.0 is representable exactly, though.

Re: strange work of GC

2015-02-07 Thread Mike Parker via Digitalmars-d-learn
On 2/8/2015 4:32 AM, Andrey Derzhavin wrote: Why do you want to use destroy? The destroy method always calls a dtor of the objects, where I can destroy some object's variables in that order that I need, I think. And this is very good for me, because I have a full control of the object's

Re: static alias this

2015-02-07 Thread Ali Çehreli via Digitalmars-d-learn
On 02/07/2015 04:46 AM, Mike wrote: B)- struct StaticRegister { static private uint _value; @property static uint value() { return _value; } @property static void value(uint v) { _value = v; } alias value this; } void

Re: Issue with template function

2015-02-07 Thread Nicholas Wilson via Digitalmars-d-learn
The original code I was using was written in Java, and only had a method for strings. This is closer to what I wanted. My unit tests were just going back and forth with readString function, so I was completely missing this for other types. Nice catch! There were a couple issues with your

Re: How to write asia characters on console?

2015-02-07 Thread weaselcat via Digitalmars-d-learn
On Sunday, 8 February 2015 at 05:57:31 UTC, Lave Zhang wrote: Hi, My first D program is like this: --- import std.stdio; void main(string[] args) { dstring s1 = hello你好d; writeln(s1); } --- But the output is not

Re: Problem with simple Formatted Input example.

2015-02-07 Thread Ali Çehreli via Digitalmars-d-learn
On 02/07/2015 04:29 PM, Venkat Akkineni wrote: This simple program seems to just hang. I am probably missing something. Any help is appreciated. I am using Linux with DMD. Program compiles fine, but when enter a string press enter, the programs seems to wait forever without returning.

How to write asia characters on console?

2015-02-07 Thread Lave Zhang via Digitalmars-d-learn
Hi, My first D program is like this: --- import std.stdio; void main(string[] args) { dstring s1 = hello你好d; writeln(s1); } --- But the output is not correct(and my console codepage is 936): C:\D\dmd2\samples\ddmd hello.d

How to write asia characters on console?

2015-02-07 Thread Lave Zhang via Digitalmars-d-learn
Hi, My first D program is like this: --- import std.stdio; void main(string[] args) { dstring s1 = hello你好d; writeln(s1); } --- But the output is not correct(and my console codepage is 936): C:\D\dmd2\samples\ddmd

Problem with simple Formatted Input example.

2015-02-07 Thread Venkat Akkineni via Digitalmars-d-learn
This simple program seems to just hang. I am probably missing something. Any help is appreciated. I am using Linux with DMD. Program compiles fine, but when enter a string press enter, the programs seems to wait forever without returning. import std.stdio; void main() {

Re: strange work of GC

2015-02-07 Thread FG via Digitalmars-d-learn
On 2015-02-08 at 01:20, Mike Parker wrote: In your case, forget destructors and the destroy method. Just implement a common method on all of your objects that need cleanup (perhaps name it 'terminate') and call that. This gives you the deterministic destruction that you want (the same as

Re: Better native D 2D graphics library?

2015-02-07 Thread weaselcat via Digitalmars-d-learn
On Saturday, 7 February 2015 at 22:09:03 UTC, Gan wrote: Is there a better D graphics library in the works? I'm using SFML(which is very easy and has lots of features) but it seems to use a lot of ram(if you leave it running for a while on a graphic intensive scene) and trying to make it

Re: Problem with simple Formatted Input example.

2015-02-07 Thread Ali Çehreli via Digitalmars-d-learn
On 02/07/2015 04:42 PM, Ali Çehreli wrote: readf(%s\n, firstName); I see that readf reads the first line of entry *after* I press two Enters on the console. OK, that is related to the '\n' character that you have in the format string. Also, repeating the space characters has no

Re: strange work of GC

2015-02-07 Thread Mike Parker via Digitalmars-d-learn
On 2/8/2015 11:32 AM, FG wrote: On 2015-02-08 at 01:20, Mike Parker wrote: In your case, forget destructors and the destroy method. Just implement a common method on all of your objects that need cleanup (perhaps name it 'terminate') and call that. This gives you the deterministic destruction