Re: Accessing members through pointers to structs (also, CTFE associative arrays)

2016-12-17 Thread Ali via Digitalmars-d-learn

On Friday, 16 December 2016 at 01:48:59 UTC, Ali Çehreli wrote:

On 12/15/2016 05:30 PM, Stefan Koch wrote:
On Thursday, 15 December 2016 at 19:30:08 UTC, Ali Çehreli 
wrote:


Yeah, I think the compiler is confused because the function 
is called
in a non-const context during the initialization of an 
immutable object.


I would open an issue:

  https://issues.dlang.org/enter_bug.cgi?product=D

Ali


You cannot Assign Associative Arrays at compile-time.
Because those are defined by druntime have no stable ABI.


Thanks Stefan but at least there should be a better diagnostic 
instead of the confusing current situation that Ali experienced.


Ali


Ah kay. Confusing :)
Thanks again!


Re: Using tango with dub

2016-12-17 Thread Soulsbane via Digitalmars-d-learn

On Saturday, 17 December 2016 at 20:26:53 UTC, albert-j wrote:

I thought Tango was obsolete a long time ago.

Is there a specific reason you need to use Tango and can't use 
Phobos?


I need a Set implementation and from what I understand there 
isn't one in Phobos right now?


Have you seen https://github.com/economicmodeling/containers it 
has a HashSet 
http://economicmodeling.github.io/containers/containers/hashset.HashSet.html


Re: Using tango with dub

2016-12-17 Thread albert-j via Digitalmars-d-learn

I thought Tango was obsolete a long time ago.

Is there a specific reason you need to use Tango and can't use 
Phobos?


I need a Set implementation and from what I understand there 
isn't one in Phobos right now?





Re: Using tango with dub

2016-12-17 Thread bauss via Digitalmars-d-learn

On Saturday, 17 December 2016 at 15:46:20 UTC, albert-j wrote:
I am trying to use Tango in a dub project because I need a 
HashSet. I added Tango as a dependency to the dub.json, but now 
dub gives me a bunch of depreciation warnings and a few errors, 
like


../../../.dub/packages/tango-1.0.3_2.068/tango/tango/util/log/Log.d(349,51): 
Error: undefined identifier '__va_argsave', did you mean struct 
'__va_argsave_t'?

What am I missing?


I thought Tango was obsolete a long time ago.

Is there a specific reason you need to use Tango and can't use 
Phobos?


Re: Using tango with dub

2016-12-17 Thread Jacob Carlborg via Digitalmars-d-learn

On 2016-12-17 16:51, albert-j wrote:

Since I just do "dub build", I assume it invokes dmd? I have v2.072.0.


Try an older version.

--
/Jacob Carlborg


Re: Cryptic C function pointer for conversion

2016-12-17 Thread bachmeier via Digitalmars-d-learn
On Saturday, 17 December 2016 at 15:15:26 UTC, data pulverizer 
wrote:


Does this mean that you can translate C code to D natively? I 
am currently only aware of the dstep package.


It may not help you, but something I've done in the past is use 
Swig to create a Common Lisp interface. It translates the C to 
Common Lisp. That is generally much easier for me to understand.


Re: Using tango with dub

2016-12-17 Thread albert-j via Digitalmars-d-learn
Since I just do "dub build", I assume it invokes dmd? I have 
v2.072.0.


Re: Using tango with dub

2016-12-17 Thread Jacob Carlborg via Digitalmars-d-learn

On 2016-12-17 16:46, albert-j wrote:

I am trying to use Tango in a dub project because I need a HashSet. I
added Tango as a dependency to the dub.json, but now dub gives me a
bunch of depreciation warnings and a few errors, like

../../../.dub/packages/tango-1.0.3_2.068/tango/tango/util/log/Log.d(349,51):
Error: undefined identifier '__va_argsave', did you mean struct
'__va_argsave_t'?

What am I missing?


It might not be compatible with that version of the compiler. Or are you 
using something that is not DMD?


--
/Jacob Carlborg


Using tango with dub

2016-12-17 Thread albert-j via Digitalmars-d-learn
I am trying to use Tango in a dub project because I need a 
HashSet. I added Tango as a dependency to the dub.json, but now 
dub gives me a bunch of depreciation warnings and a few errors, 
like


../../../.dub/packages/tango-1.0.3_2.068/tango/tango/util/log/Log.d(349,51): 
Error: undefined identifier '__va_argsave', did you mean struct 
'__va_argsave_t'?

