Re: D + Solaris

2015-02-05 Thread Suliman via Digitalmars-d-learn
ldc supports solaris/x86 "but druntime/Phobos support will most likely be lacking" what does it's mean? It is not fully work or what?

Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Andre Kostur via Digitalmars-d-learn
On 2015-02-05, 8:17 PM, Gan wrote: On Friday, 6 February 2015 at 01:36:17 UTC, Mike Parker wrote: On 2/6/2015 9:50 AM, Gan wrote: On Friday, 6 February 2015 at 00:35:12 UTC, Adam D. Ruppe wrote: On Friday, 6 February 2015 at 00:31:37 UTC, Gan wrote: Or am I misunderstanding the receive functi

Re: ubyte array to uint?

2015-02-05 Thread weaselcat via Digitalmars-d-learn
On Friday, 6 February 2015 at 05:18:45 UTC, Gan wrote: Is there a simple way of conversion? Something like: uint length = to!uint(buffer[0 .. 4]); Right now I have: uint length = *cast(uint*)buffer[0 .. 4].ptr; Which I'm not entirely sure is the correct way to do that. Hi, check out std.bitm

ubyte array to uint?

2015-02-05 Thread Gan via Digitalmars-d-learn
Is there a simple way of conversion? Something like: uint length = to!uint(buffer[0 .. 4]); Right now I have: uint length = *cast(uint*)buffer[0 .. 4].ptr; Which I'm not entirely sure is the correct way to do that.

Re: Wrong pointer calculation without casting on struct

