Re: Networking library

2018-03-14 Thread Seb via Digitalmars-d-learn
On Thursday, 15 March 2018 at 00:10:28 UTC, Cecil Ward wrote: On Thursday, 15 March 2018 at 00:06:49 UTC, Cecil Ward wrote: Can anyone point me in the direction of a library that provides very very lightweight (minimum overhead) asynchronous i/o routines for - shopping list [...] Actually

Re: How do I make only the array itself immutable?

2018-03-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 15, 2018 02:06:23 Marc via Digitalmars-d-learn wrote: > Can I make it work? > > >struct S > >{ > > > > int[] l; > > > >} > > then > > >auto s = S(); > >s.l ~= 1; // ok > >s.l = []; // error It's not possible to do anything like that, and it really doesn't make sense when you

How do I make only the array itself immutable?

2018-03-14 Thread Marc via Digitalmars-d-learn
Can I make it work? struct S { int[] l; } then auto s = S(); s.l ~= 1; // ok s.l = []; // error

Re: Networking library

2018-03-14 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 15 March 2018 at 00:06:49 UTC, Cecil Ward wrote: Can anyone point me in the direction of a library that provides very very lightweight (minimum overhead) asynchronous i/o routines for - shopping list [...] Actually I realise that if I could simply write a wrapper pretty

Re: CTFE and -betterC

2018-03-14 Thread Flamaros via Digitalmars-d-learn
On Wednesday, 14 March 2018 at 01:17:54 UTC, rikki cattermole wrote: You will still need DllMain, that is a platform requirement. I am not sure about that because when DllAnalyser don't see it in the opengl32.dll from the system32 directory. And the documentation indicate that it is

Networking library

2018-03-14 Thread Cecil Ward via Digitalmars-d-learn
Can anyone point me in the direction of a library that provides very very lightweight (minimum overhead) asynchronous i/o routines for - shopping list 1. sending and receiving IPv4 / IPv6 packets, 2. sending receiving ICMP and 3, handling incoming outgoing TCP connections and 4. handling SCTP

Re: Function argument that is a pointer to memory which the function is not allowed to modify, as in C const

2018-03-14 Thread ag0aep6g via Digitalmars-d-learn
On 03/14/2018 11:23 PM, Cecil Ward wrote: say in C I have a function with a pointer argument     foo( const sometype_t * p ) I have asked about this D nightmare before. Using the same pattern in D or the in argument qualifier as far as I can see the value of the pointer is then itself

Re: Function argument that is a pointer to memory which the function is not allowed to modify, as in C const

2018-03-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 14, 2018 22:23:47 Cecil Ward via Digitalmars-d-learn wrote: > say in C I have a function with a pointer argument > foo( const sometype_t * p ) > > I have asked about this D nightmare before. Using the same > pattern in D or the in argument qualifier as far as I can see

Re: What is the "right" way to create a generic type getter (and setter) ?

2018-03-14 Thread ag0aep6g via Digitalmars-d-learn
On 03/14/2018 11:13 PM, James Blachly wrote: Suppose I have a struct (which is really a memory map of a data file I am reading in) with too many data members to reasonably code getters/setters for by hand.  I wish to either retrieve individual values or set individual values, which could be

Function argument that is a pointer to memory which the function is not allowed to modify, as in C const

2018-03-14 Thread Cecil Ward via Digitalmars-d-learn
say in C I have a function with a pointer argument foo( const sometype_t * p ) I have asked about this D nightmare before. Using the same pattern in D or the in argument qualifier as far as I can see the value of the pointer is then itself effectively locked made constant. Without

What is the "right" way to create a generic type getter (and setter) ?

2018-03-14 Thread James Blachly via Digitalmars-d-learn
For context, please keep in mind I am coming from a python background, but am very much enjoying strong typing, although it is taking some significant adjustment. Suppose I have a struct (which is really a memory map of a data file I am reading in) with too many data members to reasonably

Re: Why does struct initializer works for arrays but not for associative arrays?

2018-03-14 Thread Andre Pany via Digitalmars-d-learn
On Wednesday, 14 March 2018 at 15:17:54 UTC, Jonathan M Davis wrote: On Wednesday, March 14, 2018 13:36:51 Andre Pany via Digitalmars-d-learn wrote: [...] Well, I think that you have two issues here: 1. Struct literals work in only a few, specific circumstances. Why, I don't know, but IIRC,

Re: Why does struct initializer works for arrays but not for associative arrays?

