Re: What is the best way to refer to itself when obtaining Substring of a literal?

2020-04-24 Thread SrMordred via Digitalmars-d-learn
On Friday, 24 April 2020 at 22:24:34 UTC, Marcone wrote: I don't want to use lambda. I don't want create variable. What is the best way to refer to itself when obtaining Substring withou using lambda and without create variable? example: writeln("Hello Word!"[x.indexOf(" "), $]); Maybe u

Re: Strip Unused Symbols Ldc + Windows

2020-03-21 Thread SrMordred via Digitalmars-d-learn
On Saturday, 21 March 2020 at 18:01:55 UTC, kinke wrote: On Saturday, 21 March 2020 at 17:33:21 UTC, SrMordred wrote: Hmm, ok, my question is in fact relate to this kind of thing: https://godbolt.org/z/NGjyyx Why int example.add(int, int): its still on the binary when all u need is alredy

Re: Strip Unused Symbols Ldc + Windows

2020-03-21 Thread SrMordred via Digitalmars-d-learn
On Saturday, 21 March 2020 at 15:53:53 UTC, kinke wrote: On Saturday, 21 March 2020 at 01:54:00 UTC, SrMordred wrote: Someone knows how to strip unused symbols on final binary using ldc on windows ? i found this about this topic:

Strip Unused Symbols Ldc + Windows

2020-03-20 Thread SrMordred via Digitalmars-d-learn
Someone knows how to strip unused symbols on final binary using ldc on windows ? i found this about this topic: https://forum.dlang.org/post/yvmnkvzgoxhcfavja...@forum.dlang.org that uses --gc-sections and --version-script but this options are not avaliable in windows lld-link

External .o sources + BetterC : undefined symbol: __chkstk

