Jupyter notebook with Dlang

2020-04-29 Thread Jan Hönig via Digitalmars-d-learn
Today I have been toying around with jupyter. I wanted to know how it works (since I use it with Python all the time). I was trying to couple xeus[3] with drepl[4] together. But now (after using google and not duckduckgo), I have found multiple projects, which attempted similar things. It

Re: Can’t use UFCS to create InputRange?

2020-04-29 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 12:23:11 UTC, Simen Kjærås wrote: Of course, nothing stops us from defining our own front, popFront and friends that combine the two approaches above: [...] We could conceivably add these to std.range.primitives (probably adding some constraints first), and

Re: Compililng C++ and D together without going mad

2020-04-29 Thread Johan via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 13:02:36 UTC, Jan Hönig wrote: On Wednesday, 29 April 2020 at 11:38:16 UTC, Johan wrote: LDC is a (somewhat complex) project with D and C++ code (and external C++ libraries). I think it will help you if your main() is in D (such that druntime is automatically

Re: Building Win32 application via dub

2020-04-29 Thread Sam E. via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 12:26:02 UTC, Mike Parker wrote: On Wednesday, 29 April 2020 at 11:55:54 UTC, Sam E. wrote: I cannot find a D example using Win32 and the normal main function, and while it is working for simple message boxes, as soon as I want to do something slightly more

Re: Compililng C++ and D together without going mad

2020-04-29 Thread Jan Hönig via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 13:12:50 UTC, Johan wrote: Manually initializing D's runtime is also possible. You need to call rt_init and rt_term: https://dlang.org/phobos/core_runtime.html#.rt_init What I meant is to - add a `int main()` in a D source file - rename your current `main`

date and timestamp

2020-04-29 Thread guai via Digitalmars-d-learn
Hi, forum I have two questions: 1) Why __DATE__ and __TIMESTAMP__ have these insane formats? "mmm dd " and "www mmm dd hh:mm:ss " I think its the first time in my life I encounter something like this. start with date, then print time, then the rest of the date - what? 2) Are those

Re: Compililng C++ and D together without going mad

2020-04-29 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 10:25:31 UTC, Jan Hönig wrote: In my pet project, I am using some C++ libraries. The main file/function is also C++. All of it successfully compiles with cmake. Now I want to add some functionality by calling my own D functions (which use some other

Can't recreate a range?

2020-04-29 Thread Casey via Digitalmars-d-learn
So, I'm trying to run some tests and I had code that looks similar to this: unittest { auto range = readStream(File("test_data/multiple.xml").byLine); int count = 0; while (!range.empty) { count++; range.popFront(); }

Re: Can't recreate a range?

2020-04-29 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 20:43:20 UTC, Casey wrote: So, I'm trying to run some tests and I had code that looks similar to this: [...] I feel like I'm missing something obscure and it's driving me a bit batty. Any clue as to why this is happening? I'd like to not have to worry

Re: Can't recreate a range?

2020-04-29 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 20:43:20 UTC, Casey wrote: void popFront() { } I mean, it might be you messed up in posting this, but having an empty popFront and expecting it to do something is a tad optimistic. Apart from that, it seems like

Re: Building Win32 application via dub

2020-04-29 Thread Sam E. via Digitalmars-d-learn
On Tuesday, 28 April 2020 at 20:18:29 UTC, Adam D. Ruppe wrote: On Tuesday, 28 April 2020 at 19:25:06 UTC, Sam E. wrote: I'm a bit surprised to see a linking error given that building directly from `dmd` seems to work fine without any flag. dmd directly uses -m32 whereas dub by default uses

Re: GtkD - how to list 0..100K strings

2020-04-29 Thread mark via Digitalmars-d-learn
Continuing this in the GtkD mailing list: https://forum.gtkd.org/groups/GtkD/thread/1370/

Re: Can’t use UFCS to create InputRange?

2020-04-29 Thread user1234 via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 08:34:53 UTC, Ogi wrote: struct R {} int front(R r) { return 42; } void popFront(R r) {} bool empty(R r) { return false; } void main() { import std.range.primitives : isInputRange; static assert(isInputRange!R); } Error: static assert:

Can’t use UFCS to create InputRange?

2020-04-29 Thread Ogi via Digitalmars-d-learn
struct R {} int front(R r) { return 42; } void popFront(R r) {} bool empty(R r) { return false; } void main() { import std.range.primitives : isInputRange; static assert(isInputRange!R); } Error: static assert: `isInputRange!(R)` is false Whats really weird is that if I replace

Re: Can’t use UFCS to create InputRange?

2020-04-29 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 08:34:53 UTC, Ogi wrote: struct R {} int front(R r) { return 42; } void popFront(R r) {} bool empty(R r) { return false; } void main() { import std.range.primitives : isInputRange; static assert(isInputRange!R); } Error: static assert:

Re: date and timestamp

2020-04-29 Thread wolframw via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 22:22:04 UTC, guai wrote: Hi, forum I have two questions: 1) Why __DATE__ and __TIMESTAMP__ have these insane formats? "mmm dd " and "www mmm dd hh:mm:ss " I think its the first time in my life I encounter something like this. start with date, then print

Re: Compililng C++ and D together without going mad

