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
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?
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
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: Command Line Utility Library
On Monday, 15 August 2016 at 09:26:21 UTC, Jacob Carlborg wrote: 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. 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
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: 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: 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.
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: 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 (&worker, 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"); }
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: 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: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 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: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
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: 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
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: 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 Seb how in the heck do you know about all these libraries, geeze.
Re: new XML and JSON libs and replacement of std.net.curl
On Monday, August 15, 2016 15:01:13 Oleg B via Digitalmars-d-learn 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. std.json and std.xml are definitely going to get the axe at some point. It's just a question of when we're going to have the replacements ready, and they've been slow in coming - primarily because one or more people have to actually do them, and they're a big undertaking. You can certainly use std.json and std.xml in the interim, but be aware that at some point, they will be deprecated, and you'll be forced to change your code to use something else. > 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. std_data_json is the most likely candidate for replacing std.json. It did go through the Phobos review process on some level, but it was decided at the time that it wasn't ready (unfortunately, I wasn't pay a lot of attention to it at the time, so I don't know the details). So, it will probably end up replacing std.json eventually, but I don't know when, and I don't know how much it will change before then. I have been using it for my projects, and it works reasonably well. It's what I'd suggest that you use, but you can choose to use std.json, and there are at least a couple of other projects on code.dlang.org that handle JSON. As to whether std_data_json is compatible with vibe.d, I don't know. It looks like it uses the same package, so I would have thought that vibe.d would just rely on it, but I don't know what Sonke is up to in that regard. > 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? That's an official GSOC project that is attempting to create a replacement for std.xml. It's very much a work in progress, and even if it is accepted, it's likely to go through a lot of changes before then. But as long as it's versioned well enough to use without having to deal with constant breakage, it would be valuable for you to use it and give feedback. If you don't want to deal with that, you can still use std.xml for now (as horrible as it is), and I think that there are at least a couple of other XML-related projects on code.dlang.org. > 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? I fully expect that std.json and std.xml will get replaced at some point. std.net.curl is a bit more questionable. The main reason that a number of folks want it gone is because it requires that you have an external, C library (curl) installed, and it's caused issues as a result, though those have more or less been resolved, and while Walter wants to get rid of it, Andrei doesn't seem to agree, so it may be here to stay. And since curl does stuff with SSL, and it's highly unlikely that we'd implement all of the crypto stuff in D without relying on an external C library, if we tried to get rid of std.net.curl, we'd either be trading one external library for another, or we'd lose functionality in Phobos. But regardless, if it did get removed, it would end up on code.dlang.org. While it does have various and cons, it's not like it's fundamentally bad. It's just questionable as to whether we want it in the standard library. So, if std.net.curl does what you want, then just use it. Worst case, at some point you _might_ have to change it so that your project pulls in std.net.curl as dub package instead of just getting it from Phobos. But there are alternatives on code.dlang.org that you can use if you'd prefer. - Jonathan M Davis
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: 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: Command Line Utility Library
On 2016-08-16 04:29, Jonathan Marler wrote: Seb how in the heck do you know about all these libraries, geeze. Currently Dub has so few libraries that it's possible to manually scan the list. -- /Jacob Carlborg