Re: Contributing CDF bindings to Deimos

2021-03-24 Thread Chris Piker via Digitalmars-d-learn

On Tuesday, 23 March 2021 at 05:54:13 UTC, mw wrote:

On Tuesday, 23 March 2021 at 05:34:57 UTC, Chris Piker wrote:

Create a github repo, and create an account on:

https://code.dlang.org/

Then you can register your project there, and supported by dub 
build.


Okay, that's done.

The repo https://github.com/das-developers/deimos.cdf and package 
https://code.dlang.org/packages/cdf have been drafted and tested 
on Linux, I'm about to test on Windows and MacOS.  As an aside, 
software developers at NASA Goddard have now heard of D which is 
nice.  They were pleased to see that it was supported by gcc. 
(Hat tip to the GDC team)


I've attempted to follow all guidelines as best I understood 
them, but this is my first package.  It likely has some style and 
functionality issues.  Is there a peer review stage to this 
process that is triggered automatically or could be requested?




Re: Using onOutOfMemoryError in C wrappers

2021-03-24 Thread Per Nordlöw via Digitalmars-d-learn

On Wednesday, 24 March 2021 at 10:25:21 UTC, Basile B. wrote:
In now way. But in your question you mentioned @nogc nothrow 
and not @safe and pure.


Ok, thanks.

Note that core.exception.onOutOfMemoryError is already qualified 
as @nogc nothrow pure @trusted.


Re: Using onOutOfMemoryError in C wrappers

2021-03-24 Thread Jack via Digitalmars-d-learn

On Wednesday, 24 March 2021 at 08:31:19 UTC, Basile B. wrote:

On Wednesday, 24 March 2021 at 07:58:22 UTC, Per Nordlöw wrote:
When wrapping C code that tries to allocate memory resources 
via functions such as


X* X_create();

should one call `onOutOfMemoryError();` upon null return?

Making more D wrappers `nothrow @nogc`.



There are several ways to do that. In addition to 
onOutOfMemoryError, you can use a static instance or `if 
(somePtr is null) assert(0);`


  void v() @nogc nothrow
  {
__gshared oom = new OutOfMemoryError();
auto X* = X_create();
if (X is null)
throw oom;
  }


why are you creating oom variable before the if(x is null) check?


Re: Using onOutOfMemoryError in C wrappers

2021-03-24 Thread Basile B. via Digitalmars-d-learn

On Wednesday, 24 March 2021 at 08:51:34 UTC, Per Nordlöw wrote:

On Wednesday, 24 March 2021 at 08:31:19 UTC, Basile B. wrote:
There are several ways to do that. In addition to 
onOutOfMemoryError, you can use a static instance


  void v() @nogc nothrow
  {
__gshared oom = new OutOfMemoryError();
auto X* = X_create();
if (X is null)
throw oom;
  }


How is that better than

void v() @nogc nothrow
{
auto X* = X_create();
if (X is null)
onOutOfMemoryError();
}

considering the fact that accessing `__gshared` state is 
neither `@safe` nor `pure`? Which, in turn, makes `v()` 
unconditionally unsafe and unpure regardless of safety and 
purity of `X_create()`.


In now way. But in your question you mentioned @nogc nothrow and 
not @safe and pure.


Re: Using onOutOfMemoryError in C wrappers

2021-03-24 Thread Per Nordlöw via Digitalmars-d-learn

On Wednesday, 24 March 2021 at 08:31:19 UTC, Basile B. wrote:
There are several ways to do that. In addition to 
onOutOfMemoryError, you can use a static instance


  void v() @nogc nothrow
  {
__gshared oom = new OutOfMemoryError();
auto X* = X_create();
if (X is null)
throw oom;
  }


How is that better than

void v() @nogc nothrow
{
auto X* = X_create();
if (X is null)
onOutOfMemoryError();
}

considering the fact that accessing `__gshared` state is neither 
`@safe` nor `pure`? Which, in turn, makes `v()` unconditionally 
unsafe and unpure regardless of safety and purity of `X_create()`.


Re: Using onOutOfMemoryError in C wrappers

2021-03-24 Thread Basile B. via Digitalmars-d-learn

On Wednesday, 24 March 2021 at 07:58:22 UTC, Per Nordlöw wrote:
When wrapping C code that tries to allocate memory resources 
via functions such as


X* X_create();

should one call `onOutOfMemoryError();` upon null return?

Making more D wrappers `nothrow @nogc`.



There are several ways to do that. In addition to 
onOutOfMemoryError, you can use a static instance or `if (somePtr 
is null) assert(0);`


  void v() @nogc nothrow
  {
__gshared oom = new OutOfMemoryError();
auto X* = X_create();
if (X is null)
throw oom;
  }


Using onOutOfMemoryError in C wrappers

2021-03-24 Thread Per Nordlöw via Digitalmars-d-learn
When wrapping C code that tries to allocate memory resources via 
functions such as


X* X_create();

should one call `onOutOfMemoryError();` upon null return?

Making more D wrappers `nothrow @nogc`.