I want to translate this c code into d (build with ldc), so I can
use -flto and inline with other code.
uint64_t _wymum(uint64_t A, uint64_t B){
__uint128_t r = A ;
r *= B;
return (r>>64)^r;
}
Do i need ASM or is there a easy way to implement it ?
On Friday, 16 August 2019 at 16:22:27 UTC, Jonathan M Davis wrote:
[...]
Thanks very much again, very helpful explain.
I use pass by ref scope instead "return TreeRange.__ctor();" to
workround this issue.
On Friday, 16 August 2019 at 13:51:49 UTC, Jonathan M Davis wrote:
It is not possible to prevent moving in D as things currently
stand. DIP 1014 will need to be implemented to either hook into
moves or to prevent them. However, once DIP 1014 has been
implemented, I would expect the result to
On Friday, 16 August 2019 at 12:23:01 UTC, Newbie2019 wrote:
I has this simple function has some memory bugs:
---
struct TreeRange {
@disable this() ;
@disable this(this) ;
}
struct Tree {
ref auto getRange() return scope {
return TreeRange!T(_root);
I has this simple function has some memory bugs:
---
struct TreeRange {
@disable this() ;
@disable this(this) ;
}
struct Tree {
ref auto getRange() return scope {
return TreeRange!T(_root);
}
}
Tree tree;
auto range = tree.getRange();
--
On Tuesday, 30 July 2019 at 10:08:55 UTC, Newbie2019 wrote:
foreach(int name_index, name; __traits(allMembers, S) ) static
if( isDelegateMember!(S, name, Type) ) {
enum Rules = getUDAs!( __traits(getMember, S, name) , Rule);
// handle the member is match this rules.
}
And one more
On Tuesday, 30 July 2019 at 10:06:21 UTC, Newbie2019 wrote:
template isDelegateMember(S, string name, D) if(is(S == struct)
&& __traits(hasMember, S, name) && is( D == delegate ) ) {
alias Fn= typeof( __traits(getMember, S.init, name) );
static assert( isFunction!Fn );
I need to check on struct members is match a delegate type. for
example;
alias Type = scope void delegate(int) @nogc ;
struct S {
void onMatch1(int) scope @nogc {
}
void onNotMatch2(int) scope {
}
void onNotMatch2(int, int) scope @nogc {
}
Type not_match3;
}
On Saturday, 27 July 2019 at 17:13:45 UTC, Adam D. Ruppe wrote:
If you change that to just plain `return NodeList(a, b);`,
while keeping the first line, it will compile too.
The reason here is when you return and construct together, it
constructs it in-place. But if you put it in a local
I think this is a bug.
If I return a struct more than one times, will throw this error.
If I return once, every thing is ok.
https://run.dlang.io/is/T4kWKM
ref auto getList() return scope {
if( i ) return NodeList(null); // remove this line will fix
this error
On Monday, 22 July 2019 at 09:54:13 UTC, Jacob Carlborg wrote:
On 2019-07-19 22:16, Max Haughton wrote:
Isn't assert a template (file and line) rather than a plain
function call?
No. It's a keyword, it's built-in to the compiler. It get extra
benefits compared to a regular functions: the
On Saturday, 20 July 2019 at 14:19:08 UTC, Adam D. Ruppe wrote:
Like the other person said, try/catch turns throws to nothrow.
The `debug` keyword disables pure checks. Those make this easy
without any mixin or wrappers/casts at all.
But even if you did want to do the mixin route, look at
On Saturday, 20 July 2019 at 09:01:21 UTC, Newbie2019 wrote:
I want to cast std.stdio : writefln into pure function pointer,
so I can call it from debug pure function. is there a way to
work around the pure check for call writefln ?
nothrow check, not pure.
On Saturday, 20 July 2019 at 06:43:03 UTC, user1234 wrote:
use `__traits(identifier)` instead of `.stringof`, see
https://dlang.org/spec/traits.html#identifier.
as explained this is not a new bug, not even a bug according to
me.
I want to cast std.stdio : writefln into pure function
On Saturday, 20 July 2019 at 04:18:15 UTC, Adam D. Ruppe wrote:
show me what you're doing now and I'll see which case it is.
Most the time I see these, the code is significantly simplified
and bugs fixed by removing the usages of these strings..
I want to do this in betterC:
template
On Saturday, 20 July 2019 at 03:58:36 UTC, Adam D. Ruppe wrote:
You should never actually need that! What is your use case?
In most cases I see people doing .stringof, the correct
solution is to simply... not. Use the local name directly.
If you do need the name - and the only cases for this
template Test(alias T){
pragma(msg, T.stringof);
enum Test = T.stringof;
}
string t1;
void t2(){}
void t3(string s){}
extern(C) void main(){
enum x1 = Test!(t1); // ok
enum x2 = Test!(t2); // expect t2, but get t2()
enum x3 = Test!(t3); //Error:
for example:
void ASSERT(string fmt, string file = __FILE_FULL_PATH__, size_t
line = __LINE__, T...) (bool c, scope T a) @nogc {
assert(c, string, file, line);
}
but i get this error:
error.d(39): Error: found file when expecting )
error.d(39): Error: found ) when expecting ; following
when build my project with -betterC, it throw this error:
Error: TypeInfo cannot be used with -betterC
There is no location information about it, how can I find what
code cause this ?
On Wednesday, 17 July 2019 at 12:16:54 UTC, Adam D. Ruppe wrote:
It is also possible a member of the struct has a destructor
that is triggering it.
Thanks, I check all member and one of them is not @nogc nothrow.
add @nogc nothrow to member fix it.
this is very hard to made a minimal example, and the projects
only build with ldc.
There is a struct TcpServer has no destructor, and all method is
@nogc nothrow.
but some how when I use it on function run @nogc nothrow, ldc
report : @nogc function run cannot call non-@nogc destructor
On Wednesday, 12 June 2019 at 13:53:09 UTC, H. S. Teoh wrote:
On Wed, Jun 12, 2019 at 01:12:58PM +, Newbie2019 via
Digitalmars-d-learn wrote:
Read:
https://wiki.dlang.org/User:Quickfur/Compile-time_vs._compile-time
T
Thanks for the tips.
I move the static array into local var
https://run.dlang.io/is/s4cfiv
onlineapp.d(23): Error: static variable A cannot be read at
compile time
onlineapp.d(23): Error: cannot implicitly convert expression 1 of
type int to int*
I see no reason the code should not work, and the second error
message make no sense.
please
23 matches
Mail list logo