Re: How do I create a fileWatcher with an onFileChange event using spawn?

2017-08-27 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-25 23:25, Enjoys Math wrote: Something like this: module file_watcher; import std.concurrency; import std.file; import std.signals; import std.datetime; void fileWatcher(Tid tid, string filename, int loopSleep) { auto modified0 = timeLastModified(filename); while (tru

Re: Choosing between enum arrays or AliasSeqs

2017-08-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-25 08:12, Nordlöw wrote: Thanks! Your advice led to the following sample solution import std.meta : aliasSeqOf; immutable englishIndefiniteArticles = [`a`, `an`]; bool isEnglishIndefiniteArticle(S)(S s) {     return cast(bool)s.among!(aliasSeqOf!englishIndefiniteArticles); } Is th

Re: Web servers in D

2017-08-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-25 07:25, Hasen Judy wrote: What libraries are people using to run webservers other than vibe.d? Don't get me wrong I like the async-io aspect of vibe.d but I don't like the weird template language and the fact that it caters to mongo crowd. I think for D to a have good web story i

Re: dmd (v2.075.0): fully static linking: undefined reference to `__tls_get_addr'

2017-08-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-19 16:07, kdevel wrote: test.d --- void main () { } --- $ dmd -c test.d $ cc -o test test.o -L/[...]/dmd2/linux/lib64 -lphobos2 -static -lpthread -lrt /[...]/dmd2/linux/lib64/libphobos2.a(sections_elf_shared_774_420.o): In function `_D2rt19sections_elf_shared11getTLSRangeFNbNimmZAv'

Re: Create class on stack

2017-08-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-06 17:47, Moritz Maxeiner wrote: If you use this option, do be aware that this feature has been scheduled for future deprecation [1]. It's likely going to continue working for quite a while (years), though. It's used all over the place in the DMD code base. -- /Jacob Carlborg

Re: Create class on stack

2017-08-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-05 19:08, Johnson Jones wrote: using gtk, it has a type called value. One has to use it to get the value of stuff but it is a class. Once it is used, one doesn't need it. Ideally I'd like to treat it as a struct since I'm using it in a delegate I would like to minimize unnecessary all

Re: How to build GUI-based applications in D ?

2017-08-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-01 17:45, ashit wrote: thank you James i should try that. i was always enjoy the pure and efficiency of C. that made me stubborn to learn java. Just to be clear, there's no Java code in DWT. Everything is ported to D. -- /Jacob Carlborg

Re: Profiling after exit()

2017-07-28 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-28 11:30, Mario Kröplin wrote: Our programs are intended to run "forever". 24/7 servers. What's wrong with having a bool that determines if the loop should continue running? -- /Jacob Carlborg

Re: Profiling after exit()

2017-07-27 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-27 16:30, Eugene Wissner wrote: I have a multi-threaded application, whose threads normally run forever. But I need to profile this program, so I compile the code with -profile, send a SIGTERM and call exit(0) from my signal handler to exit the program. The problem is that I get the

Re: Cast to subclass in the dmd compiler

2017-07-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-25 23:06, unDEFER wrote: I have found the answer in the code. Right code is: Import imp = m.isImport(); if (imp !is null) Thank you. That's the correct solution. For Expression, there's a field called "op" that indicates what kind of expression it is, which can used in combinatio

Re: Get UDA of unit tests during Runtime.moduleUnitTester

2017-07-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-26 05:27, Matthew Remmel wrote: So as mentioned above, the first problem is that using ModuleInfo.unitTest returns an aggregated function of all 3 unit tests for that module, instead of each one individually, so the UDA information is lost. The second problem is that running __trai

Re: How does one determine the UDAs of all symbols contained in a given module?

2017-07-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-21 06:16, Andrew Edwards wrote: Thanks... Minus the AliasSeq bit, this is pretty much what I've been working with since talking to Brain. The main problem I'm facing is that it fails to compileif any of the symbols in the imported module is marked private. Ah, yes. That's a known

Re: How does one determine the UDAs of all symbols contained in a given module?

2017-07-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-19 13:49, Andrew Edwards wrote: Thanks Jacob and Nicholas... Brian Schott helped me out a bit on IRC earlier. I'm still not getting exactly what I'm looking for though so wanted to experiment a bit more before posting an update here. I'll check out the warp.d examples Nicholas linke

Re: C style 'static' functions

2017-07-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-19 14:11, John Burton wrote: Hmm it turns out this machine has 2.0.65 on which is fairly ancient. I'd not realized this machine had not been updated. Sorry for wasting everyones' time if that's so, and thanks for the help. I suspected something like this :). Nice to hear that you

Re: C style 'static' functions

2017-07-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-19 09:22, John Burton wrote: In C I can declare a function 'static' and it's only visible from within that implementation file. So I can have a static function 'test' in code1.c and another non static function 'test' in utils.c and assuming a suitable prototype I can use 'test' in my

Re: How does one determine the UDAs of all symbols contained in a given module?

2017-07-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-19 11:25, Nicholas Wilson wrote: You'll want to use https://dlang.org/spec/traits.html#getMember in conjunction with https://dlang.org/spec/traits.html#getAttributes. Have a look some of the projects on github e.g. https://github.com/kaleidicassociates/excel-d/blob/master/source/xl

Re: Appending static arrays

2017-07-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-17 22:11, Nordlöw wrote: - under what name: append, concat or cat? append - add array or element to existing array concat (concatenate) - add to arrays (or element) together to create a new array Seems like this is a concatenation. But please avoid shortening the names. I vote y

Re: Silly struct behaviour

2017-07-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-13 20:07, JN wrote: Consider: struct Foo { int bar; } void processFoo(Foo foo) { } void main() { Foo f = {bar: 5}; processFoo(f);// ok processFoo(Foo(5)); // ok processFoo({bar: 5}); // fail processFoo(Foo({bar: 5}));

Re: 2D game physics, macOS

2017-07-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-13 02:34, Joel wrote: It doesn't look like there's any thing I can use. I've come across: dbox, dchip, and blaze. Blaze is dsource. dbox is alpha and hasn't been updated for 3 years. dchip [1] hasn't been updated for 2 years and doesn't compile (that's with out using any thing, jus

Re: Foreign threads in D code.

2017-07-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-12 11:28, Biotronic wrote: That's basically what I tried to say It wasn't very clear to me at least. - the GC may collect memory *it has allocated* if the only pointers to it are in memory the GC doesn't scan (i.e. on the stack of an unregistered thread or in memory not allocated

Re: 2D game physics, macOS

2017-07-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-12 12:18, Joel wrote: Is there a 2D physics library I can use on macOS, with D? I already use a multimedia library for graphics, sound and input. Box2D [1] perhaps. I think I've seen bindings for it, somewhere. [1] http://box2d.org -- /Jacob Carlborg

Re: Foreign threads in D code.

2017-07-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-11 08:18, Biotronic wrote: If DRuntime is not made aware of the thread's existence, the thread will not be stopped by the GC, and the GC might collect memory that the thread is referencing on the stack or in non-GC memory. Are you sure? Wouldn't that make malloc or any other custom

Re: Fiber based UI-Toolkit

2017-07-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-11 04:40, Gerald wrote: Thanks for the link, I'm not active with .Net so I had to go look it up. Reminds me a lot of the way node.js works. If all your async activity is IO bound maybe it works fine and I'm wrong about this. My past experience has been that it's challenging to det

Re: Fiber based UI-Toolkit

2017-07-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-10 15:37, Gerald wrote: Having said that, I'm in the camp where this doesn't make much sense. Using fibers on the main UI thread is likely going to result in a blocked UI whenever a fiber takes too long to do its work. History has shown that cooperative multi-tasking typically doesn

Re: Application settings

2017-07-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-07 21:40, FoxyBrown wrote: What's the "best" way to do this? I want something I can simply load at startup in a convenient and easy way then save when necessary(possibly be efficient at it, but probably doesn't matter). Simply json an array and save and load it, or is there a better

Re: Fiber based UI-Toolkit

2017-07-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-09 23:12, bauss wrote: I believe OSX (possibly macOS too.) only allows it from the main thread. Yes, that's correct. But what's the difference between OSX and macOS ;) -- /Jacob Carlborg

Re: Fiber based UI-Toolkit

2017-07-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-09 21:43, Christian Köstlin wrote: I wonder if there is any fiber based / fiber compatible UI-Toolkit out for dlang. The second question is, if it would make sense at all to have such a thing? If I recall correctly, vibe.d has some form of integration with the native GUI event loop

Re: D and .lib files. C++/Other?

2017-07-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-01 21:11, Damien Gibson wrote: As well I only intended to use shared libraries not static ones... Well, you can use shared libraries in two different way, dynamic linking or dynamic loading. Dynamic linking is when you declare your external symbols as usual and you link with the

Re: D and .lib files. C++/Other?

2017-07-01 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-07-01 20:13, Damien Gibson wrote: Hi... A while back i had some issues with making a usable dll file, to which i did manage to figure out... Though while trying to use it with C++ i kept getting an error about a corrupted lib file... Not sure if this is the issue you're having, but if y

Re: Advice wanted on garbage collection of sockets for c++ programmer using D

2017-06-28 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-27 11:54, John Burton wrote: I'm coming from a C++ background so I'm not too used to garbage collection and it's implications. I have a function that creates a std.socket.Socket using new and connects to a tcp server, and writes some stuff to it. I then explicitly close the socket, and

Re: Advice wanted on garbage collection of sockets for c++ programmer using D

2017-06-28 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-27 17:24, Steven Schveighoffer wrote: Yes, Tango solved this by having a separate "finalize()" method. I wish we had something like this. Not sure if this is the same, but I remember that Tango had a separate method called "dispose" that was called if a class was allocated on the

Re: libc dependency

2017-06-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-21 17:51, David Nadlinger wrote: This is not relevant for cross-compilation, as long as you have the libraries available. You can actually link a D Windows x64/MSVCRT executable from Linux today if you copy over the necessary libraries. The question is just how we can make this as eas

Re: libc dependency

2017-06-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-20 21:59, David Nadlinger wrote: For Windows, we use the MS C runtime, though, and the legal situation around redistribution seems a bit unclear. Musl (or similar) should be available as an alternative. That will make it easier to cross-compile as well. But I guess MS C runtime is

Re: libc dependency

2017-06-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-20 14:10, Steven Schveighoffer wrote: I remember they specifically did not want to depend on anything in the C library. I can only tell you what I read from the source code :) . I didn't know enough about these things back in the D1 and Tango days. -- /Jacob Carlborg

Re: libc dependency

2017-06-20 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-20 13:51, Moritz Maxeiner wrote: Last time I checked you only needed the Xcode command line tools (which are small), not the whole thing. Yes. But I think there are a few things missing, depending on what you need. There's some LLDB library that is missing from the command line to

Re: libc dependency

2017-06-20 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-20 09:48, Russel Winder via Digitalmars-d-learn wrote: But there is lots of paid resource in the core Go community which makes not using "middleware" feasible by providing your own. Also of course the Go/C interface is not as clean as is the case in D, so the need for Go-specific midd

Re: libc dependency

2017-06-20 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-20 01:29, Steven Schveighoffer wrote: I may have misspoke. I mean they didn't depend on the library itself. I think they do depend on the C wrappers. So for instance, they didn't use FILE *, but instead used read/write/recv/send. They did use the Posix and Windows API functions.

Re: D and memory mapped devices

2017-06-14 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-14 11:04, Rene Zwanenburg wrote: I've casted void buffers to structs containing bitfields to read pre-existing binary files, and that worked just fine. I don't see why it would be different for memory mapped devices. What do yo mean by 'do more'? This bitfield discussion came up in

Re: D for Web Development?

2017-06-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-08 09:32, Michael Reiland wrote: A few questions: - Is vibe.d the recommended way of doing web work? Yes. - Is that book worth purchasing? Yes. - Does D have a good library for accessing Postgres? I see several listed but I don't know what the most stable would be for produc

Re: Linker cannot find malloc and free on OS X

2017-06-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-05 13:48, bvoq wrote: So I ran: dmd -unittest -main -v -L-lgmp -L-lc -g gmp/* The error seems to stem from: cc dbgio.o -o dbgio -g -m64 -Xlinker -no_compact_unwind -lgmp -lc -L/usr/local/Cellar/dmd/2.074.0/lib -lgmp -lgmp -lgmp -lgmp -lc -lphobos2 -lpthread -lm Full invocation of com

Re: Linker cannot find malloc and free on OS X

2017-06-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-05 01:14, bvoq wrote: The flag -L-lc seems to have been passed to the library. This is the full error message after running it with dub test --verbose You need to continue to invoke the sub commands, that is, DMD, Clang and the linker with the verbose flag (-v) added. There's no po

Re: D and GDB

2017-06-04 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-04 20:13, Russel Winder via Digitalmars-d-learn wrote: On Sun, 2017-06-04 at 20:31 +0300, ketmar via Digitalmars-d-learn wrote: maybe 'cause backtrace is called with `bt` command? ;-) Sadly even using the correct command, I am not getting any data that helps infer what the is

Re: std.path.buildPath

2017-06-04 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-04 19:05, Patrick Schluter wrote: buildPath("/usr/bin", "/usr/bin/gcc") /usr/bin/usr/bin/gcc is obviously wrong. Says who? It might be exactly what I want. The case that came up is inside DStep. The user provides a set of files C header to be translated to D modules. The user als

Re: Linker cannot find malloc and free on OS X

2017-06-04 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-04 12:45, Nordlöw wrote: My gmp-d tests successfully on Linux as dub test but on OS X it fails as Undefined symbols for architecture x86_64: "free", referenced from: ... "malloc", referenced from: ... Any ideas on why? https://github.com/nordlow/gmp-d/issues/4#issuecomment

Re: std.path.buildPath

2017-06-04 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-04 07:44, Jesse Phillips wrote: What is your expected behavior? Throw an exception? You can't really append an absolute path to another. Of course you can. I expect buildPath("/foo", "/bar") to result in "/foo/bar". That's how Ruby behaves. -- /Jacob Carlborg

Re: C macros vs D can't do the right thing

2017-06-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-03 16:22, David Nadlinger wrote: We could also finally fix the frontend to get around this. At DConf 2015, Walter officially agreed that this is a bug that needs fixing. ;) That would be nice. -- /Jacob Carlborg

Re: std.path.buildPath

2017-06-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-03 16:12, Russel Winder via Digitalmars-d-learn wrote: From the manual page on std.path.buildPath: writeln(buildPath("foo", "bar", "baz")); // "foo/bar/baz" writeln(buildPath("/foo/", "bar/baz")); // "/foo/bar/baz" writeln(buildPath("/foo", "/bar")); // "/bar" I have no i

Re: C macros vs D can't do the right thing

2017-06-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-06-03 16:03, Nicholas Wilson wrote: I think an alias template parameter will work here as aliases take anything(types, literals, symbols). No, it doesn't work for types: void foo(alias a)() {} void main() { foo!(int)(); } Results in: Error: template instance foo!int does not ma

Re: No tempFile() in std.file

2017-05-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-05-16 09:39, Anonymouse wrote: Linker --gc-sections IIRC that only works with LDC. With DMD it's possible that it removes sections that are used but not directly referenced. -- /Jacob Carlborg

Re: Lookahead in unittest

2017-05-11 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-05-10 18:17, Stefan Koch wrote: It looks like this unitest-test block are treated like a function. unittest blocks are lowered to functions. -- /Jacob Carlborg

Re: Structure of platform specific vs non platform specific code

2017-05-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-05-09 20:08, Igor wrote: In case you are interested in the reasoning for having platform code that imports game code Casey explains that in case where you structure all platform specific code in functions that other code should call you are making a needlessly big interface polluting the

Re: Structure of platform specific vs non platform specific code

2017-05-09 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-05-08 23:16, Igor wrote: Hi, I am following Casey Muratori's Handmade Hero and writing it in DLang. I got to Day 011: The Basics of Platform API Design where Casey explains the best way to structure platform specific vs non-platform specific code but his method cannot work in DLang since

Re: get vtable size

2017-05-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-05-07 06:01, Mike B Johnson wrote: how many elements(virtual functions) are in the __vptr? I guess you can use __traits(allMembers) and __traits(isVirtualMethod) [1]. [1] http://dlang.org/spec/traits.html -- /Jacob Carlborg

Re: Why does this compile (method in class without return type)

2017-05-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-05-03 14:50, Adam D. Ruppe wrote: No accident there, the spec says any storage class will do: http://dlang.org/spec/function.html#auto-functions "An auto function is declared without a return type. If it does not already have a storage class, use the auto storage class. " I see. -- /

Re: Why does this compile (method in class without return type)

2017-05-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-05-03 08:54, nkm1 wrote: Consider: import std.stdio; class A { final print() { writeln(this); } // no return type } class B : A { final void print() { writeln(this); } } void main() { auto b = new B; b.print(); A a1 = b; a1.print(); A a2 = new A;

Re: Top level associative arrays

2017-05-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-05-02 09:48, ANtlord wrote: Hello! Is it possible to define associative array on top level of module? I try to compile this code and I get message `Error: non-constant expression ["s":"q", "ss":"qq"]` import std.stdio; auto dict = [ "s": "q", "ss": "qq" ]; void main() { w

Re: Porting Java code to D that uses << and >>> operators

2017-05-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-05-02 01:27, Faux Amis wrote: To me, this [2] suggests otherwise ;) Or am I missing something? [2] https://dlang.org/spec/expression.html#order-of-evaluation From that link: "Note that dmd currently does not comply with left to right evaluation of function arguments and AssignExpres

Re: Porting Java code to D that uses << and >>> operators

2017-05-01 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-05-01 17:45, bachmeier wrote: I'm porting a small piece of Java code into D, but I've run into this: int y1 = ((x12 & MASK12) << 22) + (x12 >>> 9) + ((x13 & MASK13) << 7) + (x13 >>> 24); I have a basic understanding of those operators in both languages, but I can't find a sufficiently d

Re: interfacing Cpp - GCC Dual ABI abi_tag in name mangling

2017-04-30 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-04-29 20:08, سليمان السهمي (Soulaïman Sahmi) wrote: GCC has this attribute called abi_tag that they put on any function that returns std::string or std::list, for the rational behind that read here:https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html . the special thing wit

Re: Stuck with DMD, and Unit-Threaded

2017-04-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-04-16 10:20, Russel Winder via Digitalmars-d-learn wrote: There are points when you need to ask someone for help… I am trying to get Dub to build integration tests from test-source as a separate thing from building unit tests from source. The latter is easy and works, as does building th

Re: SFML gcc - MacOS

2017-04-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-04-16 10:11, Joel wrote: I've got Xcode, do I enter `xcode-select --install` in the terminal? Yes. That will get you access to Clang, the linker and other tools on the command line. It will also create /usr/include needed to build C/C++ code from the command line. -- /Jacob Carlbo

Re: SFML gcc - MacOS

2017-04-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-04-16 03:52, Joel wrote: In getting DSFML (http://dsfml.com/) working. I found gcc takes for ever to install, is there some thing wrong? (I posted in https://github.com/Jebbs/DSFML, but no replies). Maybe just install Xcode CLT (some how), and uninstall gcc. I've had this problem for a wh

Re: Duplicated functions not reported?

2017-04-15 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-04-15 13:10, Stefan Koch wrote: It would requires an O(n^2) check per declaration. Even it is never used. which would make imports that much more expensive. Does it need to be that bad? Isn't it possible to do some simple checks with less overhead? Something like first checking the na

Duplicated functions not reported?

2017-04-15 Thread Jacob Carlborg via Digitalmars-d-learn
I'm not sure if I'm missing something obvious here, but the following code compiles and runs: void foo() {} void foo() {} void main() {} Although if I do call "foo", the compiler will complain that it matches both versions of "foo". Is this expected behavior of how function overloading work

Re: Function names and lambdas

2017-04-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-04-07 23:05, Ali Çehreli wrote: Main reason for D not supporting the name-to-pointer mapping? I don't think so because as far as I know this has been the case since very early on but UFCS came very much later. More likely due to properties, i.e. calling functions without parentheses.

Re: Undefined Reference calling D from C using static linking

2017-03-23 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-03-23 13:26, Nicholas Wilson wrote: Getting dmd to do the linking should work. You may wish to see what mir (github.com/libmir) does to build in it's "Better C" mode, so i'm sure it is possible, I just don't know the incantations, sorry. Perhaps someone else can help. As an ugly workar

Re: Does "dub test" run tests?

2017-03-20 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-03-20 10:07, Russel Winder via Digitalmars-d-learn wrote: And different behaviour with different build options, at least when using dmd, but I think the same is true for ldc2: |> dub test No source files found in configuration 'library'. Falling back to "dub -b unittest". Performing "

Re: exceptions thrown when running app with failed unittests

2017-03-20 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-03-20 00:49, Ervin Bosenbacher wrote: On Sunday, 19 March 2017 at 23:23:48 UTC, Adam D. Ruppe wrote: On Sunday, 19 March 2017 at 22:33:26 UTC, Ervin Bosenbacher wrote: Is it normal to see the long trace output instead of just a failed unit test message? Yeah, it is normal, though IMO

Re: Inplace toLower()

2017-03-20 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-03-19 22:32, Nordlöw wrote: Is there an in-place version of std.uni.toLower() If not, how do I most elegantly construct one? I would recommend against toLower and toUpper as in-place versions. Not all letters can be converted in-place, i.e. they might require more storage. -- /Jacob

Re: What is PostgreSQL driver is most stable?

2017-03-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-03-15 15:08, Suliman wrote: Could you give an example when it's better to use DBRow and where to get data in structure? Use PGCommand and call "executeQuery" to get back a result set that is iteratable: auto query = "SELECT * FROM foos" auto cmd = new PGCommand(connection, query); a

Re: What is PostgreSQL driver is most stable?

2017-03-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-03-14 14:32, Suliman wrote: Does it work fine on Linux with x64 Postgres? I've tested it on macOS and Linux 64bit. Works great. -- /Jacob Carlborg

Re: Is it possible to use std.experimental.allocator without the runtime or with the runtime disabled?

2017-03-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-03-08 12:59, Guillaume Piolat wrote: Is it possible to use std.experimental.allocator without the runtime or with the runtime disabled? I had a quick look through the imports, I could not find anything that I know uses the runtime. Although it does use exceptions and asserts in some p

Re: Writing pattern matching macros in D.

2017-03-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-03-06 17:27, Deech wrote: I was thinking something on the order of Scala's pattern matching using apply/unapply methods. http://www.artima.com/pins1ed/extractors.html. That should be possible. Although not as a macro and not with the same nice syntax. Something like this should be pos

Re: Recommend: IDE and GUI library

2017-02-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-24 23:44, XavierAP wrote: And second question, is DWT the de facto standard for creating GUIs? Or are there good competitors. There's no de factor library for creating GUIs in D. If you want a native look and feel, DWT is a good option. If you want the application to look the same

Re: Serializer class

2017-02-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-24 19:10, houdoux09 wrote: The problem is that I can not retrieve the variables from the parent class. Cast the value to the type of the base class and run it through the same function. You can have a look at the Orange serialization library [1]. [1] https://github.com/jacob-carl

Re: Serializer class

2017-02-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-22 20:13, thedeemon wrote: On Wednesday, 22 February 2017 at 18:34:26 UTC, houdoux09 wrote: void Read(T)(T value) { foreach(i, mm; value.tupleof) { writeln(__traits(identifier, value.tupleof[i]), " = ", mm); if(isArray!(typeof(mm))) { Read(mm[0]); //

Re: Class Order Style

2017-02-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-20 14:47, Jolly James wrote: How to sort the members of a class? like: 1. properties then 2. private 3. methods 4. ctors ... and so on. are there any recommendations? In my opinion: 1. Manifest constants (enum) 2. Static variables 3. Instance variables 4. Constructors 5. Properti

Re: Getting nice print of struct for debugging

2017-02-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-22 12:18, Martin Tschierschke wrote: Exactly what I was looking for, **thank you!** Both ways of accessing the struct elements are very interesting, giving an impression what is possible with D. Is it possible to overwrite "toString" for all structs in one step? It depends. You ca

Re: How do I use CTFE to generate an immutable associative array at compile time?

2017-02-22 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-21 23:49, H. S. Teoh via Digitalmars-d-learn wrote: That may appear to work, but I would *strongly* recommend against it, because what happens when you use enum with an AA, is that the AA will be created *at runtime*, *every single time* it is referenced. (It is as if you copy-n-past

Re: Getting nice print of struct for debugging

2017-02-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-20 17:04, Martin Tschierschke wrote: Hello, I have a little program where I am filling a struct with values from an regex match. Now I want to display the content of the struct for debugging purpose. If struct is named MyStruct I can print a list of the field names with: foreach(fie

Re: Hello, folks! Newbie to D, have some questions!

2017-02-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-19 13:45, ketmar wrote: nogc doesn't turn it off, if says that compiler must ensure that *your* *code* doesn't allocate, Just to clarify, allocate using the GC. It's perfectly fine to allocate using malloc in a @nogc function. -- /Jacob Carlborg

Re: Get the address of an object, within the object itself

2017-02-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-15 22:42, Andrew Chapman wrote: Thanks Jonathan. Good point about the reference address. I can work around this quite easily, but I was curious. I will try the void* cast and see what happens. If it's only for printing you can use the C "printf" without any casting: import core.

Re: Creating an array of immutable objects

2017-02-14 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-15 01:08, David Zhang wrote: Thanks for your answers. Out of curiosity though, how could something like this be done with classes instead? You mean if FileDesc was a class? It's basically the same. You would need: Mutable array: 1. Add a constructor which sets all immutable instanc

Re: Creating an array of immutable objects

2017-02-14 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-02-14 01:59, David Zhang wrote: Hi, I have a struct with two immutable members, and I want to make an array of them. How do I to this? I'm using allocators for this. string[] paths; struct FileDesc { immutable string path; immutable uint index; } _fileDesc = /*something*/; Yo

Re: Minimum PR size

2017-01-31 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-01-31 11:36, Jason Schroeder wrote: I am interested in contributing to D on GitHub, and was wondering if there is a minimum or preferabe minimum size of a pull request; e.g. I woukd like to work on increasing code coverage, and am wondering if a pull request with one additional line of co

Re: What do you use to generate documentation?

2017-01-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-01-19 19:45, Suliman wrote: It's seems that there is no any big changes in this deal. The upcoming 2.073.0 (now in release candidate) has a completely new default Ddoc theme. -- /Jacob Carlborg

Re: What do you use to generate documentation?

2017-01-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2013-03-13 10:35, Andrea Fontana wrote: I've tried to build documentation using ddoc format and dmd. dmd -c -D -o- ... Generated documentation looks ugly and without stylesheet. Am I wrong? Yes :). The upcoming 2.073.0 (now in release candidate) has a completely new default Ddoc theme.

Re: version identifier hygiene

2017-01-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-01-16 21:04, Ali Çehreli wrote: It is plausible to compile and link the sources of multiple packages on the same command line at the same. (I'm not sure whether this is required for e.g. LLVM's link-time optimization (LTO) but I think it helps the compiler as well.) The trouble is, the v

Re: Delegate parameter name shadows type name

2017-01-09 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-01-09 20:51, Ali Çehreli wrote: Those two syntaxes always confuse me and I'm never sure without trying which one to use when. :) However, the code is correct in this case because that's a delegate instance. I agree. When it comes to declaring a delegate type, i.e. a variable or functi

Re: Delegate parameter name shadows type name

2017-01-09 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-01-09 20:18, Ali Çehreli wrote: This is something that surprised me in a friend's code. (A "friend", hmmm? No, really, it wasn't me! :) ) // Some type of the API struct MyType { int i; } // Some function of the API that takes a delegate void call(void delegate(MyType) dlg) { dl