2015-02-05 Thread Baz via Digitalmars-d-learn
On Friday, 6 February 2015 at 04:10:08 UTC, tcak wrote: On Friday, 6 February 2015 at 03:59:51 UTC, tcak wrote: I am on 64-bit Linux. I defined a struct that it 8 bytes in total. align(1) struct MessageBase{ align(1): ushort qc; ushort wc; ushort id; ushort cont

Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Gan via Digitalmars-d-learn
On Friday, 6 February 2015 at 01:36:17 UTC, Mike Parker wrote: On 2/6/2015 9:50 AM, Gan wrote: On Friday, 6 February 2015 at 00:35:12 UTC, Adam D. Ruppe wrote: On Friday, 6 February 2015 at 00:31:37 UTC, Gan wrote: Or am I misunderstanding the receive function? Does it send whole messages or

Re: Wrong pointer calculation without casting on struct

2015-02-05 Thread tcak via Digitalmars-d-learn
On Friday, 6 February 2015 at 03:59:51 UTC, tcak wrote: I am on 64-bit Linux. I defined a struct that it 8 bytes in total. align(1) struct MessageBase{ align(1): ushort qc; ushort wc; ushort id; ushort contentLength; void[0] content; } I defined a funct

Wrong pointer calculation without casting on struct

2015-02-05 Thread tcak via Digitalmars-d-learn
I am on 64-bit Linux. I defined a struct that it 8 bytes in total. align(1) struct MessageBase{ align(1): ushort qc; ushort wc; ushort id; ushort contentLength; void[0] content; } I defined a function in this struct that tries to set a pointer to "conte

Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Mike Parker via Digitalmars-d-learn
On 2/6/2015 9:50 AM, Gan wrote: On Friday, 6 February 2015 at 00:35:12 UTC, Adam D. Ruppe wrote: On Friday, 6 February 2015 at 00:31:37 UTC, Gan wrote: Or am I misunderstanding the receive function? Does it send whole messages or just message chunks? It sends as much as it can when you call i

Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 February 2015 at 00:50:43 UTC, Gan wrote: How can you distinguish between different packets that get sent? Won't they all be merged to a giant blob of data? Yeah, that's normal in TCP though, because it is a stream oriented protocol. You could add stuff to your data indicating me

Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Gan via Digitalmars-d-learn
On Friday, 6 February 2015 at 00:35:12 UTC, Adam D. Ruppe wrote: On Friday, 6 February 2015 at 00:31:37 UTC, Gan wrote: Or am I misunderstanding the receive function? Does it send whole messages or just message chunks? It sends as much as it can when you call it. So if there's only 12 bytes a

Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 February 2015 at 00:31:37 UTC, Gan wrote: Or am I misunderstanding the receive function? Does it send whole messages or just message chunks? It sends as much as it can when you call it. So if there's only 12 bytes available when you send it with a 4096 buffer, it will fill the fi

Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Gan via Digitalmars-d-learn
On Friday, 6 February 2015 at 00:28:00 UTC, Gan wrote: On Friday, 6 February 2015 at 00:24:54 UTC, Adam D. Ruppe wrote: On Friday, 6 February 2015 at 00:15:15 UTC, Gan wrote: ubyte[] buf = new ubyte[](0); This is your problem: receive fills a preexisting buffer, and you alloc

Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Gan via Digitalmars-d-learn
On Friday, 6 February 2015 at 00:24:54 UTC, Adam D. Ruppe wrote: On Friday, 6 February 2015 at 00:15:15 UTC, Gan wrote: ubyte[] buf = new ubyte[](0); This is your problem: receive fills a preexisting buffer, and you allocated zero bytes for it to fill, so it can't give you an

Re: Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 6 February 2015 at 00:15:15 UTC, Gan wrote: ubyte[] buf = new ubyte[](0); This is your problem: receive fills a preexisting buffer, and you allocated zero bytes for it to fill, so it can't give you anything. Give it a bigger buffer, I like to use 4096, and it will

Trying to make a TCP server, client connects and disconnects immediately

2015-02-05 Thread Gan via Digitalmars-d-learn
I managed to get the client to connect but immediately on the server side, this happens: long length = player.playerSocket.receive(buf); if (length == 0) { //No longer connected player.playerSocket.shutdown(SocketShutdown.BOTH); pla

Re: strange alias behavior

2015-02-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 05, 2015 23:08:13 Vlad Levenfeld via Digitalmars-d-learn wrote: > I'm expecting in this code http://dpaste.dzfl.pl/ee0d3cd31734 > either line 8 should not compile, or lines 12 and 14 should have > a totally different output. What's going on? It looks like alias b = that.obj

strange alias behavior

2015-02-05 Thread Vlad Levenfeld via Digitalmars-d-learn
I'm expecting in this code http://dpaste.dzfl.pl/ee0d3cd31734 either line 8 should not compile, or lines 12 and 14 should have a totally different output. What's going on?

Re: how can I get a reference of array?

2015-02-05 Thread Ali Çehreli via Digitalmars-d-learn
On 02/05/2015 01:49 AM, Christof Schardt wrote: "Ali Çehreli" schrieb im Newsbeitrag news:mav4a1$l3a$1...@digitalmars.com... On 02/04/2015 10:42 PM, zhmt wrote: The following article is very informative: http://dlang.org/d-array-article.html Nice and important article. But: How could I h

Re: Do you have a better way to remove element from a array?

2015-02-05 Thread FG via Digitalmars-d-learn
On 2015-02-05 at 17:25, bearophile wrote: It has to be a void function (or perhaps bettter it can return true/false if it has removed the item, so it becomes @nogc and nothrow). And it has to remove the first item equal to the given one. You can then add a second function that removes at a given

Re: What am I doing Wrong (OpenGL & SDL)

2015-02-05 Thread Entity325 via Digitalmars-d-learn
Aldacron and I have determined that I'm doing something weird with the imports between gl.d and gl3.d, the functions I'm trying to access are deprecated so the problem is less that they aren't loading and more that I can see them at all.

Re: Do you have a better way to remove element from a array?

2015-02-05 Thread bearophile via Digitalmars-d-learn
bachmeier: It seems your argument is that remove is poorly designed because it's not destructive. Or am I missing your argument? It has to be a void function (or perhaps bettter it can return true/false if it has removed the item, so it becomes @nogc and nothrow). And it has to remove the f

Re: Do you have a better way to remove element from a array?

2015-02-05 Thread bachmeier via Digitalmars-d-learn
On Thursday, 5 February 2015 at 14:09:10 UTC, bearophile wrote: Tobias Pankrath: Works as designed: http://dlang.org/phobos/std_algorithm.html#.remove Unfortunately it's one of the worst designed functions of Phobos: https://issues.dlang.org/show_bug.cgi?id=10959 Bye, bearophile It seems

Re: D + Solaris

2015-02-05 Thread John Colvin via Digitalmars-d-learn
On Thursday, 5 February 2015 at 14:51:58 UTC, suliman wrote: My next job will be related with prorgamming under Solaris. I dont know version but suppose it will be something pretty out of date. Once i had seen topic about D and Solaris, but i want to ask if D solaris version is ready for prod

D + Solaris

2015-02-05 Thread suliman via Digitalmars-d-learn
My next job will be related with prorgamming under Solaris. I dont know version but suppose it will be something pretty out of date. Once i had seen topic about D and Solaris, but i want to ask if D solaris version is ready for production or it is alpha? Does anybody have experience with it?

Re: Syntax for checking if an element exists in a list

2015-02-05 Thread Stéphane
On Thursday, 5 February 2015 at 13:31:21 UTC, Nicholas Wilson wrote: Note that D does NOT have default fall through. i.e. Yes, but I thought I read that we always had to explicitely specify one ending statement, as "goto", "continue"... or "break"; which, in many basic cases, means having t

Re: Syntax for checking if an element exists in a list

2015-02-05 Thread Stéphane
On Thursday, 5 February 2015 at 12:35:03 UTC, Tobias Pankrath wrote: import std.algorithm; if(options[1].canFind("foo", "bar", "baz")) This looks quite OK. Thank you, I did not know about that possibility.

Re: Do you have a better way to remove element from a array?

2015-02-05 Thread FrankLike via Digitalmars-d-learn
On Thursday, 5 February 2015 at 14:09:10 UTC, bearophile wrote: Yes,A.remove(item) or A.removeAt(index) They are better than now.

Re: Do you have a better way to remove element from a array?

2015-02-05 Thread FrankLike via Digitalmars-d-learn
On Thursday, 5 February 2015 at 14:09:10 UTC, bearophile wrote: Tobias Pankrath: Works as designed: http://dlang.org/phobos/std_algorithm.html#.remove Unfortunately it's one of the worst designed functions of Phobos: https://issues.dlang.org/show_bug.cgi?id=10959 Bye, bearophile Yes,A.re

Re: Syntax for checking if an element exists in a list

2015-02-05 Thread anonymous via Digitalmars-d-learn
On Thursday, 5 February 2015 at 13:31:21 UTC, Nicholas Wilson wrote: Note that D does NOT have default fall through. i.e. switch(myopt) { case "opt1", "opt2", "opt3": do_A(); break; case "opt4": do_B(); break; default: do_C(); } is equivalent

Re: Do you have a better way to remove element from a array?

2015-02-05 Thread bearophile via Digitalmars-d-learn
Tobias Pankrath: Works as designed: http://dlang.org/phobos/std_algorithm.html#.remove Unfortunately it's one of the worst designed functions of Phobos: https://issues.dlang.org/show_bug.cgi?id=10959 Bye, bearophile

Re: Do you have a better way to remove element from a array?

2015-02-05 Thread Tobias Pankrath via Digitalmars-d-learn
On Thursday, 5 February 2015 at 13:55:59 UTC, FrankLike wrote: On Thursday, 5 February 2015 at 13:29:30 UTC, Tobias Pankrath wrote: Works as designed: http://dlang.org/phobos/std_algorithm.html#.remove Thank you. aa = remove(aa,1);//ok but how to remove one item? such as aa.remove(2) ? I

Re: Do you have a better way to remove element from a array?

2015-02-05 Thread FrankLike via Digitalmars-d-learn
On Thursday, 5 February 2015 at 13:29:30 UTC, Tobias Pankrath wrote: Works as designed: http://dlang.org/phobos/std_algorithm.html#.remove Thank you. aa = remove(aa,1);//ok but how to remove one item? such as aa.remove(2) ?

Re: What am I doing Wrong (OpenGL & SDL)

2015-02-05 Thread Mike Parker via Digitalmars-d-learn
On 2/5/2015 4:53 PM, Entity325 wrote: On Thursday, 5 February 2015 at 07:23:15 UTC, drug wrote: Look at this https://github.com/drug007/geoviewer/blob/master/src/sdlapp.d I used here SDL and OpenGL and it worked. Ctor of SDLApp creates SDL window with OpenGL context, may be it helps. Tested yo

Re: Syntax for checking if an element exists in a list

2015-02-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 5 February 2015 at 13:31:21 UTC, Nicholas Wilson wrote: On Thursday, 5 February 2015 at 12:31:31 UTC, Stéphane wrote: Syntax for checking if an element exists in a list Hello, I would like to know if there is a better (easier to wite, easier to read, easier to understand) way to

Re: how can I get a reference of array?

2015-02-05 Thread FG via Digitalmars-d-learn
On 2015-02-05 at 09:58, bearophile wrote: zhmt: Will arr.ptr change in the future? As the array add more members , it need more memroy, then remalloc may be called, the pointer maybe change, then the stored pointer will be invalid. Will this happen? Yes, it can happen. Therefore, don't u

Re: Syntax for checking if an element exists in a list

2015-02-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 5 February 2015 at 12:31:31 UTC, Stéphane wrote: Syntax for checking if an element exists in a list Hello, I would like to know if there is a better (easier to wite, easier to read, easier to understand) way to check if an element (string) is in a list of strings. Here are t

Do you have a better way to remove element from a array?

2015-02-05 Thread FrankLike via Digitalmars-d-learn
Now I can remove element from a array: module removeOne; import std.stdio; import std.array; import std.algorithm; void main() { int[] aa =[1,2,3,4,5]; aa = aa[0..2] ~aa[3..$]; writeln(aa); //ok remove(aa,1); writeln(aa);//get error result } You

Re: Do you have a better way to remove element from a array?

2015-02-05 Thread Tobias Pankrath via Digitalmars-d-learn
On Thursday, 5 February 2015 at 13:25:37 UTC, FrankLike wrote: Now I can remove element from a array: module removeOne; import std.stdio; import std.array; import std.algorithm; void main() { int[] aa =[1,2,3,4,5]; aa = aa[0..2] ~aa[3..$]; writeln(aa); //ok

Re: Syntax for checking if an element exists in a list

2015-02-05 Thread Tobias Pankrath via Digitalmars-d-learn
import std.algorithm; int main(string[] options) { // true if the first option given to this program is either foo, bar, or baz. if(options[1].canFind("foo", "bar", "baz")) return 0; return 1; }

Syntax for checking if an element exists in a list

2015-02-05 Thread Stéphane
Syntax for checking if an element exists in a list Hello, I would like to know if there is a better (easier to wite, easier to read, easier to understand) way to check if an element (string) is in a list of strings. Here are the possibilities I see today, as someone who is new to D: 1) u

Re: how can I get a reference of array?

2015-02-05 Thread zhmt via Digitalmars-d-learn
On Thursday, 5 February 2015 at 10:12:47 UTC, wrote: On Thursday, 5 February 2015 at 06:58:09 UTC, Ali Çehreli wrote: On 02/04/2015 10:42 PM, zhmt wrote: Here is a simple code snippet: With this approach, the allocation of `arr` itself is often clumsy and error-prone. In this case it is imp

Re: how can I get a reference of array?

2015-02-05 Thread Jakob Ovrum via Digitalmars-d-learn
On Thursday, 5 February 2015 at 06:58:09 UTC, Ali Çehreli wrote: On 02/04/2015 10:42 PM, zhmt wrote: Here is a simple code snippet: With this approach, the allocation of `arr` itself is often clumsy and error-prone. In this case it is important to note that `arr` is allocated on the stack an

Re: how can I get a reference of array?

2015-02-05 Thread Christof Schardt via Digitalmars-d-learn
"Ali Çehreli" schrieb im Newsbeitrag news:mav4a1$l3a$1...@digitalmars.com... On 02/04/2015 10:42 PM, zhmt wrote: The following article is very informative: http://dlang.org/d-array-article.html Nice and important article. But: How could I have looked this up this myself? What should be t

Re: how can I get a reference of array?

2015-02-05 Thread zhmt via Digitalmars-d-learn
On Thursday, 5 February 2015 at 08:58:47 UTC, bearophile wrote: zhmt: Will arr.ptr change in the future? As the array add more members , it need more memroy, then remalloc may be called, the pointer maybe change, then the stored pointer will be invalid. Will this happen? Yes, it can happ

Re: how can I get a reference of array?

2015-02-05 Thread zhmt via Digitalmars-d-learn
Sorry, I misunderstand the meaning of array pointer, it is not equals to arr.ptr. The array pointer meets my need perfectly . Ignore my replies above, Sorry!!!

Re: how can I get a reference of array?

2015-02-05 Thread bearophile via Digitalmars-d-learn
zhmt: Will arr.ptr change in the future? As the array add more members , it need more memroy, then remalloc may be called, the pointer maybe change, then the stored pointer will be invalid. Will this happen? Yes, it can happen. Bye, bearophile

Re: how can I get a reference of array?

2015-02-05 Thread zhmt via Digitalmars-d-learn
The behavior of array is more or less unpredictable. If it is always a reference like class , it will be more predictable.

Re: how can I get a reference of array?

2015-02-05 Thread zhmt via Digitalmars-d-learn
Will arr.ptr change in the future? As the array add more members , it need more memroy, then remalloc may be called, the pointer maybe change, then the stored pointer will be invalid. Will this happen?

Re: What am I doing Wrong (OpenGL & SDL)

2015-02-05 Thread drug via Digitalmars-d-learn
On 05.02.2015 10:53, Entity325 wrote: On Thursday, 5 February 2015 at 07:23:15 UTC, drug wrote: Look at this https://github.com/drug007/geoviewer/blob/master/src/sdlapp.d I used here SDL and OpenGL and it worked. Ctor of SDLApp creates SDL window with OpenGL context, may be it helps. Tested yo