Re: Template type reduction
On Monday, 15 August 2016 at 19:40:37 UTC, Steven Schveighoffer wrote: On 8/15/16 3:31 PM, Engine Machine wrote: Suppose I have a templated type like struct S(T) { int x; static if (T is Y) int y; } I would like to be able to create a reference to S(T) for any T, struct Q { S!* s; // Can hold any type of S. } and be able to access s.x, since it is common to all S. Can D do anything like this? It is sort of like runtime inheritance, but at the compile time level. I don't think so. You'd have to cast, as the compiler doesn't have any understanding that all S instantiations will have an x member. This is a problem. How can I cast to something I don't know? I do not want to have to cast to S!T every time just to access x, e.g., struct Q { Object s; } which is too general as s can be things that are not of type S!*. This seems odd. You will lose the type information for s if you were to succeed. Might as well just store an int. Seems like what you want is a variant or some other kind of tagged union. No, what I want is a type that is the intersection of all the types it can be. The problem is I cannot cast because the type is complex and I don't know the exact signature, but I do know that it has a basic type embedded in it. enum Types { Int, Word, Complex } struct MyType(string name, Types type, Args...) { string Name = name; Types Type = type; static if (type == Int) int val; static if (type == word) ushort val; static if (type == Complex) { ... }; } So, how can I get val? I know if it is an int or a word, val exists. But I can't specify the name or type at runtime to get at the innards of the type. Object o = MyType!("test", Types.Int); Useless! I can never retrieve anything from o. I can't cast it back. Yet I know that o has a name and a type and possibly a val if I know the type... and I know all this at compile time. Yet D doesn't seem to allow me to use this information. I know one will say use either oop or constructors, but neither of these are appropriate(although constructors are close). What I need is a type constructor, which bridges the gap. This is how I am using the data above, to construct the object, but D treats it as part of the type, which I don't what. I guess I will have to use string mixins to construct the types properly ;/ What a pain in the ass ;/
Re: new XML and JSON libs and replacement of std.net.curl
On 16/08/2016 3:35 AM, Seb wrote: On Monday, 15 August 2016 at 15:25:22 UTC, rikki cattermole wrote: On 16/08/2016 3:20 AM, Seb wrote: On Monday, 15 August 2016 at 15:04:29 UTC, rikki cattermole wrote: On 16/08/2016 3:01 AM, Oleg B wrote: As replacement of std.net.curl I found https://github.com/ikod/dlang-requests. Who know's about this lib? Is this good replacement of std.net.curl? Nope, not a replacement. Why? I like it a lot more than std.net.curl (try to get the error code in std.net.curl) & the decision that etc (which wrap curl & zlib) needs to go has been made at Dconf, so I would love to see dlang-requests as std.experimental.http ;-) No matter how much I would like curl to go, it still requires somebody willing to do it. Keep in mind that it won't be able to support https without adding a dependency such as Botan into the mix. A heck a lot of work. Oh I thought the author was just asking whether it is a good replacement for him personally. Well before we worry about Botan, I think libasync needs to arrive first ;-) https://github.com/etcimon/libasync (it's from the same author as Botan) My personal opinion of libasync is that while it is a great idea and is needed, the coding is pretty horrible. So I started SPEW[0] which should handle windowing primarily (but also sockets, timers ext.). [0] http://spew.cf/
Re: Command Line Utility Library
On Monday, 15 August 2016 at 10:48:11 UTC, Seb wrote: Are you trying to parse arguments? There's a lot of good stuff for it already: https://dlang.org/phobos/std_getopt.html https://code.dlang.org/packages/darg https://blog.thecybershadow.net/2014/08/05/ae-utils-funopt/ For configuration files: https://code.dlang.org/packages/onyx-config https://code.dlang.org/packages/inid https://code.dlang.org/packages/yamkeys https://code.dlang.org/packages/runtimer https://code.dlang.org/packages/variantconfig Seb how in the heck do you know about all these libraries, geeze.
Re: Command Line Utility Library
On Tuesday, 16 August 2016 at 01:23:16 UTC, UDW wrote: On Monday, 15 August 2016 at 10:48:11 UTC, Seb wrote: [...] Thanks for the suggestions Seb, https://blog.thecybershadow.net/2014/08/05/ae-utils-funopt/ looks very nice :). I just thought there would be a standard library, stdclib, phobos or otherwise for making CLI tools that would generate sub-commands, options, help text and handle input for it all. Unfortunately my gumby searching didn't find much yesterday. Sort of like this https://github.com/tj/commander.js which I found after a bit more searching. ty again Have you had a detailed look at std.getopt? https://dlang.org/phobos/std_getopt.html That's very similar to commander.js ;-)
Re: Command Line Utility Library
On Monday, 15 August 2016 at 10:48:11 UTC, Seb wrote: Are you trying to parse arguments? There's a lot of good stuff for it already: https://dlang.org/phobos/std_getopt.html https://code.dlang.org/packages/darg https://blog.thecybershadow.net/2014/08/05/ae-utils-funopt/ For configuration files: https://code.dlang.org/packages/onyx-config https://code.dlang.org/packages/inid https://code.dlang.org/packages/yamkeys https://code.dlang.org/packages/runtimer https://code.dlang.org/packages/variantconfig Thanks for the suggestions Seb, https://blog.thecybershadow.net/2014/08/05/ae-utils-funopt/ looks very nice :). I just thought there would be a standard library, stdclib, phobos or otherwise for making CLI tools that would generate sub-commands, options, help text and handle input for it all. Unfortunately my gumby searching didn't find much yesterday. Sort of like this https://github.com/tj/commander.js which I found after a bit more searching. ty again
Re: Template type reduction
On 8/15/16 3:31 PM, Engine Machine wrote: Suppose I have a templated type like struct S(T) { int x; static if (T is Y) int y; } I would like to be able to create a reference to S(T) for any T, struct Q { S!* s; // Can hold any type of S. } and be able to access s.x, since it is common to all S. Can D do anything like this? It is sort of like runtime inheritance, but at the compile time level. I don't think so. You'd have to cast, as the compiler doesn't have any understanding that all S instantiations will have an x member. I do not want to have to cast to S!T every time just to access x, e.g., struct Q { Object s; } which is too general as s can be things that are not of type S!*. This seems odd. You will lose the type information for s if you were to succeed. Might as well just store an int. Seems like what you want is a variant or some other kind of tagged union. -Steve
Template type reduction
Suppose I have a templated type like struct S(T) { int x; static if (T is Y) int y; } I would like to be able to create a reference to S(T) for any T, struct Q { S!* s; // Can hold any type of S. } and be able to access s.x, since it is common to all S. Can D do anything like this? It is sort of like runtime inheritance, but at the compile time level. I do not want to have to cast to S!T every time just to access x, e.g., struct Q { Object s; } which is too general as s can be things that are not of type S!*. Is this possible?
Re: new XML and JSON libs and replacement of std.net.curl
On Monday, 15 August 2016 at 15:01:13 UTC, Oleg B wrote: Hello. As replacement of std.net.curl I found https://github.com/ikod/dlang-requests. Who know's about this lib? Is this good replacement of std.net.curl? Maybe if I need json and http requests I must fully use vibe for these things? Vibe not resolve xml question =( I want to use minimal count of dependencies... Hello, Can you use dlang-requests instead of curl, or not, depends on your requirements. If you find any bugs, you can post bug report to project, usually I react quickly. dlang-requests depend only on libssl/libcrypt. Regards, Igor
Re: new XML and JSON libs and replacement of std.net.curl
On Monday, 15 August 2016 at 15:01:13 UTC, Oleg B wrote: Hello. In std.xml docs I read that is deprecated, [...] For XML I found this project https://github.com/lodo1995/experimental.xml. Is this really candidate to std, or author just called it as he want? Hi! I'm the developer of that XML library. It is still under heavy development, so if you decide to use it and find any problem, feel free to contact me on GitHub. Feedback from actual usage is very important to understand what needs more work. Thank you. As a side note, the GSoC is almost over, so the iter for inclusion in Phobos should start soon.
Re: new XML and JSON libs and replacement of std.net.curl
On Monday, 15 August 2016 at 15:25:22 UTC, rikki cattermole wrote: On 16/08/2016 3:20 AM, Seb wrote: On Monday, 15 August 2016 at 15:04:29 UTC, rikki cattermole wrote: On 16/08/2016 3:01 AM, Oleg B wrote: As replacement of std.net.curl I found https://github.com/ikod/dlang-requests. Who know's about this lib? Is this good replacement of std.net.curl? Nope, not a replacement. Why? I like it a lot more than std.net.curl (try to get the error code in std.net.curl) & the decision that etc (which wrap curl & zlib) needs to go has been made at Dconf, so I would love to see dlang-requests as std.experimental.http ;-) No matter how much I would like curl to go, it still requires somebody willing to do it. Keep in mind that it won't be able to support https without adding a dependency such as Botan into the mix. A heck a lot of work. Oh I thought the author was just asking whether it is a good replacement for him personally. Well before we worry about Botan, I think libasync needs to arrive first ;-) https://github.com/etcimon/libasync (it's from the same author as Botan)
Re: new XML and JSON libs and replacement of std.net.curl
On 16/08/2016 3:20 AM, Seb wrote: On Monday, 15 August 2016 at 15:04:29 UTC, rikki cattermole wrote: On 16/08/2016 3:01 AM, Oleg B wrote: As replacement of std.net.curl I found https://github.com/ikod/dlang-requests. Who know's about this lib? Is this good replacement of std.net.curl? Nope, not a replacement. Why? I like it a lot more than std.net.curl (try to get the error code in std.net.curl) & the decision that etc (which wrap curl & zlib) needs to go has been made at Dconf, so I would love to see dlang-requests as std.experimental.http ;-) No matter how much I would like curl to go, it still requires somebody willing to do it. Keep in mind that it won't be able to support https without adding a dependency such as Botan into the mix. A heck a lot of work.
Re: new XML and JSON libs and replacement of std.net.curl
On Monday, 15 August 2016 at 15:04:29 UTC, rikki cattermole wrote: On 16/08/2016 3:01 AM, Oleg B wrote: As replacement of std.net.curl I found https://github.com/ikod/dlang-requests. Who know's about this lib? Is this good replacement of std.net.curl? Nope, not a replacement. Why? I like it a lot more than std.net.curl (try to get the error code in std.net.curl) & the decision that etc (which wrap curl & zlib) needs to go has been made at Dconf, so I would love to see dlang-requests as std.experimental.http ;-)
Re: Multi-Thread message passing approach
I misunderstood the problem. The problem was that a dynamically sized array cannot be sent as a message. So this works: import std.concurrency; import std.stdio; import core.thread; enum tidMax = 10; struct Start { int tidCnt = 0; Tid[tidMax] tids; } struct Msg { int orig; int dest; } struct Done { int dummy = 0; } void worker (int ndx) { writeln ("worker ", ndx, " spawned"); Start start = receiveOnly!(Start)(); Tid[] tids; foreach (i; 0 .. start.tidCnt) { tids ~= start.tids[i]; } writeln ("worker ", ndx, " got tidList"); for (int i = 0; i < 3; i++) { if (i != ndx) { Msg msg = Msg(ndx, i); send (tids[i], msg); } } writeln ("worker ", ndx, " sent messages"); bool done = false; while (!done) { receive ( (Msg msg) { writeln ("msg from: ", msg.orig, ", to: ", msg.dest); }, (Done d) { done = true; } ); } writeln ("worker ", ndx, " is done"); } void main() { Start start; Done done; for (int i = 0; i < 3; i++) { auto tid = spawn (, i); start.tids[start.tidCnt++] = tid; } foreach (i; 0 .. start.tidCnt) { send (start.tids[i], start); } Thread.sleep (1000.msecs); foreach (i; 0 .. start.tidCnt) { send (start.tids[i], done); } Thread.sleep (1000.msecs); writeln ("main is done"); }
new XML and JSON libs and replacement of std.net.curl
Hello. In std.xml docs I read that is deprecated, and std.net.curl can be deprecated too (not remember here I read about std.net.curl). About std.json I read what it's has slow (de)serialization. What I must use at this time? vibe.data.json has evolution https://github.com/s-ludwig/std_data_json, but, if I correctly understood, they are not compatible and I can't use stdx.data.json in vibe. For XML I found this project https://github.com/lodo1995/experimental.xml. Is this really candidate to std, or author just called it as he want? As replacement of std.net.curl I found https://github.com/ikod/dlang-requests. Who know's about this lib? Is this good replacement of std.net.curl? Maybe if I need json and http requests I must fully use vibe for these things? Vibe not resolve xml question =( I want to use minimal count of dependencies...
Re: new XML and JSON libs and replacement of std.net.curl
On 16/08/2016 3:01 AM, Oleg B wrote: Hello. In std.xml docs I read that is deprecated, and std.net.curl can be deprecated too (not remember here I read about std.net.curl). About std.json I read what it's has slow (de)serialization. What I must use at this time? vibe.data.json has evolution https://github.com/s-ludwig/std_data_json, but, if I correctly understood, they are not compatible and I can't use stdx.data.json in vibe. For XML I found this project https://github.com/lodo1995/experimental.xml. Is this really candidate to std, or author just called it as he want? Official GSOC project so most likely will be accepted. As replacement of std.net.curl I found https://github.com/ikod/dlang-requests. Who know's about this lib? Is this good replacement of std.net.curl? Nope, not a replacement. Maybe if I need json and http requests I must fully use vibe for these things? Vibe not resolve xml question =( I want to use minimal count of dependencies... Basically they have been there for a while, expect them be there for a long time. So unless they don't work for you, may as well use them.
Re: Virus detected
On Monday, 15 August 2016 at 06:51:35 UTC, Joel wrote: Thanks rikki. Did you install it? Try to copy the installed files to a folder visible to windows defender, maybe only one file is a culprit - which one?
Re: Virus detected
On Monday, 15 August 2016 at 06:20:55 UTC, Joel wrote: I can't install DMD, because Windows defender says the install file has a virus and wipes it off. I'm using a Windows 10 pro OS. DMD 2.071.1 this seems to be a recent issue & at least you aren't alone with this problem: http://forum.dlang.org/post/cvsrmxfryidhizacc...@forum.dlang.org
Re: Command Line Utility Library
On 2016-08-15 09:29, UDW wrote: Hi, I would like some options for a library, preferably json configurable, that helps with command line tool development. Doesn't have to be in D specifically. Currently I am using using std.getopt. I had a search in the DUB repos and in github but didn't really find anything appealing. I think you need to be a bit more specific on what you need. -- /Jacob Carlborg
Re: Caesar Cipher Cracking
On Sunday, 14 August 2016 at 18:36:02 UTC, Stefan wrote: same code, just a little shorter. usage of ".array" more UFCS replaced cast with ".to" Wow Stefan! Thanks for your time, I'll have a look at it! Antonio
Using shared libraries for external scripts, looking for advice (windows)
So this is kind of an open ended question, just looking for advice on doing it in general, if it's possible, and doing it specifically in D on windows. I am not super familiar with how shared libraries work so I had some questions. I would like to attempt to use D to write scripts for a game engine I am working on. The goal is to have the ability to externalize the code that is specific to an individual game or level instead of just compiling it all into the engine it self. I want to be able to treat them as resources similar to other asset files such as images or models. A secondary goal is to be able to reload them at runtime for iteration. So with that in mind, my general plan was to compile them into dll's and load them at runtime. My understanding is that to make it work, each dll will need to have an entry point that registers its data with the rest of the engine but I am unclear of some of the details or even if it is possible. I am unsure of how to give the library access to the rest of the engine. For instance, I have some global data in the engine. How do I go about making sure the dlls have access to that data, is there a way to make sure the dll will share the memory space as the rest of the program, or will I need to explicitly pass that data into the dll to give it access. Also I am unsure of how to go about keeping the engine code out of the dll. I would like to keep the dll as small as possible. If the dll accesses anything from the engine, how do I keep the engine code out of the dll? Idealy I would also like to keep phobos out of the dll as well. If the dlls get too big then it will probably not be useable. Is this even possible currently? Is this a terrible idea or am I severely misunderstanding things? I think I heard that remedy games did something similar, anyone know the specifics of how they did it?
Command Line Utility Library
Hi, I would like some options for a library, preferably json configurable, that helps with command line tool development. Doesn't have to be in D specifically. Currently I am using using std.getopt. I had a search in the DUB repos and in github but didn't really find anything appealing. ty ss <3
Re: Virus detected
On Monday, 15 August 2016 at 06:28:54 UTC, rikki cattermole wrote: On 15/08/2016 6:20 PM, Joel wrote: I can't install DMD, because Windows defender says the install file has a virus and wipes it off. I'm using a Windows 10 pro OS. DMD 2.071.1 Windows Defender is fairly false positive heavy, I usually disable it in favor of Avast. The problem relates to dmd and Optlink, they are old coding style and very obvious what they are doing (code generation) which is usually not a good thing. Alternately you can just exclude it from a set directory[0] which I also do for Avast (why would I wait for it to scan programs that I COMPILED!). [0] https://support.microsoft.com/en-nz/instantanswers/64495205-6ddb-4da1-8534-1aeaf64c0af8/add-an-exclusion-to-windows-defender Thanks rikki.
Re: Virus detected
On 15/08/2016 6:20 PM, Joel wrote: I can't install DMD, because Windows defender says the install file has a virus and wipes it off. I'm using a Windows 10 pro OS. DMD 2.071.1 Windows Defender is fairly false positive heavy, I usually disable it in favor of Avast. The problem relates to dmd and Optlink, they are old coding style and very obvious what they are doing (code generation) which is usually not a good thing. Alternately you can just exclude it from a set directory[0] which I also do for Avast (why would I wait for it to scan programs that I COMPILED!). [0] https://support.microsoft.com/en-nz/instantanswers/64495205-6ddb-4da1-8534-1aeaf64c0af8/add-an-exclusion-to-windows-defender
Virus detected
I can't install DMD, because Windows defender says the install file has a virus and wipes it off. I'm using a Windows 10 pro OS. DMD 2.071.1