2018-03-14 Thread Seb via Digitalmars-d-learn
On Wednesday, 14 March 2018 at 15:17:54 UTC, Jonathan M Davis wrote: On Wednesday, March 14, 2018 13:36:51 Andre Pany via Digitalmars-d-learn wrote: [...] Well, I think that you have two issues here: 1. Struct literals work in only a few, specific circumstances. Why, I don't know, but IIRC,

Re: Why does file order matters when using -run option?

2018-03-14 Thread Seb via Digitalmars-d-learn
On Wednesday, 14 March 2018 at 14:44:24 UTC, Marc wrote: assume the files: app.d void main() { import myModule : foo; writeln(foo(...)); } myModule.d module myModule; int foo(int n) { } the following fail: dmd -run app.d mymodule.d give error like this: Error: module

Re: Why does struct initializer works for arrays but not for associative arrays?

2018-03-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 14, 2018 13:36:51 Andre Pany via Digitalmars-d-learn wrote: > Hi, > > I do not understand why struct initializer works for arrays but > not for > associative arrays: > > struct Bar > { > string s; > } > > struct Foo > { > Bar[string] asso; > Bar[] arr; > } > >

Re: Why does struct initializer works for arrays but not for associative arrays?

2018-03-14 Thread Uknown via Digitalmars-d-learn
On Wednesday, 14 March 2018 at 13:36:51 UTC, Andre Pany wrote: Hi, I do not understand why struct initializer works for arrays but not for associative arrays: struct Bar { string s; } struct Foo { Bar[string] asso; Bar[] arr; } void main() { Foo foo = { arr: [{s:

Re: "Error: address of variable this assigned to this with longer lifetime"

2018-03-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 14, 2018 07:11:49 Nathan S. via Digitalmars-d-learn wrote: > On Tuesday, 13 March 2018 at 22:33:56 UTC, Jonathan M Davis wrote: > > And you can't get rid of it, because the object can still be > > moved, which would invalidate the pointer that you have > > referring to the

Re: Why does file order matters when using -run option?

2018-03-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 14 March 2018 at 14:44:24 UTC, Marc wrote: Why does -run fail here? I thought it was a shorthand to this batch: Check the help text: $ dmd -h dmd [...] -run [...] Argument to pass when running the resulting program Notice that there's only one file there.

Why does file order matters when using -run option?

2018-03-14 Thread Marc via Digitalmars-d-learn
assume the files: app.d void main() { import myModule : foo; writeln(foo(...)); } myModule.d module myModule; int foo(int n) { } the following fail: dmd -run app.d mymodule.d give error like this: Error: module `myModule` is in file 'myModule.d' which cannot be read

Why does struct initializer works for arrays but not for associative arrays?

2018-03-14 Thread Andre Pany via Digitalmars-d-learn
Hi, I do not understand why struct initializer works for arrays but not for associative arrays: struct Bar { string s; } struct Foo { Bar[string] asso; Bar[] arr; } void main() { Foo foo = { arr: [{s: "123"}], asso: ["0": {s: "123"}] // does not work }; }

Re: how to make private class member private

2018-03-14 Thread Seb via Digitalmars-d-learn
On Wednesday, 14 March 2018 at 04:30:17 UTC, Amorphorious wrote: On Wednesday, 14 March 2018 at 01:41:33 UTC, psychoticRabbit wrote: On Tuesday, 13 March 2018 at 21:38:59 UTC, Amorphorious wrote: You are a moron...etc..etc..etc..etc. See. This is what happens when you have

Re: RefRange behavior

2018-03-14 Thread Alex via Digitalmars-d-learn
On Wednesday, 14 March 2018 at 10:22:45 UTC, Alex wrote: Is there a simple workaround, maybe? ok, the workaround would be to enumerate the member and to use the former notation.

RefRange behavior

2018-03-14 Thread Alex via Digitalmars-d-learn
Hi all, given this: ´´´ import std.range; size_t[] arr; struct S { RefRange!(size_t[]) member; } void fun(ref size_t numByRef){} void main() { arr.length = 42; S s; s.member = refRange(); static assert(__traits(compiles, fun(s.member[0])));

Re: "Error: address of variable this assigned to this with longer lifetime"

2018-03-14 Thread Nathan S. via Digitalmars-d-learn
On Tuesday, 13 March 2018 at 22:33:56 UTC, Jonathan M Davis wrote: And you can't get rid of it, because the object can still be moved, which would invalidate the pointer that you have referring to the static array. ... https://issues.dlang.org/show_bug.cgi?id=17448 Thanks for the info.