2020-03-11 Thread SrMordred via Digitalmars-d-learn
I got undefined symbol: __chkstk when using some external .o sources ( compile with clang ) + betterC flag. I thought that __chkstk was present on ntdll.lib, so i added manually as a lib, but still didn´t work. How can i solve this? (it must be another lib that D includes since it works

Re: BetterC + startsWith

2020-02-21 Thread SrMordred via Digitalmars-d-learn
The issue is that strings aren't input ranges in betterC [1], due to autodecoding. Normally you'd work around this using std.utf.byCodeUnit, but that's currently broken, because std.utf attempts to import core.exception.UnicodeException from druntime at module scope [2], causing any betterC

BetterC + startsWith

2020-02-21 Thread SrMordred via Digitalmars-d-learn
//-betterC import core.stdc.stdio; import std.algorithm; void main(){ printf( "%d\n",startsWith("a","b") ); } //Fails to compile with betterC, dmd/ldc2 last versions. Any reason for not work with betterC or should i file the issue ? (Find this on a bindbc lib, so i think that it may have

Re: dub build doesn't work

2019-10-23 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 22 October 2019 at 22:14:02 UTC, OiseuKodeur wrote: Hello, i am having a problem with dub build with this project https://github.com/OiseauKodeur/cervelet/tree/master/source when i try to compile everything go well but when i click to run the .exe it give my an error missing

Re: My dialogue code is not working as it should!

2019-10-20 Thread SrMordred via Digitalmars-d-learn
On Sunday, 20 October 2019 at 08:41:19 UTC, TodNaz wrote: Hello! I can’t understand ... My dialogue code is not working as it should! He must, if the texture does not exceed the maximum value, add a character, otherwise go to a new line until the text ends. But he constantly makes the

Re: Functional Programming in D

2019-10-09 Thread SrMordred via Digitalmars-d-learn
https://garden.dlang.io/

Re: What is "dual-context" ?

2019-09-13 Thread SrMordred via Digitalmars-d-learn
On Friday, 13 September 2019 at 04:23:47 UTC, Paul Backus wrote: On Friday, 13 September 2019 at 02:49:33 UTC, SrMordred wrote: [...] "Dual context" is the compiler feature that allows you to pass delegates as template arguments to member functions. For a long time, limitations in the

What is "dual-context" ?

2019-09-12 Thread SrMordred via Digitalmars-d-learn
source\app.d(37,10): Error: function `app.main.match!((some) => print(some), (none) => print("none")).match` requires a dual-context, which is not yet supported by LDC I was playing with my home made "sumtypes". The code below works fine in dmd, but in ldc it triggers that error.

Re: hasElaborateCopyConstructor bug?

2019-06-01 Thread SrMordred via Digitalmars-d-learn
On Sunday, 2 June 2019 at 04:02:08 UTC, Paul Backus wrote: On Saturday, 1 June 2019 at 23:29:08 UTC, SrMordred wrote: On Saturday, 1 June 2019 at 21:39:33 UTC, SImen Kjærås wrote: On Saturday, 1 June 2019 at 21:05:32 UTC, SrMordred wrote: Haven't tested it extensively, so use at your own

Re: hasElaborateCopyConstructor bug?

2019-06-01 Thread SrMordred via Digitalmars-d-learn
On Saturday, 1 June 2019 at 21:39:33 UTC, SImen Kjærås wrote: On Saturday, 1 June 2019 at 21:05:32 UTC, SrMordred wrote: hasElaborateCopyConstructor checks if the type defines a postblit[0]. Yes, I know this. But since dmd 2.086 we have copy ctors:

hasElaborateCopyConstructor bug?

2019-06-01 Thread SrMordred via Digitalmars-d-learn
import std.traits; struct T { this(ref return scope T other){} } pragma(msg, hasElaborateCopyConstructor!T); //false

Re: Calling copyctor manually

2019-06-01 Thread SrMordred via Digitalmars-d-learn
On Saturday, 1 June 2019 at 19:10:36 UTC, Paul Backus wrote: On Saturday, 1 June 2019 at 02:27:36 UTC, SrMordred wrote: void main() { T a; T b; a.__ctor(b); } https://run.dlang.io/is/NeioBs Thanks! The most obvious way i didn´t think :P

Calling copyctor manually

2019-05-31 Thread SrMordred via Digitalmars-d-learn
Its possible to call copyctor manually without calling dtor? ex, what i did before: struct T{ ~this(){ writeln("DTOR"); } this(this){ writeln("POSTBLIT"); } } T a; T b; memcpy(,,T.sizeof); a.__postblit; /* output: POSTBLIT DTOR DTOR */ With copy ctors, not sure what to do. struct T{

Re: Dlang + emscripten

2019-05-17 Thread SrMordred via Digitalmars-d-learn
On Thursday, 16 May 2019 at 19:27:15 UTC, Dukc wrote: On Thursday, 16 May 2019 at 18:23:12 UTC, SrMordred wrote: [...] Nice will take a look on this two, thanks :)

Dlang + emscripten

2019-05-16 Thread SrMordred via Digitalmars-d-learn
I´m following this link to build d+sdl2+emscripten on web: https://theartofmachinery.com/2018/12/20/emscripten_d.html And, i´m was able to compile but i get the warnings warning: Linking two modules of different data layouts / target triples even when I compile using x86. So i´m not sure if

Re: Emulating DLL

2019-03-20 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 19 March 2019 at 19:50:15 UTC, Craig wrote: Take a look at my lib, its a simple hot-reload external dll lib: https://github.com/SrMordred/reloaded I did´nt use it extensively, but its simple enough to be tweaked at your own need :)

Re: isSame/TemplateOf bug?

2019-02-19 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 19 February 2019 at 23:03:37 UTC, Paul Backus wrote: On Tuesday, 19 February 2019 at 22:43:25 UTC, SrMordred wrote: import std.traits; import std.stdio; struct Test(T) { this(T)( auto ref T value ) { writeln( TemplateOf!(typeof(value)).stringof);

isSame/TemplateOf bug?

2019-02-19 Thread SrMordred via Digitalmars-d-learn
import std.traits; import std.stdio; struct Test(T) { this(T)( auto ref T value ) { writeln( TemplateOf!(typeof(value)).stringof); writeln( __traits(isSame, TemplateOf!(typeof(value)), Test) ); } } void main(){ auto value =

Re: dub ldc error _d_array_slice_copy

2019-02-18 Thread SrMordred via Digitalmars-d-learn
On Monday, 18 February 2019 at 23:40:20 UTC, kinke wrote: On Monday, 18 February 2019 at 19:10:50 UTC, SrMordred wrote: dub --compiler=ldc2 //app.d:4: error: undefined reference to '_d_array_slice_copy' Dub has nothing to do with it, it's the -betterC flag, and LDC expecting that druntime

Re: dub ldc error _d_array_slice_copy

2019-02-18 Thread SrMordred via Digitalmars-d-learn
On Monday, 18 February 2019 at 19:14:42 UTC, SrMordred wrote: oh, and: DUB version 1.13.0, built on Feb 17 2019 LDC - the LLVM D compiler (1.14.0): based on DMD v2.084.1 and LLVM 7.0.1 Sorry, both give the same error, the problem is related to -betterC flag (which i forgot to add on first

Re: dub ldc error _d_array_slice_copy

2019-02-18 Thread SrMordred via Digitalmars-d-learn
oh, and: DUB version 1.13.0, built on Feb 17 2019 LDC - the LLVM D compiler (1.14.0): based on DMD v2.084.1 and LLVM 7.0.1

dub ldc error _d_array_slice_copy

2019-02-18 Thread SrMordred via Digitalmars-d-learn
On ubuntu: void test(size_t l) { char* a; a[0 .. l] = a[0 .. l]; } extern(C) void main(){ test(0); } ldc2 source/app.d //compiles dub --compiler=ldc2 //app.d:4: error: undefined reference to '_d_array_slice_copy'

Re: Is there a nice syntax to achieve optional named parameters?

2019-01-17 Thread SrMordred via Digitalmars-d-learn
On Thursday, 17 January 2019 at 12:11:02 UTC, Matheus wrote: foo(alias x){} foo("a"); foo(1); 'x' will be string one time and integer another? Or there is something that I'm missing. Matheus. Yes, but there is a mistake there: alias is part of the template: foo(alias x)(){} //note extra

Re: Is there a nice syntax to achieve optional named parameters?

2019-01-16 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote: As an example let's say I have a type 'Window' that represents a win32 window. I'd like to be able to construct an instance of the type with some optional parameters that default to some reasonable settings and create the

Re: What's that 'q' before '{' in this code?

2019-01-15 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 15 January 2019 at 17:52:35 UTC, Machine Code wrote: https://github.com/dlang/dmd/blob/master/src/dmd/compiler.d#L75 https://dlang.org/spec/lex.html#token_strings :)

Bug or expected?

2019-01-08 Thread SrMordred via Digitalmars-d-learn
size_t[2] a; size_t[2] b; auto x = a[] & b[]; //array operation without destination memory not allowed size_t[2] y = a[] & b[]; // fine

Re: BetterC + Windows + setjmp longjmp

2018-09-20 Thread SrMordred via Digitalmars-d-learn
Ok, after a better look at the sources I finally got it: setjmp is a macro. the true function signature is "int _setjmp(jmp_buf, void*)" the void* is the current function address which in mingw sources are capture by "__builtin_frame_address(0)". And I did´t look yet to see if Dlang have an

Re: BetterC + Windows + setjmp longjmp

2018-09-19 Thread SrMordred via Digitalmars-d-learn
On Wednesday, 19 September 2018 at 11:12:41 UTC, Diederik de Groot wrote: On Wednesday, 19 September 2018 at 11:06:23 UTC, Diederik de Groot wrote: On Tuesday, 18 September 2018 at 19:45:18 UTC, SrMordred wrote: Only the exact size of the jmp_buf is important (not the details about the

Re: BetterC + Windows + setjmp longjmp

2018-09-18 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 18 September 2018 at 20:01:48 UTC, SrMordred wrote: longjmp is crashing so may be related to the struct declaration. Well just found a thread of the same problem, just that in my case with 64x crashes too. https://forum.dlang.org/post/mmxwhdypncaeikknl...@forum.dlang.org

Re: BetterC + Windows + setjmp longjmp

2018-09-18 Thread SrMordred via Digitalmars-d-learn
longjmp is crashing so may be related to the struct declaration.

Re: BetterC + Windows + setjmp longjmp

2018-09-18 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 18 September 2018 at 03:09:18 UTC, Mike Parker wrote: On Tuesday, 18 September 2018 at 00:24:23 UTC, SrMordred wrote: Yes, i'm using signal(SIGSEGV, sigfn_t func), it catches correctly, but end the execution after. I find the alternatives of setjmp/longjmp and sigaction, but

Re: BetterC + Windows + setjmp longjmp

2018-09-17 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 18 September 2018 at 00:12:35 UTC, Diederik de Groot wrote: On Monday, 17 September 2018 at 23:44:41 UTC, SrMordred wrote: [...] You can use core.stdc.signal nothrow @nogc @system sigfn_t signal(SIGSEGV, sigfn_t func) To catch the signal With a handler signature of: enum void

BetterC + Windows + setjmp longjmp

2018-09-17 Thread SrMordred via Digitalmars-d-learn
Its possible to use setjmp/longjmp on windows? Or, to be straight to my problem: its possible to continue execution after a SIGSEGV(or any other failure/signal) with betterC and windows?

Re: array to string functional?

2018-09-14 Thread SrMordred via Digitalmars-d-learn
On Friday, 14 September 2018 at 19:44:37 UTC, berni wrote: a) I've got an int[] which contains only 0 und 1. And I want to end with a string, containing 0 and 1. So [1,1,0,1,0,1] should become "110101". Of course I can do this with a loop and ~. But I think it should be doable with functional

Re: hasAliasing with nested static array bug ?

2018-09-06 Thread SrMordred via Digitalmars-d-learn
On Thursday, 6 September 2018 at 07:37:11 UTC, Simen Kjærås wrote: On Wednesday, 5 September 2018 at 22:35:16 UTC, SrMordred wrote: https://run.dlang.io/is/TOTsL4 Yup, that's a bug. Reduced example: struct S { int*[1] arr; } import std.traits : hasAliasing; static assert(hasAliasing!S);

hasAliasing with nested static array bug ?

2018-09-05 Thread SrMordred via Digitalmars-d-learn
https://run.dlang.io/is/TOTsL4

C++ GLM(OpenGL Mathematics) D Equivalent.

2018-09-04 Thread SrMordred via Digitalmars-d-learn
Most C++ game related projects uses GLM as they default math/vector lib (even if not using opengl). In D we have (that I found): gfm.math - https://github.com/d-gamedev-team/gfm dlib.math - https://github.com/gecko0307/dlib Gl3n - https://github.com/Dav1dde/gl3n But i'm not sure which

Re: How to use LLD linker?

2018-07-06 Thread SrMordred via Digitalmars-d-learn
Well, since its VS 2017 installer, eventually I hit all the components needed to install it properly. Now its working. Thanks 0xEAB for the tip about the Windows SDK too :)

Re: How to use LLD linker?

2018-07-06 Thread SrMordred via Digitalmars-d-learn
Delete everything, installed everything again, the installation failed to set the proper PATH to MS link.exe, so i put it by hand and now get: fatal error LNK1104: cannot open file 'libcmt.lib' Frustrating.

Re: How to use LLD linker?

2018-07-06 Thread SrMordred via Digitalmars-d-learn
On Friday, 6 July 2018 at 19:36:05 UTC, 0xEAB wrote: On Friday, 6 July 2018 at 03:48:04 UTC, SrMordred wrote: Well I just installed the VS 2017 to try the ldc and get (maybe) the same error. You didn't forget to install the Windows SDK with it, did you? Yep I forgot xD It fixed the PATHs

Re: How to use LLD linker?

2018-07-06 Thread SrMordred via Digitalmars-d-learn
On Friday, 6 July 2018 at 10:55:47 UTC, Rainer Schuetze wrote: On 06/07/2018 05:48, SrMordred wrote: [...] The problem is that the Digital Mars linker is called but the Microsoft linker is run, because they share the same name link.exe. For dmd/x64/32mscoff or LDC in general the latter is

Re: How to use LLD linker?

2018-07-05 Thread SrMordred via Digitalmars-d-learn
On Saturday, 30 June 2018 at 10:48:49 UTC, Suliman wrote: Correct me if I am wrong, but I have read news that dmd now can be used without C++ Build Tools. I trying to build simple project. And getting Error: Warning: no Visual C++ installation detected OPTLINK (R) for Win32 Release 8.00.17

Re: CustomString and string constraints

2018-06-26 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 22:16:28 UTC, Jonathan M Davis wrote: If what you're asking is whether it's possible for a template constraint that uses something like isSomeString will ever match a user-defined type, then the answer is no. Thats exactly what I wanted xD. My idea was that if

CustomString and string constraints

2018-06-26 Thread SrMordred via Digitalmars-d-learn
Is possible to make a Custom Struct String work for D string constraints? eg: struct MyString { char[] arr; alias arr this; } void getString( char[] str ){} MyString().split(";"); //oops, type mismatch getString( MyString() ); //fine, implicit conversion

Re: Static Array Idiom not working anymore.

2018-06-12 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 16:27:50 UTC, SrMordred wrote: On Tuesday, 12 June 2018 at 15:39:10 UTC, Steven Schveighoffer wrote: Essentially what you had originally was a memory corruption bug (yes, even before the deprecation happened). Oops , that bad. Well, not anymore ;)

Re: Static Array Idiom not working anymore.

2018-06-12 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 12 June 2018 at 15:39:10 UTC, Steven Schveighoffer wrote: Essentially what you had originally was a memory corruption bug (yes, even before the deprecation happened). Oops , that bad.

Static Array Idiom not working anymore.

2018-06-12 Thread SrMordred via Digitalmars-d-learn
this idiom for creating static array used to work, but they are failing now. What changed and whats the alternative? (from https://p0nce.github.io/d-idioms/#@nogc-Array-Literals:-Breaking-the-Limits) T[n] s(T, size_t n)(auto ref T[n] array) pure nothrow @nogc @safe { return array; }

Re: delegates and functions

2018-06-10 Thread SrMordred via Digitalmars-d-learn
a => { return 2*a; } /\ \ / || \ / ||\ / || \ / || \ / This is \ / function \ This is definition of delegate definition \ so you have a function that returns delegate. ``` it's like a => a => 2*a; or (a){ return () {

Re: Why char[] is not @nogc on this case

2018-05-24 Thread SrMordred via Digitalmars-d-learn
Because arrays of char and wchar are treated as ranges of dchar. That part that I didnt know, thanks! :)

Re: Why char[] is not @nogc on this case

2018-05-24 Thread SrMordred via Digitalmars-d-learn
On Friday, 25 May 2018 at 00:04:10 UTC, Adam D. Ruppe wrote: On Thursday, 24 May 2018 at 23:55:24 UTC, SrMordred wrote: //Error: @nogc delegate onlineapp.main.__lambda1 cannot call non-@nogc function std.range.chain!(char[], char[]).chain.Result.front Why? phobos automatically decodes utf8

Why char[] is not @nogc on this case

2018-05-24 Thread SrMordred via Digitalmars-d-learn
int[] a; int[] b; ()@nogc { foreach(v ; chain( a,b ) ) printf("%d\n", v); }(); //Ok, everything fine; char[] a; char[] b; ()@nogc { foreach(v ; chain( a,b ) ) printf("%c\n", v); }(); //Error: @nogc delegate onlineapp.main.__lambda1 cannot call non-@nogc function

Re: UFCS syntax I never saw before.

2018-05-21 Thread SrMordred via Digitalmars-d-learn
"%s %s".writefln = ("foo".tuple = "bar").expand; lol

Re: UFCS syntax I never saw before.

2018-05-21 Thread SrMordred via Digitalmars-d-learn
Right, so this should´n be working I think. struct SomeStruct { void foo(int); } SomeStruct s; s.foo = 10; I thought that only with @property this will work.

UFCS syntax I never saw before.

2018-05-21 Thread SrMordred via Digitalmars-d-learn
After all this time I saw this: writeln = iota = 5; what?? I never saw that before! This is interesting, there is something useful that i can do with this kind of call?

Re: property += operator

2018-05-10 Thread SrMordred via Digitalmars-d-learn
On Thursday, 10 May 2018 at 19:41:41 UTC, Dlang User wrote: On 5/10/2018 1:43 PM, SrMordred wrote: [...] I am relatively new to D and I was under the impression that that was a limitation of @property functions. But, re-reading the language reference, it gave this example (it returns

property += operator

2018-05-10 Thread SrMordred via Digitalmars-d-learn
struct T { int x; @property ref X(){ return x; } @property X(int v) { x = v; } } T t; t.X += 10; The setter 'x = v' are not executed because i´m returning the reference of x. And without the 'ref' the compiler complains because 'x' is not a lvalue. Any solution

Re: Negative index range violation

2018-02-22 Thread SrMordred via Digitalmars-d-learn
On Thursday, 22 February 2018 at 02:41:30 UTC, Steven Schveighoffer wrote: Hah! I never thought of doing a slice with negative indexes ;) Maybe is my past of python: arr[-3:] to get the last 3 elements for eg. :)

Re: Negative index range violation

2018-02-21 Thread SrMordred via Digitalmars-d-learn
But with a slice negative indexes are never allowed, even on a pointer. youd have to do (c-1)[0 .. 1]; Nice! Thank you both! In D Slice article it says "You can even use negative indexes!" so I thought that the [-1..x] should work too :)

Negative index range violation

2018-02-21 Thread SrMordred via Digitalmars-d-learn
string x = "123"; auto c = x.ptr; c++; writeln(c[-1]); // 1 writeln(c[-1..0]); //BOOM Range violation Can I do this / Bug / some mistake ?

Re: multithread/concurrency/parallel methods and performance

2018-02-19 Thread SrMordred via Digitalmars-d-learn
On Monday, 19 February 2018 at 05:54:53 UTC, Dmitry Olshansky wrote: The operation is trivial and dataset is rather small. In such cases SIMD with eg array ops is the way to go: result[] = values[] * values2[]; Yes, absolutely right :) I make a simple example to understand why the threads

Re: multithread/concurrency/parallel methods and performance

2018-02-19 Thread SrMordred via Digitalmars-d-learn
On Monday, 19 February 2018 at 05:49:54 UTC, Nicholas Wilson wrote: As SIZE=1024*1024 (i.e. not much, possibly well within L2 cache for 32bit) it may be that dealing with the concurrency overhead adds a significant amount of overhead. That 'concurrency overhead' is what i´m not getting. Since

multithread/concurrency/parallel methods and performance

2018-02-18 Thread SrMordred via Digitalmars-d-learn
I´m experimenting with threads and related recently. (i´m just started so may be some terrrible mistakes here) With this base work: foreach(i ; 0 .. SIZE) { results[i] = values1[i] * values2[i]; } and then with this 3 others methods: parallel, spawn and Threads. this was my results:

Re: Concurrency send immutable

2017-11-24 Thread SrMordred via Digitalmars-d-learn
Nice, thank you!

Re: Concurrency send immutable

2017-11-24 Thread SrMordred via Digitalmars-d-learn
On Friday, 24 November 2017 at 12:36:42 UTC, Daniel Kozak wrote: Should print something like this: std.concurrency.OwnerTerminated@std/concurrency.d(223): Owner terminated Yes, it was, I was aware of this and put some sleep after that too. (immutable (int)[] v) OK that parenteshis was

Re: Concurrency send immutable

2017-11-24 Thread SrMordred via Digitalmars-d-learn
On Friday, 24 November 2017 at 12:05:16 UTC, SrMordred wrote: immutable int[] arr = [1,2,3,4,5]; auto t = spawn({ receive( (immutable int[] v) => writeln(v) );}); t.send(arr); whats the problem here? Nothing prints out

Concurrency send immutable

2017-11-24 Thread SrMordred via Digitalmars-d-learn
immutable int[] arr = [1,2,3,4,5]; auto t = spawn({ receive( (immutable int[] v) => writeln(v) );}); t.send(arr); whats the problem here?

Re: __traits(compiles , mixin ... )

2017-10-25 Thread SrMordred via Digitalmars-d-learn
On Wednesday, 25 October 2017 at 20:04:47 UTC, Adam D. Ruppe wrote: On Wednesday, 25 October 2017 at 19:50:31 UTC, SrMordred wrote: so why this line resolves to false? Because it is illegal to put a statement or declaration inside __traits(compiles). sorry, I should have said that before...

Re: __traits(compiles , mixin ... )

2017-10-25 Thread SrMordred via Digitalmars-d-learn
The semicolon there indicates it is a complete statement that does nothing, and that's no error. so why this line resolves to false? void F(){} pragma(msg, __traits( compiles, mixin("F();") ) );//false

Re: __traits(compiles , mixin ... )

2017-10-25 Thread SrMordred via Digitalmars-d-learn
On Wednesday, 25 October 2017 at 19:25:01 UTC, Adam D. Ruppe wrote: On Wednesday, 25 October 2017 at 19:12:02 UTC, SrMordred wrote: Maybe i´m tired already, but whats wrong here: pragma(msg, __traits( compiles, mixin("int x") ) ); You are missing a ; The mixin must compile as a full thing

Re: __traits(compiles , mixin ... )

2017-10-25 Thread SrMordred via Digitalmars-d-learn
On Wednesday, 25 October 2017 at 19:12:02 UTC, SrMordred wrote: Maybe i´m tired already, but whats wrong here: pragma(msg, __traits( compiles, mixin("int x") ) ); //output: false Or the original case I found: struct T{} pragma(msg, __traits( compiles, T() ) ); //true pragma(msg, __traits(

__traits(compiles , mixin ... )

2017-10-25 Thread SrMordred via Digitalmars-d-learn
Maybe i´m tired already, but whats wrong here: pragma(msg, __traits( compiles, mixin("int x") ) ); //output: false

Re: splitter string/char different behavior

2017-09-30 Thread SrMordred via Digitalmars-d-learn
In order to know where to split, it really has to do it from the front. If it starts from the back, you won't necessarily split in the same places as when iterating from the front, and that would violate how bidirectional ranges are supposed to work (the elements should be the same - just in

Re: splitter string/char different behavior

2017-09-30 Thread SrMordred via Digitalmars-d-learn
For "a.b.c"splitter(x), Range r is a string, r.front is a char. The template can only be instantiated if the predicate function is valid. The predicate function is "a == b". Since r.front is a char, then s must be a type that can be compared with '=='. A string and char cannot be compared with

splitter string/char different behavior

2017-09-30 Thread SrMordred via Digitalmars-d-learn
writeln( "a.b.c".splitter('.').dropBack(1) ); //compiles ok writeln( "a.b.c".splitter(".").dropBack(1) ); //error: Error: template std.range.dropBack cannot deduce function from argument types !()(Result, int), candidates are: (...) Hm.. can someone explain whats going on?

Parameters template and ref types

2017-09-26 Thread SrMordred via Digitalmars-d-learn
When using Parameters!T there are no difference between ref int and int for eg. I know there is ParameterStorageClassTuple!T but it didt solve my problem: I want to transform any ref Type parameters in Type* like: staticMap!( ref2ptr, Parameters!MyFunc ); //(ref int, int) But then again

Re: OpIndex/OpIndexAssign strange order of execution

2017-09-18 Thread SrMordred via Digitalmars-d-learn
void main() { auto s = S(); s["b", "c"] = s["a"]; } Prints a ["b", "c"] Ali I thought about this too, thanks!

Re: OpIndex/OpIndexAssign strange order of execution

2017-09-18 Thread SrMordred via Digitalmars-d-learn
On Monday, 18 September 2017 at 15:14:20 UTC, Moritz Maxeiner wrote: On Monday, 18 September 2017 at 15:11:34 UTC, Moritz Maxeiner wrote: gets rewritten to --- t.opIndex("b").opIndexAssign(t["a"].value, "c"); --- Sorry, forgot one level of rewriting: ---

Re: Looking for instructions on how to make a Derelict library

2017-09-18 Thread SrMordred via Digitalmars-d-learn
I used to have a guide to creating "Derelictified" bindings for an older version. I should write one up for the current version. +1

Re: OpIndex/OpIndexAssign strange order of execution

2017-09-18 Thread SrMordred via Digitalmars-d-learn
Should I report this as a bug? I tried a C++ equivalent code and it execute in the expected order.

OpIndex/OpIndexAssign strange order of execution

2017-09-17 Thread SrMordred via Digitalmars-d-learn
struct Test{ @property int value(){ writeln("property value : ", _value); return _value; } int _value; Test opIndex( string index ) { writeln( "opIndex : index : ", index ); return this; } Test opIndexAssign(int value, string index )

Re: SDL and new Thread open two windows

2017-09-01 Thread SrMordred via Digitalmars-d-learn
On Saturday, 2 September 2017 at 03:47:24 UTC, Adam D. Ruppe wrote: On Saturday, 2 September 2017 at 03:41:47 UTC, SrMordred wrote: Whats going on , and how to prevent this ? Are you using a static this anywhere? Hm, right. I was constructing the window there. Forgot that static this will

SDL and new Thread open two windows

2017-09-01 Thread SrMordred via Digitalmars-d-learn
Im using SDL2 with derelict, on ubuntu. Last DMD. When using spawn or new Thread like : spawn( (){ while(true){ Thread.sleep(500.msecs); }); the program open two SDL windows. Whats going on , and how to prevent this ?

Re: -betterC not working

2017-09-01 Thread SrMordred via Digitalmars-d-learn
On Wednesday, 30 August 2017 at 23:12:07 UTC, SrMordred wrote: On Wednesday, 30 August 2017 at 22:45:27 UTC, Adam D. Ruppe wrote: On Wednesday, 30 August 2017 at 22:18:07 UTC, SrMordred wrote: DMD64 D Compiler v2.075.1 -betterC as described recently is not yet released.

Re: -betterC not working

2017-08-30 Thread SrMordred via Digitalmars-d-learn
On Wednesday, 30 August 2017 at 22:45:27 UTC, Adam D. Ruppe wrote: On Wednesday, 30 August 2017 at 22:18:07 UTC, SrMordred wrote: DMD64 D Compiler v2.075.1 -betterC as described recently is not yet released. https://dlang.org/changelog/2.076.0_pre.html is where it gets the new behavior, and

-betterC not working

2017-08-30 Thread SrMordred via Digitalmars-d-learn
On Ubuntu: //dub.json { "name": "d_betterc", "dflags" : ["-betterC"] } //source/app.d import std.stdio; extern (C) int main(int argc, char** argv) { int[] x; writeln(x); return 0; } //cmd dub run --config=application --arch=x86_64 --build=debug --compiler=dmd //or dmd

Re: Problem with dtor behavior

2017-07-28 Thread SrMordred via Digitalmars-d-learn
On Friday, 28 July 2017 at 16:25:01 UTC, Adam D. Ruppe wrote: On Thursday, 27 July 2017 at 19:19:27 UTC, SrMordred wrote: "auto ref means ref for lvalues, value for rvalues." Iep, my confusion was there. My mind is still wrapped around the rvalue references and move semantics of c++

Re: Problem with dtor behavior

2017-07-28 Thread SrMordred via Digitalmars-d-learn
On Friday, 28 July 2017 at 15:49:42 UTC, Moritz Maxeiner wrote: [...] Nice, a bit more clear now, thank you!

Re: Problem with dtor behavior

2017-07-28 Thread SrMordred via Digitalmars-d-learn
On Thursday, 27 July 2017 at 20:28:47 UTC, Moritz Maxeiner wrote: On Thursday, 27 July 2017 at 19:19:27 UTC, SrMordred wrote: //D-CODE struct MyStruct{ int id; this(int id){ writeln("ctor"); } ~this(){ writeln("dtor"); } } MyStruct* obj; void push(T)(auto

Problem with dtor behavior

2017-07-27 Thread SrMordred via Digitalmars-d-learn
//D-CODE struct MyStruct{ int id; this(int id){ writeln("ctor"); } ~this(){ writeln("dtor"); } } MyStruct* obj; void push(T)(auto ref T value){ obj[0] = value; } void main() { obj = cast(MyStruct*)malloc( MyStruct.sizeof ); push(MyStruct(1)); }

Re: criando modulos em D para classe pessoa[AJUDA]

2017-07-24 Thread SrMordred via Digitalmars-d-learn
On Monday, 24 July 2017 at 20:14:23 UTC, SrMordred wrote: On Monday, 24 July 2017 at 19:45:03 UTC, dark777 wrote: pessoal eu tenho umas classes java e estava portando para D e para usar as importaçoes criei os modules nescessarios todos estao dentro da mesma pasta porem ao fazer: $rdmd

Re: criando modulos em D para classe pessoa[AJUDA]

2017-07-24 Thread SrMordred via Digitalmars-d-learn
On Monday, 24 July 2017 at 19:45:03 UTC, dark777 wrote: pessoal eu tenho umas classes java e estava portando para D e para usar as importaçoes criei os modules nescessarios todos estao dentro da mesma pasta porem ao fazer: $rdmd principal ele retorna o seguinte erro: principal.d(18): Error:

Re: Get complete function declaration

2017-07-18 Thread SrMordred via Digitalmars-d-learn
On Tuesday, 18 July 2017 at 13:53:11 UTC, Ivan Kazmenko wrote: On Tuesday, 18 July 2017 at 13:35:49 UTC, SrMordred wrote: There is a way to get the full function(or any other structure) declaration with traits? Or I will have to mount it with std.traits functions? eg. void add(int x, int

Get complete function declaration

2017-07-18 Thread SrMordred via Digitalmars-d-learn
There is a way to get the full function(or any other structure) declaration with traits? Or I will have to mount it with std.traits functions? eg. void add(int x, int y){} GetFullFunctionDeclaration!add; //return "void add(int x, int y)"

dmd, vibe.d RAM usage when compiling.

2017-07-11 Thread SrMordred via Digitalmars-d-learn
I never notice this before, but i tried to put a basic hello world from vibe.d (like the one that are in the dlang front page examples now), into the most basic instance on google cloud (with 600mb of RAM) and the compilation returned "Killed dmd failed with exit code 137." So I look at the

Re: Playing with Entity System, performance and D.

2017-06-19 Thread SrMordred via Digitalmars-d-learn
On Monday, 19 June 2017 at 19:06:57 UTC, ag0aep6g wrote: For me, alias_fun and op_apply are very close. If anything, alias_fun seems to be slightly faster. Typical output (ldc2 -release -O3): Avoiding bounds checking makes it faster for me (but is unsafe of course): I took a deeper

Playing with Entity System, performance and D.

2017-06-19 Thread SrMordred via Digitalmars-d-learn
I was playing around my ES and different ways of doing it with D. I end up with a performance test of alias func vs ranges vs opApply. code here: https://dpaste.dzfl.pl/a2eff240552f Results on my machine win 10 x64, compiling with: dub run --build=release --arch=x86 --compiler=ldc2 (unable

  1   2   >