What am I missing?



Re: Cryptic C function pointer for conversion

2016-12-17 Thread ketmar via Digitalmars-d-learn
p.s.: that means that i didn't really *decoded* that declaration, 
just brute-forced someting that c++ compiler happily accepts. so 
take it with a grain of salt. ;-)


Re: Cryptic C function pointer for conversion

2016-12-17 Thread data pulverizer via Digitalmars-d-learn

On Saturday, 17 December 2016 at 14:06:07 UTC, ketmar wrote:
On Saturday, 17 December 2016 at 13:39:27 UTC, data pulverizer 
wrote:


that is what it means, in D:

//void (*(*xDlSym)(sqlite3_vfs*,void*, const char 
*zSymbol))(void);


struct sqlite3_vfs {}

extern(C) {
alias RetRes = void function ();
alias DeclType = RetRes function (sqlite3_vfs *a,void *b, const 
char *zSymbol);


DeclType xDlSym;

void zoo (void) {}
auto goo (sqlite3_vfs *a,void *b, const char *zSymbol) { return 
 }

}

void main () {
  xDlSym = 
}


at least that is what i managed to decode, fed to C(++) 
compiler and translate to D.


p.s. I confirmed your interpretation on stackoverflow:

http://stackoverflow.com/questions/8722817/syntax-for-a-pointer-to-a-function-returning-a-function-pointer-in-c



Re: Cryptic C function pointer for conversion

2016-12-17 Thread ketmar via Digitalmars-d-learn
On Saturday, 17 December 2016 at 15:15:26 UTC, data pulverizer 
wrote:


Does this mean that you can translate C code to D natively? I 
am currently only aware of the dstep package.


with my head and bare hands. well, armed with some regular 
expressions. did you seen some of my "port" announcements? they 
all done manually. it's not that hard, mostly search-and-replace.


also, i did used c++ 'cause it has `auto` feature, so i pasted 
your declaration, and then played with c++ and -Wall until it 
silenced. actually,


void zoo (void) {}
auto goo (sqlite3_vfs *a,void *b, const char *zSymbol) { return 
 }


was taken verbatim from c++. as you can see, it even has 
`(void)`, which is forbidden in D (but allowed in my dmd fork ;-).


Re: Cryptic C function pointer for conversion

2016-12-17 Thread data pulverizer via Digitalmars-d-learn

On Saturday, 17 December 2016 at 14:06:07 UTC, ketmar wrote:

that is what it means, in D:

//void (*(*xDlSym)(sqlite3_vfs*,void*, const char 
*zSymbol))(void);


struct sqlite3_vfs {}

extern(C) {
alias RetRes = void function ();
alias DeclType = RetRes function (sqlite3_vfs *a,void *b, const 
char *zSymbol);

...
}


Thanks ketmar,

I guess that this means I got it the other way round the function 
pointer that is returned is the function that takes in and 
returns void.


at least that is what i managed to decode, fed to C(++) 
compiler and translate to D.


Does this mean that you can translate C code to D natively? I am 
currently only aware of the dstep package.





Re: Cryptic C function pointer for conversion

2016-12-17 Thread ketmar via Digitalmars-d-learn
On Saturday, 17 December 2016 at 13:39:27 UTC, data pulverizer 
wrote:


that is what it means, in D:

//void (*(*xDlSym)(sqlite3_vfs*,void*, const char 
*zSymbol))(void);


struct sqlite3_vfs {}

extern(C) {
alias RetRes = void function ();
alias DeclType = RetRes function (sqlite3_vfs *a,void *b, const 
char *zSymbol);


DeclType xDlSym;

void zoo (void) {}
auto goo (sqlite3_vfs *a,void *b, const char *zSymbol) { return 
 }

}

void main () {
  xDlSym = 
}


at least that is what i managed to decode, fed to C(++) compiler 
and translate to D.


Cryptic C function pointer for conversion

2016-12-17 Thread data pulverizer via Digitalmars-d-learn
I have come across a function pointer in C that I am attempting 
to convert, and am not sure what the current interpretation is:


```
\\ The C Code:
void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
```

The best I can tell is that this is a function pointer that 
returns a function that returns void and the correct translation 
to D is:


```
alias void function(sqlite3_vfs*,void*, const char *zSymbol) ptr;
ptr* function() xDlSym;
```

I've never seen a construction like this before so my 
interpretation might be wrong!