Re: Can we use "ImportC" used yet?

2021-10-23 Thread data pulverizer via Digitalmars-d-learn
On Sunday, 24 October 2021 at 05:54:43 UTC, data pulverizer wrote: Actually it's more complicated than that. On construction I do need to call `protect` and call `unprotect` or `unprotect_ptr` when the function in which the object is created returns. At the moment, I'm not even sure (or more l

Re: Can we use "ImportC" used yet?

2021-10-23 Thread data pulverizer via Digitalmars-d-learn
On Saturday, 23 October 2021 at 17:42:32 UTC, data pulverizer wrote: On Saturday, 23 October 2021 at 16:39:08 UTC, data pulverizer wrote: ``` ... this(R_xlen_t n) { SEXPTYPE _real_ = SEXPTYPE.REALSXP; _data = protect(allocVector(_real_, n)); unprotect(1); } ... ``` Looking at t

Are there anything like leetcode.com but that supports D?

2021-10-23 Thread Dr Machine Code via Digitalmars-d-learn
I'd like that to some friends getting start with programming. Sadly that platform doesn't support D.

Re: How can I check a newly set ref value

2021-10-23 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 23 October 2021 at 20:14:25 UTC, solidstate1991 wrote: If I wanted to check whether the assigned value is within a range, and I want to throw a certain exception if outside of it, then how I can do that? You can't with ref, you will need to do separate getter and setter propertie

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Tim via Digitalmars-d-learn
On Saturday, 23 October 2021 at 19:52:19 UTC, Simon wrote: Thanks for putting up with me! I tried a bunch and it seems like I left out too much code, because I can't get it working 100%. I didn't even know about the q{} syntax, so I didn't think the stuff I left out would matter, but when usi

How can I check a newly set ref value

2021-10-23 Thread solidstate1991 via Digitalmars-d-learn
Let's say I have something like this: ``` struct Foo { int[] bar; this() { bar.length = 10; } ref int opIndex(size_t i) { return bar[i]; } } void main() { Foo f = Foo(); f[3] = 15; } ``` If I wanted to check whether the assigned value is within a rang

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 23 October 2021 at 18:23:47 UTC, Simon wrote: For debugging purposes, I have built a mixin that will, when declared inside a function, output code to the console that will reproduce the exact function call. Sounds like what you really want is https://github.com/dlang/dmd/pull/130

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Simon via Digitalmars-d-learn
On Saturday, 23 October 2021 at 19:03:41 UTC, Tim wrote: On Saturday, 23 October 2021 at 18:56:48 UTC, Simon wrote: And I tried to use your suggestion like this: enum OUTPUT_REPRO_CASE(alias func = __traits(parent, {})) = "build the actual code stuff with"~fullyQualifiedName!func~" and so on"

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Tim via Digitalmars-d-learn
On Saturday, 23 October 2021 at 18:56:48 UTC, Simon wrote: And I tried to use your suggestion like this: enum OUTPUT_REPRO_CASE(alias func = __traits(parent, {})) = "build the actual code stuff with"~fullyQualifiedName!func~" and so on"; Which doesn't work. In that case func seems to become

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Simon via Digitalmars-d-learn
On Saturday, 23 October 2021 at 18:36:27 UTC, Tim wrote: On Saturday, 23 October 2021 at 18:23:47 UTC, Simon wrote: So what I am looking for then is the equivalent to __FUNCTION__ that evaluates to the actual symbol of the function instead of its name, so it can be used as a parameter to Param

Re: Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Tim via Digitalmars-d-learn
On Saturday, 23 October 2021 at 18:23:47 UTC, Simon wrote: So what I am looking for then is the equivalent to __FUNCTION__ that evaluates to the actual symbol of the function instead of its name, so it can be used as a parameter to ParameterIdentifierTuple. You could use the following: alias

Is there an alternative to "__FUNCTION__" that gives the actual function symbol and not the name as a string?

2021-10-23 Thread Simon via Digitalmars-d-learn
For debugging purposes, I have built a mixin that will, when declared inside a function, output code to the console that will reproduce the exact function call. So, as an example, for the following function int reproducible_function(int a, int b){ mixin(OUTPUT_REPRO_CASE!reproducible_functio

Re: Can we use "ImportC" used yet?

2021-10-23 Thread data pulverizer via Digitalmars-d-learn
On Saturday, 23 October 2021 at 16:39:08 UTC, data pulverizer wrote: ``` ... this(R_xlen_t n) { SEXPTYPE _real_ = SEXPTYPE.REALSXP; _data = protect(allocVector(_real_, n)); unprotect(1); } ... ``` Looking at that code, I realise didn't need the un/protect.

Re: Can we use "ImportC" used yet?

2021-10-23 Thread data pulverizer via Digitalmars-d-learn
On Friday, 22 October 2021 at 16:16:22 UTC, Dave P. wrote: I think you ran into this [issue](https://issues.dlang.org/show_bug.cgi?id=22404). The bug fix isn’t part of a released dmd yet. Yes that's the same error. When I try this: ``` ... this(R_xlen_t n) { SEXPTYPE _real_ = SEXPTYPE

Re: Vibe tutorial

2021-10-23 Thread Tejas via Digitalmars-d-learn
On Saturday, 23 October 2021 at 14:28:14 UTC, Imperatorn wrote: On Saturday, 23 October 2021 at 08:41:35 UTC, Imperatorn wrote: I think I shared this earlier, but I'm unsure if I got the link right: https://github.com/reyvaleza/vibed/blob/main/BuildWebAppsinVibe.pdf A vibe.d tutorial pdf To

Re: Vibe tutorial

2021-10-23 Thread Imperatorn via Digitalmars-d-learn
On Saturday, 23 October 2021 at 08:41:35 UTC, Imperatorn wrote: I think I shared this earlier, but I'm unsure if I got the link right: https://github.com/reyvaleza/vibed/blob/main/BuildWebAppsinVibe.pdf A vibe.d tutorial pdf To summarize, this should work: https://github.com/reyvaleza/vibed/

Re: Vibe tutorial

2021-10-23 Thread Imperatorn via Digitalmars-d-learn
On Saturday, 23 October 2021 at 13:37:19 UTC, Tejas wrote: On Saturday, 23 October 2021 at 08:41:35 UTC, Imperatorn wrote: I think I shared this earlier, but I'm unsure if I got the link right: https://github.com/reyvaleza/vibed/blob/main/BuildWebAppsinVibe.pdf A vibe.d tutorial pdf For som

Re: Vibe tutorial

2021-10-23 Thread Tejas via Digitalmars-d-learn
On Saturday, 23 October 2021 at 08:41:35 UTC, Imperatorn wrote: I think I shared this earlier, but I'm unsure if I got the link right: https://github.com/reyvaleza/vibed/blob/main/BuildWebAppsinVibe.pdf A vibe.d tutorial pdf For some very strange reason, it says __invalid format__ when you

Re: std.zip expand: memory allocation failed

2021-10-23 Thread Selim Ozel via Digitalmars-d-learn
Did you try the MmFile workaround? I did. I also pinpointed the problem, I use x86_mscoff to run dub and it's specific to that architecture selection. It's related to MapViewOfFileEx [1]. I still haven't found a way around it though. [1] https://stackoverflow.com/questions/12121843/mapview

Vibe tutorial

2021-10-23 Thread Imperatorn via Digitalmars-d-learn
I think I shared this earlier, but I'm unsure if I got the link right: https://github.com/reyvaleza/vibed/blob/main/BuildWebAppsinVibe.pdf A vibe.d tutorial pdf

Re: Dub failing to use the linker correctly.

2021-10-23 Thread Imperatorn via Digitalmars-d-learn
On Saturday, 23 October 2021 at 00:54:17 UTC, Ruby The Roobster wrote: On Friday, 22 October 2021 at 21:57:02 UTC, Ruby The Roobster wrote: On Friday, 22 October 2021 at 21:21:41 UTC, jfondren wrote: On Friday, 22 October 2021 at 19:56:37 UTC, Ruby The Roobster wrote: I have a simple vibe-d pro