Re: Selective unittesting in DUB

2016-12-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-12-21 19:07, Nordlöw wrote: Is there a way to specify in dub.json (or any other file) that only a subset of the sources compiled and linked to a library or app should have they're unittests enabled? You can use the "unittest" configuration in Dub to add or remove files, but I don't thi

Re: Is it possbile to specify a remote git repo as dub dependency?

2016-12-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-12-19 13:11, biocyberman wrote: I can write a short script to clone the remote git repo and use it as a submodule. But if it is possible to do with dub, it will be more convenient. It's not currently possible. -- /Jacob Carlborg

Re: Using tango with dub

2016-12-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-12-17 21:15, bauss wrote: I thought Tango was obsolete a long time ago. It's a third party library like any other library. -- /Jacob Carlborg

Re: Using tango with dub

2016-12-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-12-18 10:43, albert-j wrote: Try an older version. Before resorting to that, I am also trying to "dub build --compiler=gdc". Getting different types of errors: ../../../.dub/packages/tango-1.0.3_2.068/tango/tango/math/IEEE.d:614:17: error: instead of C-style syntax, use D-style syntax

Re: Using tango with dub

2016-12-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-12-17 16:51, albert-j wrote: Since I just do "dub build", I assume it invokes dmd? I have v2.072.0. Try an older version. -- /Jacob Carlborg

