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: 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);

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

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

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

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

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

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

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

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: 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: 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-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

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

Re: Silly struct behaviour

2017-07-14 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: 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

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: 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-11 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

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,

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

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

Re: Profiling after exit()

2017-07-28 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-26 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

Re: Get UDA of unit tests during Runtime.moduleUnitTester

2017-07-26 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

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

2017-07-25 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: 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

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.

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: 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

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

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

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

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: 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

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: 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: 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: 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

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

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

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: 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

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-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

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

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

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

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

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: 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

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

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

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: 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?

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: 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: 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: 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

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

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() {

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: 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,

Re: Add a precompiled c++ obj file to dub

2017-10-09 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-08 04:58, Fra Mecca wrote: At the end I added them as linking options (lflags) but it is kinda odd that it works given that everything is supplied to dmd as -Lobj.o Everything passed to DMD with the -L flag is passed to the linker, basically as is. So if the linker accepts object

Re: What's the best way to programmatically detect the most recent release of DMD and others?

2017-10-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-16 17:13, Andrew Edwards wrote: The best way I know to determine the latest DMD release is http://ftp.digitalmars.com/LATEST. I'm not aware that such a file exists for LDC and GDC so I'm currently doing: string latest(string url) {     return executeShell("git ls-remote --tags " ~

Re: What's the best way to programmatically detect the most recent release of DMD and others?

2017-10-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-16 20:32, Andrew Edwards wrote: You're a godsend. Thank you very much. :D -- /Jacob Carlborg

Re: How to modify process environment variables

2017-10-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-17 06:51, Ky-Anh Huynh wrote: Hi, Is it possible to change the current process's environment variables? I have looked at `std/process.d` source code, and there is only a private method `createEnv` used when new (sub)process is created. In C `putEnv` the answer is positive:

Re: Tango + D2 + Mac

2017-10-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-17 04:52, Fat_Umpalumpa wrote: I am having a lot of trouble trying to install Tango to use with D2 on my mac os Sierra. Is this even possible? Thanks! It can be used as a Dub package [1]. But it will not compile with the latest version of DMD. 2.071.0 is the latest version it

Re: Does D have an equivalent to C#'s String.IsNullOrWhiteSpace?

2017-10-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-12 21:42, Daniel Kozak wrote: Wow, C# is really wierd. They have method IsNullOrEmpty (OK why not), but they have IsNullOrWhiteSpace OK little akward but still OK until you realized it is more like IsNullOrEmptyOrWhiteSpace :D It's pretty neat functionality. Ruby has it (or rather

Re: Output range with custom string type

2017-08-30 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-29 19:35, Moritz Maxeiner wrote: On Tuesday, 29 August 2017 at 09:59:30 UTC, Jacob Carlborg wrote: [...] But if I keep the range internal, can't I just do the allocation inside the range and only use "formattedWrite"? Instead of using both formattedWrite and sformat and go through

Re: extern(C) and slices

2017-09-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-09-12 01:03, Nordlöw wrote: If I have a function like `extern(C) void f(void *x, size_t x_sz)` can I instead declare it as `extern(C) void f(void[] x)` ? It looks like the length needs to come first [1]. I think it would be technically possible if you flipped the parameters but

Re: Cannot make LDC use LTO when called via DUB

2017-09-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-09-25 09:47, Sebastiaan Koppe wrote: I didn't know dflags-* was a thing, and I can't find it in docs either. That's how it works in the JSON package description file. -- /Jacob Carlborg

Re: core.stdc.time

2017-09-30 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-09-30 08:56, Tony wrote: The documentation says: -- This module contains bindings to selected types and functions from the standard C header . Note that this is not automatically generated, and may omit some types/functions from the

Re: When to opCall instead of opIndex and opSlice?

2017-10-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-02 17:57, Nordlöw wrote: Is implementing opCall(size_t) for structures such as array containers that already define opIndex and opSlice deprecated? I can't find any documentation on the subject on when opCall should be defined to enable foreach (isIterable). opCall is not related

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

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

2017-08-28 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

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

2017-08-28 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-28 08:31, Nemanja Boric wrote: On Monday, 28 August 2017 at 06:27:20 UTC, Jacob Carlborg wrote: http://code.dlang.org/packages/vibe-core http://code.dlang.org/packages/libasync In addition, to avoid polling, it's possible to register yourself to the operating system so it will

Output range with custom string type

2017-08-28 Thread Jacob Carlborg via Digitalmars-d-learn
I'm working on some code that sanitizes and converts values of different types to strings. I thought it would be a good idea to wrap the sanitized string in a struct to have some type safety. Ideally it should not be possible to create this type without going through the sanitizing functions.

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

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

Re: Output range with custom string type

2017-08-29 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-28 23:45, Moritz Maxeiner wrote: If you want the caller to be just in charge of allocation, that's what std.experimental.allocator provides. In this case, I would polish up the old "format once to get the length, allocate, format second time into allocated buffer" method used with

Re: hijack dub test

2017-08-31 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-31 08:41, Nicholas Wilson wrote: My project is a library, but I also need to test it and unit tests won't cut it (external hardware). How do you set up the dub.json to build the library normally but when it is invoked with `dub test` it runs a separate configuration that also

Re: Output range with custom string type

2017-08-31 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-29 19:35, Moritz Maxeiner wrote: void put(T t) {     if (!store)     {     // Allocate only once for "small" vectors     store = alloc.makeArray!T(8);     if (!store) onOutOfMemoryError();     }     else if (length ==

Re: Dustmite always reduced to empty set after two iterations

2017-10-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-11 22:36, Nordlöw wrote: My first idea is to make stderr "core dumped" the invariant. Therefore my first try becomes to redirect stderr to stdout (in bash) and grep for the pattern 'core dumped' as follows IIRC, segmentation faults are printed by the shell and not the

Re: Linking multiple libraries

2017-11-26 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-25 23:31, Mike Parker wrote: You don't link static libraries with each other. They're just collections of object files intended to be linked with an executable or a DLL. Order doesn't matter for optlink or the MS linker, but other linkers, such as ld (which is commonly used with

Re: GUI program on Mac OS in D?

2017-11-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-24 16:09, Adam D. Ruppe wrote: Thanks, this gets me started. Do you happen to know if there is anything like "pragma(lib)" for the -framework argument? (I don't use dub, so I took your config there to make my own command line, but it would be nice if I didn't have to specify the

Re: Error: 'this' is only defined in non-static member functions

2017-11-23 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-23 01:35, Jonathan M Davis wrote: It would make sense with something like the nodes of a linked list if they needed access to the container for some reason. Pretty much any case where a an instance of a nested class is going to be associated with a specific instance of its parent

Re: GUI program on Mac OS in D?

2017-11-23 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-23 17:06, Adam D. Ruppe wrote: I know we have the extern(Objective-C) stuff from https://wiki.dlang.org/DIP43 now, but do we have existing bindings anywhere along the lines of the win32 ones we can just import and start calling the operating system functions? Not as far as I know.

Re: Instructions to build DMD from source don't work (anymore) here

2017-11-30 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-30 12:19, Basile B. wrote: That's strange because as said i had g++ / c++ but DMD compiles only once gcc-c++ setup. Anyway, working now. It should be possible to get which package the "g++" file belongs to [1]. [1]

Re: Shared and race conditions

2017-11-30 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-29 17:13, Wanderer wrote: I'm trying to simulate a race condition in D with the following code: I'm not sure what your end goal is but perhaps you could try to see if the LLVM thread sanitizer [1] can be used with LDC. The thread sanitizer can identify race conditions even though

Re: Instructions to build DMD from source don't work (anymore) here

2017-11-30 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-30 09:56, Basile B. wrote: On Thursday, 30 November 2017 at 08:38:15 UTC, Basile B. wrote: [...] All required tools are setup. I do not set AUTOBOOTSTRAP=1 since dmd 2.077 is setup. I needed gcc-c++... I don't know why but since "which g++" gave a valid file name i thought it was

Re: scope(exit) and Ctrl-C

2017-12-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-02 02:26, Adam D. Ruppe wrote: But this is intentional - there is no generic, reliable, cross-platform way of handling it natively. So you need to know the system and code it yourself. Not super hard but does take a bit of effort in your code. Since the "scope" block is not

Re: Object oriented programming and interfaces

2017-12-04 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-04 21:43, Dirk wrote: Hi! I defined an interface: interface Medoid {     float distance( Medoid other );     uint id() const @property; } and a class implementing that interface: class Item : Medoid {     float distance( Item i ) {...}     uint id() const @property {...} }

Re: gdc-6.3.0 on travis borked?

2017-12-01 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-01 07:20, Nick Sabalausky (Abscissa) wrote: When using gdc-6.3.0 on travis-ci, travis is reporting that it can't download the compiler: -- $ source "$(CURL_USER_AGENT="$CURL_USER_AGENT" bash install.sh gdc-6.3.0 --activate)"

Re: Passing anonymous enums as function parameters

2017-12-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-17 12:49, kerdemdemir wrote: I have an enum statement : enum : string {     KErdem     Ali     Zafer     Salih     //etc... } I don't want to give a name to my enum class since I am accessing this variables very often. But I also have a function like: double

Re: Dynamic Array reserve

2017-12-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-16 15:11, Vino wrote: Hi All,  Request your help on reserve an dynamic array when the capacity is reached to a point(eg: 80%) so the array to extend the reserve by next 20% Example: Array!string Test; Test. reserve(100) - Initall Test =(.) - The number of entries are

Re: GUI program on Mac OS in D?

2017-12-14 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-14 14:56, mrphobby wrote: Also, it feels a bit awkward to implement the callback handling methods as static methods, with the "self" and SEL arguments. Would have been nice if it was possible to use instance methods. That's currently not possible. The "self" and SEL arguments are

Re: GUI program on Mac OS in D?

2017-12-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-13 13:18, mrphobby wrote: I have been taking a look at your example. Looks pretty neat! Some advanced mixin stuff there that looks pretty useful. They're pretty basic ;) However, as far as I can tell there is no handling of retain/release. No, that's correct. How would you

Re: GUI program on Mac OS in D?

2017-12-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-13 16:07, Jacob Carlborg wrote: On 2017-12-13 13:18, mrphobby wrote: Would it be possible to somehow hook this up automatically to the D destructor perhaps? Interested in hearing your thoughts on this! As far as I know, the destructor is only called (automatically by the GC).

<    1   2   3   4   5   6   7   >