Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 13:06:37 UTC, drug wrote: On 12/23/20 3:23 PM, Godnyx wrote: Any ideas? Just fix your typos: ```D import std : printf, toStringz; void put(A...)(string prompt, A args) { static foreach (ulong i; 0..args.length) { static if (is(typeof(args[i]) ==

Re: C++ or D?

2020-12-23 Thread evilrat via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 18:03:56 UTC, frame wrote: It's not the problem mentioned but I had to struggle with DLLs and D's Variant-type. The problem is that Variant uses TypeInfo which does not pass DLL boundaries correctly so that int != int in runtime even it's in fact a simple int

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 13:55:20 UTC, Adam D. Ruppe wrote: On Wednesday, 23 December 2020 at 13:06:37 UTC, drug wrote: static foreach (ulong i; 0..args.length) { static if (is(typeof(args[i]) == string)) printf("%s\n", args[i].toStringz); static if (is(t

Re: C++ or D?

2020-12-23 Thread frame via Digitalmars-d-learn
On Saturday, 19 December 2020 at 09:06:33 UTC, Godnyx wrote: Hi! Can you be more specific about the problems someone is gonna face with D that can't be fixed? This is very important for me because I'm planning to use D for development in the near (I wish near) future and I want to know what's g

Re: Slice allocation after appending

2020-12-23 Thread Ali Çehreli via Digitalmars-d-learn
On 12/23/20 8:14 AM, frame wrote: > That implementation > can become very handy for some situations but for this simple case > > foreach (arr; [a, b]) { .. } > > would also work. Absolutely. > The difference is that the foreach loop is happen at > runtime and will not compiled as multiple lines

Re: Getting started with graphqld

2020-12-23 Thread aberba via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 08:33:21 UTC, Trustee wrote: On Tuesday, 22 December 2020 at 23:49:12 UTC, aberba wrote: On Friday, 18 December 2020 at 03:36:05 UTC, Trustee wrote: [...] Heres's a demo I put together https://github.com/aberba/graphqld-demo A minimal example with only the

Re: Slice allocation after appending

2020-12-23 Thread frame via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 11:19:38 UTC, Rekel wrote: I'm not sure what your aliasSeq does, sadly I don't find the documentation's explanation satisfactory. Try to write static foreach (arr; [a, b]) { .. } - it will not work because that loop is generated at compile time (static). It

Re: Slice allocation after appending

2020-12-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/22/20 5:12 PM, Rekel wrote: According to the D slice article (https://dlang.org/articles/d-array-article.html), slices do not care where they start, only where they end, when checking whether expanding in place is permitable, or at least that is what I understood regarding it. Now I'm u

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 13:06:37 UTC, drug wrote: static foreach (ulong i; 0..args.length) { static if (is(typeof(args[i]) == string)) printf("%s\n", args[i].toStringz); static if (is(typeof(args[i]) == int)) Putting some `else` in there would help too

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread drug via Digitalmars-d-learn
On 12/23/20 3:23 PM, Godnyx wrote: Any ideas? Just fix your typos: ```D import std : printf, toStringz; void put(A...)(string prompt, A args) { static foreach (ulong i; 0..args.length) { static if (is(typeof(args[i]) == string)) printf("%s\n", args[i].toStringz);

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 09:42:42 UTC, Ferhat Kurtulmuş wrote: On Wednesday, 23 December 2020 at 09:40:27 UTC, Ferhat Kurtulmuş wrote: On Wednesday, 23 December 2020 at 09:06:02 UTC, Godnyx wrote: [...] I didn't dive into your use case, but you should use static foreach in this case

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 09:50:03 UTC, Ali Çehreli wrote: On 12/23/20 1:06 AM, Godnyx wrote: > for (ulong i = 0; i < args.length; i++) { > if (typeof(args[i]).stringof == "string") > printf("%s\n", args[i].toStringz); > } I replaced for with foreach and

Re: Slice allocation after appending

2020-12-23 Thread Rekel via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 04:03:37 UTC, Ali Çehreli wrote: It is valid. One can always copy the small array before appending to it and the large array would be preserved. Try the -profile command line switch when compiling your program and it will show where memory allocations occur.

Re: Why is (int[int] s = int[int].init) not allowed

2020-12-23 Thread Andre Pany via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 07:08:31 UTC, Daniel Kozak wrote: Dne st 23. 12. 2020 1:00 uživatel Steven Schveighoffer via Digitalmars-d-learn napsal: On 12/22/20 5:44 PM, Daniel Kozak wrote: > [...] Yeah: void sample_valid(int[int] s = null) -Steve Yes AA.init is null per doc. htt

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Ali Çehreli via Digitalmars-d-learn
On 12/23/20 1:06 AM, Godnyx wrote: > for (ulong i = 0; i < args.length; i++) { > if (typeof(args[i]).stringof == "string") > printf("%s\n", args[i].toStringz); > } I replaced for with foreach and it worked (and I passed "prompt"). static foreach would work as wel

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 09:40:27 UTC, Ferhat Kurtulmuş wrote: On Wednesday, 23 December 2020 at 09:06:02 UTC, Godnyx wrote: [...] I didn't dive into your use case, but you should use static foreach in this case: void put(A...)(string prompt, A args) { static foreach (ulong i;

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 09:06:02 UTC, Godnyx wrote: On Wednesday, 23 December 2020 at 08:50:50 UTC, Mike Parker wrote: On Wednesday, 23 December 2020 at 08:45:15 UTC, Godnyx wrote: Yep and I find it out! It won't work with templates and/or variadic function parameters. It says that t

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 08:50:50 UTC, Mike Parker wrote: On Wednesday, 23 December 2020 at 08:45:15 UTC, Godnyx wrote: Yep and I find it out! It won't work with templates and/or variadic function parameters. It says that the variable can't be read at compile time (so I can't cast it)

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 08:45:15 UTC, Godnyx wrote: Yep and I find it out! It won't work with templates and/or variadic function parameters. It says that the variable can't be read at compile time (so I can't cast it) or it will work but it will give me a segmentation fault (lol hell

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
On Wednesday, 23 December 2020 at 04:02:54 UTC, Paul Backus wrote: On Tuesday, 22 December 2020 at 21:26:37 UTC, Godnyx wrote: On Tuesday, 22 December 2020 at 21:10:59 UTC, Godnyx wrote: Is there a way? If not then how std.stdio does it? I should mention that I want to use it in a variable th

Re: Can I output strings using core.stdc.stdio?

2020-12-23 Thread Godnyx via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 21:40:15 UTC, Dave P. wrote: On Tuesday, 22 December 2020 at 21:37:23 UTC, Godnyx wrote: On Tuesday, 22 December 2020 at 21:28:10 UTC, Dave P. wrote: On Tuesday, 22 December 2020 at 21:10:59 UTC, Godnyx wrote: [...] Lol. Actually I just don't want to use Phobos

Re: Getting started with graphqld

2020-12-23 Thread Trustee via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 23:49:12 UTC, aberba wrote: On Friday, 18 December 2020 at 03:36:05 UTC, Trustee wrote: On Thursday, 17 December 2020 at 14:49:42 UTC, evilrat wrote: On Tuesday, 15 December 2020 at 16:25:29 UTC, Trustee wrote: connect a basic vibe-d app to a graphql backend.