2020-04-29 Thread Jan Hönig via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 11:38:16 UTC, Johan wrote: LDC is a (somewhat complex) project with D and C++ code (and external C++ libraries). I think it will help you if your main() is in D (such that druntime is automatically initialized for you). https://github.com/ldc-developers/ldc

Re: Compililng C++ and D together without going mad

2020-04-29 Thread Jan Hönig via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 13:02:36 UTC, Jan Hönig wrote: I will probably need: Also this thing: https://github.com/nlohmann/json

Re: Building Win32 application via dub

2020-04-29 Thread Sam E. via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 10:26:40 UTC, Sam E. wrote: Really, there's no reason at all to use WinMain. Just create a standard main function. Then you don't need to worry about manually initializing the runtime and you'll have a console window by default. You can always turn it off in

Re: Compililng C++ and D together without going mad

2020-04-29 Thread Johan via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 10:25:31 UTC, Jan Hönig wrote: In my pet project, I am using some C++ libraries. The main file/function is also C++. All of it successfully compiles with cmake. Now I want to add some functionality by calling my own D functions (which use some other

Re: Can’t use UFCS to create InputRange?

2020-04-29 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 09:16:58 UTC, user1234 wrote: The static checker doesn't see your free funcs because to do so it would have to import the whole module. (is it possible to do that ? no idea.) Of course it's possible! :) We can find the context of R (in this case, the module)

Re: Building Win32 application via dub

2020-04-29 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 11:55:54 UTC, Sam E. wrote: On Wednesday, 29 April 2020 at 10:46:30 UTC, Mike Parker wrote: On Wednesday, 29 April 2020 at 10:44:48 UTC, Mike Parker wrote: Yeah, it says "WinMain is needed", which has never been true. THere's no need for the def file either.

Re: Building Win32 application via dub

2020-04-29 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 11:55:54 UTC, Sam E. wrote: I cannot find a D example using Win32 and the normal main function, and while it is working for simple message boxes, as soon as I want to do something slightly more complex (using a window), an hInstance has to be provided (as far

Re: Building Win32 application via dub

2020-04-29 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 09:43:53 UTC, Sam E. wrote: Though the program built with dub is now crashing at runtime when calling `writeln` within the `WinMain` block. The exception error is: Exception has occurred: W32/0xc096 Unhandled exception at 0x7FF643C5AFE4 in

Re: Building Win32 application via dub

2020-04-29 Thread rikki cattermole via Digitalmars-d-learn
On 29/04/2020 10:27 PM, Sam E. wrote: To be honest, I haven't yet found the way to switch between -m32 and -m64 (or other) via dub :) $ dub build --arch=x86 $ dub build --arch=x86_64

Re: Building Win32 application via dub

2020-04-29 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 10:26:40 UTC, Sam E. wrote: I took the WinMain from https://wiki.dlang.org/D_for_Win32, should that documentation be updated to use a normal main function instead? Also the details regarding linker flags may be a good addition to that wiki page. Yeah, it

Re: Building Win32 application via dub

2020-04-29 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 10:27:35 UTC, Sam E. wrote: To be honest, I haven't yet found the way to switch between -m32 and -m64 (or other) via dub :) Pass the -a flag on the dub command line with the appropriate argument: For -m32: -ax86 For -m32mscoff: -ax86_mscoff For -m64:

Re: Building Win32 application via dub

2020-04-29 Thread Ahmet Sait via Digitalmars-d-learn
Though the program built with dub is now crashing at runtime when calling `writeln` within the `WinMain` block. Back then when I was trying to use writeln (or any standard output function like printf)in a non-console app in Windows it used to crash, I don't know exact reason behind it but you

Compililng C++ and D together without going mad

2020-04-29 Thread Jan Hönig via Digitalmars-d-learn
In my pet project, I am using some C++ libraries. The main file/function is also C++. All of it successfully compiles with cmake. Now I want to add some functionality by calling my own D functions (which use some other modules/projects/phobos). My questions is, what is the "proper" building

Re: Building Win32 application via dub

2020-04-29 Thread Sam E. via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 10:19:39 UTC, Ahmet Sait wrote: Though the program built with dub is now crashing at runtime when calling `writeln` within the `WinMain` block. Back then when I was trying to use writeln (or any standard output function like printf)in a non-console app in

Re: Building Win32 application via dub

2020-04-29 Thread Sam E. via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 10:12:29 UTC, Mike Parker wrote: Most likely because you're calling writeln before initializing the runtime. Of course, that was it, thanks for the help Mike! Also, when using WinMain, you aren't going to see any output from writeln because you won't have a

Re: Building Win32 application via dub

2020-04-29 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 10:44:48 UTC, Mike Parker wrote: On Wednesday, 29 April 2020 at 10:26:40 UTC, Sam E. wrote: I took the WinMain from https://wiki.dlang.org/D_for_Win32, should that documentation be updated to use a normal main function instead? Also the details regarding

Re: Building Win32 application via dub

2020-04-29 Thread Sam E. via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 10:46:30 UTC, Mike Parker wrote: On Wednesday, 29 April 2020 at 10:44:48 UTC, Mike Parker wrote: Yeah, it says "WinMain is needed", which has never been true. THere's no need for the def file either. What's the way to get the hInstance without the use of