Re: Using tango with dub

2016-12-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-12-17 16:46, albert-j wrote: I am trying to use Tango in a dub project because I need a HashSet. I added Tango as a dependency to the dub.json, but now dub gives me a bunch of depreciation warnings and a few errors, like ../../../.dub/packages/tango-1.0.3_2.068/tango/tango/util/log/Log.d

Re: Get fils at compile-time

2016-12-15 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-12-14 21:47, bauss (wtf happend to my name took some old cached title LOL??) wrote: Is there a way to get all files in a folder at compile-time. To be more specific I want to import the content of all files within a specific folder during compile-time. I know how to do it with a specific

Re: Check whether function/delegate uses any shared or global variables

2016-12-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-12-12 12:15, Nicholas Wilson wrote: there is the pure function attribute, how ever this still allows you to use globals *if you pass them as parameters to the function*. And it can access immutable global data. -- /Jacob Carlborg

Re: How to use library compiled with Microsoft Visual Studio 2015 in D?

2016-12-04 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-12-05 07:44, unDEFER wrote: Hello! I have compiled libdb (BerkeleyDB) with Microsoft Visual Studio 2015. 1) "Debug" mode. I have libdb53d.dll file. Do implib. The linker doesn't seen symbols from the library! Do "lib -l". In the list of symbols "db_create", linker searches "_db_create". I

Re: how to catch D Throwables (or exceptions) from C++?

2016-12-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-12-01 02:58, Timothee Cour via Digitalmars-d-learn wrote: eg: ``` dlib.d: extern(C) void dfun(){assert(0, "some_msg");} clib.cpp: extern "C" void dfun(); void fun(){ try{ dfun(); } catch(...){ // works but how do i get "some_msg" thrown from D? } } ``` At least for a C

<    1   2   3   4   5   6   7   >