Hi,
There's issue in importing functions I came across some time ago
that I wonder if it is a purposeful design or if it is something
that will be changed in the future.
Say I have module like this:
```d
module funs;
double myfun(double x)
{
return x*x;
}
```
and I call `myfun` in a
On Friday, 4 June 2021 at 15:19:17 UTC, bachmeier wrote:
It requires an R package if you want to call D functions from
R. You need to link to R itself if you want to do something
like pass a vector from R to D and then access that data from
D. Since R is aware of the location of all the
On Wednesday, 2 June 2021 at 23:23:58 UTC, bachmeier wrote:
Are you aware of my embedr project, which handles all that for
you, and does a lot of other stuff?
https://embedr.netlify.app
If you want to do it yourself, you can see the boilerplate you
need to add to call a shared library from R
Doing `Runtime.initialize` is working with Julia but not yet R,
I'm getting a clock/GLIBC error
```
Error in dyn.load("rbasic.so") :
unable to load shared object 'code/rbasic.so':
lib/x86_64-linux-gnu/librt.so.1: undefined symbol:
__clock_nanosleep, version GLIBC_PRIVATE
```
do I need to
On Wednesday, 2 June 2021 at 17:49:49 UTC, Steven Schveighoffer
wrote:
What's happening is that the dynamic linker is trying to
resolve that symbol, but cannot find it in the given library.
Try `ldd code/rbasic.so` and see if it tells you the things it
is looking for. Many times, you will
Hi,
I'm getting an odd issue with ImportC when I import a header
converted with `gcc -E -P ...` some of the types signatures in
functions don't come through with their proper names but as
`__tagXX` where `XX` is some number. It's got to the point where
the type itself might get imported
On Sunday, 17 October 2021 at 04:45:26 UTC, data pulverizer wrote:
I ended up defining `typedef struct __float128__ {unsigned long
long x[2];} __float128__;` and doing a find and replace for
`__float128` which is totally overkill since I won't be using
it and according to the documentation,
I ended up defining `typedef struct __float128__ {unsigned long
long x[2];} __float128__;` and doing a find and replace for
`__float128` which is totally overkill since I won't be using it
and according to the documentation, the D compiler doesn't
support 128-bit floats yet though it has
On Saturday, 16 October 2021 at 08:19:41 UTC, rempas wrote:
On Saturday, 16 October 2021 at 07:09:16 UTC, jfondren wrote:
If I understand correctly you mean compile the original file
with gcc (`gcc test_og.c -o test_og.o`) and then link it with
DMD (`dmd test.d test_og.o`)? ...
While we're
Okay wow, this is amazing, I can now call R's standalone math
library `Rmath.h` by converting:
```
//r2d_con.c
#define __restrict restrict
#define __asm__ asm
#define __extension__
#define __inline
#define __builtin_bswap16
#define __builtin_bswap32
#define __builtin_bswap64
#define
On Sunday, 17 October 2021 at 10:46:30 UTC, data pulverizer wrote:
Okay wow, this is amazing, I can now call R's standalone math
library `Rmath.h` by converting ...
Sorry you don't need `-lRmath` so the initial call should be:
```
gcc -E -P -I"/usr/share/R/include" r2d_con.c > r2d.c
```
Okay I'm definitely trying to use `importC` rather than the
regular `extern(C)` way. I can see where I went wrong. The steps
for importC for header files are:
1. Prepend the following directives to `test_og.c` or whatever
your interface c script is:
```
#define __restrict restrict
#define
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
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
On Thursday, 21 October 2021 at 23:06:18 UTC, jfondren wrote:
On Thursday, 21 October 2021 at 22:23:50 UTC, data pulverizer
wrote:
I'd first check that the type names look OK in the processed C.
If they do, then it's an importc bug. Those are still getting
reported, but yours might be new.
On Friday, 31 December 2021 at 00:57:26 UTC, kdevel wrote:
```dptr.d
class R {
}
void foo (R r)
{
}
alias fn = void function (R);
void lyr (fn F) (R r)
{
}
immutable fn foo_ptr = // line 14
pragma (msg, typeof (foo_ptr));
auto ptr = lyr!(foo_ptr);// line 17
```
dmd reports:
```
On Tuesday, 28 December 2021 at 00:32:03 UTC, Paul Backus wrote:
The result of `.stringof` is completely implementation-defined,
may change arbitrarily between compiler releases, and is not
even guaranteed to be valid D code in the first place.
Wow, I didn't know this.
In this case, the
On Monday, 27 December 2021 at 21:31:03 UTC, Adam Ruppe wrote:
if you can paste teh code where you generate this I can prolly
show you a much easier way to do it. stringof sucks really hard.
Will the above `mixin` example suffice? It expands to the code
that I described.
On Monday, 27 December 2021 at 22:52:58 UTC, data pulverizer
wrote:
I think the only thing to do for now is probably for me to
construct a template that creates a proper string for this type.
It would look something like this:
```
enum safe_stringof(T) = T.stringof;
template safe_stringof(T:
On Monday, 27 December 2021 at 21:05:51 UTC, data pulverizer
wrote:
Hello, ...
... an equivalent mixin error would be
```
//...
alias DOUBLE = MyEnum.DOUBLE;
alias STRING = MyEnum.STRING;
alias INTEGER = MyEnum.INTEGER;
void main()
{
alias T = MyType!(INTEGER);
alias U =
On Tuesday, 28 December 2021 at 00:57:27 UTC, Paul Backus wrote:
```d
enum instantiate(string type, string expr) = type ~ "(" ~
expr ~ ")";
pragma(msg, instantiate!("RVector!(SEXPTYPE.REALSXP)", "x"));
```
One possibility is to generate a collection of compile time
strings that denote
On Monday, 27 December 2021 at 21:31:03 UTC, Adam Ruppe wrote:
if you can paste teh code where you generate this I can prolly
show you a much easier way to do it. stringof sucks really hard.
I think the only thing to do for now is probably for me to
construct a template that creates a proper
On Monday, 27 December 2021 at 23:04:40 UTC, Adam Ruppe wrote:
On Monday, 27 December 2021 at 21:21:30 UTC, data pulverizer
wrote:
alias T = MyType!(INTEGER);
What is MyType?
enum code = "writeln(\"instance: \", adder(" ~
T.stringof ~ "(), " ~ U.stringof ~ "()" ~ "));";
Hello,
I'm generating code using mixins and one of my mixins expands to
something like this:
```
adder(MyType!MyEnum.INTEGER(), MyType!MyEnum.STRING());
```
`MyType!MyEnum.STRING` is generated with `T.stringof `. I get the
error:
```
Error: template instance `MyType!(MyEnum)` does not
On Wednesday, 22 December 2021 at 16:01:49 UTC, rikki cattermole
wrote:
Seems to be working just fine as of 2.098.
```d
import std;
void main()
{
static foreach(Foo; ["Abc", "def"]) {{
string str = Foo;
writeln("Hello D ", str, __VERSION__);
}}
}
```
```
Hello D Abc2098
On Wednesday, 22 December 2021 at 16:10:42 UTC, Adam D Ruppe
wrote:
So OUTSIDE a function, static foreach() {{ }} is illegal
because a plain {} is illegal outside a function.
But INSIDE a function, static foreach() {{ }} is legal, but it
isn't magic about static foreach - it is just a body
Hi All,
I noticed that the double bracket `{{` for scoping `static
foreach` is no longer part of D and it looks like it has been
replaced with
https://dlang.org/changelog/2.098.0.html#AliasAssign. Could
someone confirm this with a link to the DIP and any other tools
that we should be using
Hi,
I am trying to compile the following items:
```
import std.bitmanip: bitfields;
enum TYPE_BITS = 5;
enum NAMED_BITS = 16;
struct sxpinfo_struct {
mixin(bitfields!(
SEXPTYPE, "type", TYPE_BITS,
uint, "scalar", 1,
uint, "obj", 1,
uint, "alt", 1,
uint,
On Thursday, 28 October 2021 at 05:51:27 UTC, Imperatorn wrote:
Try renaming debug to something else
Many thanks guys. I should have spotted that one!
On Thursday, 28 October 2021 at 05:20:35 UTC, data pulverizer
wrote:
Hi,
I am trying to compile the following items ...
Sorry forgot to prepend:
```
enum SEXPTYPE
{
NILSXP = 0,
SYMSXP = 1,
LISTSXP = 2,
CLOSXP = 3,
ENVSXP = 4,
PROMSXP = 5,
LANGSXP = 6,
SPECIALSXP = 7,
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.
Hi,
It looks to me like `A*[]` would require extra allocation of
memory and `ref` would not, am I wrong? If so it may be something
to consider if relevant for your application.
Thanks.
On Sunday, 31 October 2021 at 18:51:09 UTC, user1234 wrote:
To me it is the right answer. Maybe that OP wanted the
TemplateType parameter to be implicitly added (and that's why
Ali interpreted the question as a language proposal)?
Ah, I see. Interesting proposal.
On Sunday, 31 October 2021 at 17:35:35 UTC, Ali Çehreli wrote:
On 10/31/21 7:07 AM, Salih Dincer wrote:
> ```d
> auto foo(int value, auto s = Section(2, 60)) {
> int max; /* ^--- ?
> ...*/
> return Section (0, max)
> }
> ```
> Is possible something like above
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_ =
Hello all,
I'm not sure how to set the compile time parameters in D's SQLite
module particular the items that take multiple parameters, for
example in the C API manual `SQLITE_CONFIG_MMAP_SIZE` takes two
`sqlite3_int64`. How do I set these? Do I just write something
like
```
enum
On Tuesday, 1 March 2022 at 20:59:46 UTC, data pulverizer wrote:
Hello all,
I'm not sure how to set the compile time parameters in D's
SQLite module particular the items that take multiple
parameters, for example in the C API manual
`SQLITE_CONFIG_MMAP_SIZE` takes two `sqlite3_int64`. How do
On Thursday, 21 April 2022 at 03:59:26 UTC, Steven Schveighoffer
wrote:
OK, so reviewing with that in mind, it looks like you're trying
to import `myPackage.modules.mymodule`, but the file
`../myPackageName/source/myPackageName/modules/mymodule.d`
doesn't exist.
Is there one too many
On Thursday, 21 April 2022 at 00:14:16 UTC, Steven Schveighoffer
wrote:
Did you substitute something real with `...` to hide it from
your post? Because that's not a real path.
I used it to hide my actual paths.
Hi all,
I'm trying to import a local dub package into a dub project
(`json` format). I have added the package I'm trying to import
with `dub add-local` and `dub add-path` and including it within
the json file, but I get the error
```
$ dub build
Performing "debug" build using
Hi all,
I am calling code from a C API, and would like to know how to
catch exit errors so that they can be handled and make them more
like an exceptions so that the computation can continue. I've
tried something similar to what is outlined here:
https://dlang.org/phobos/object.html#.Error
On Wednesday, 19 October 2022 at 14:05:35 UTC, data pulverizer
wrote:
Hi all,
I am calling code from a C API, and would like to know how to
catch exit errors so that they can be handled and make them
more like an exceptions so that the computation can continue.
I've tried something similar
On Thursday, 20 October 2022 at 13:02:52 UTC, bachmeier wrote:
I've done an initial release of the second version:
https://github.com/bachmeil/embedrv2
The two biggest changes are
- Moving to Dub as the default for compilation, which allows
the use of any other Dub libraries
- It writes the
On Thursday, 20 October 2022 at 10:13:41 UTC, Sergey wrote:
On Thursday, 20 October 2022 at 09:52:05 UTC, data pulverizer
wrote:
I'm currently writing a D interop with R, the dynamic
statistical programming language. There's a function called
How is your project related to EmbedR?
The
On Wednesday, 19 October 2022 at 16:48:10 UTC, Ali Çehreli wrote:
On 10/19/22 07:05, data pulverizer wrote:
> I am calling code from a C API, and would like to know how to
catch exit
> errors
If you are talking about the exit() Posix function, you can't
do anything about that because its
On Thursday, 20 October 2022 at 12:14:38 UTC, jmh530 wrote:
On Thursday, 20 October 2022 at 11:59:45 UTC, data pulverizer
wrote:
[snip]
Mine is also private for now till it reaches an acceptable
state when I'll think about whether it should be publicly
released or jealously guarded. It's a
On Monday, 3 October 2022 at 11:08:00 UTC, Steven Schveighoffer
wrote:
On 10/2/22 12:21 PM, data pulverizer wrote:
I've noticed that `writeln` calls the destructor of a struct
multiple times and would like to know how to stop this from
happening. It has become a very serious problem when
On Sunday, 2 October 2022 at 16:44:25 UTC, Paul Backus wrote:
It's because `writeln` is copying the object, and each of the
copies is being destroyed. If you add a copy constructor to
your example, you can see it happening:
...
I thought something like this could be happening in my original
On Sunday, 2 October 2022 at 17:19:55 UTC, data pulverizer wrote:
Any reason why this could be?
Sorry I'll need to implement all the overloaded copy constructors
and see if that fixes it.
On Sunday, 2 October 2022 at 17:51:59 UTC, Ali Çehreli wrote:
What I noticed first in your original code was that it would be
considered buggy because it was not considering copying. Every
struct that does something in its destructor should either have
post-blit (or copy constructor) defined
On Sunday, 2 October 2022 at 18:24:51 UTC, Ali Çehreli wrote:
I've just tested. That is used only for explicit constructor
syntax ...
Many thanks. Knowledgeable as always!
On Sunday, 2 October 2022 at 17:28:51 UTC, data pulverizer wrote:
Sorry I'll need to implement all the overloaded copy
constructors and see if that fixes it.
I've got it, something weird happened to my copy constructor.
This was my original attempt and was ignored (didn't run in the
copy
I've noticed that `writeln` calls the destructor of a struct
multiple times and would like to know how to stop this from
happening. It has become a very serious problem when working with
objects that have memory management external to D.
Here is a repeatable example, where the destructor
201 - 253 of 253 matches
Mail list logo