Re: C++17 Init statement for if/switch

2017-08-16 Thread SrMordred via Digitalmars-d
On Tuesday, 15 August 2017 at 21:05:09 UTC, bachmeier wrote: On Tuesday, 15 August 2017 at 20:31:50 UTC, Jonathan Marler wrote: Without alot of usage, it will just be an esoteric construct that looks confusing to the average developer. That is correct. After a while it gets tiring to see a

Re: struct constructors and destructors.

2017-07-19 Thread SrMordred via Digitalmars-d
On Wednesday, 19 July 2017 at 09:09:40 UTC, Stefan Koch wrote: On Wednesday, 19 July 2017 at 07:48:28 UTC, Danni Coy wrote: Is there a reason that the following code struct Foo { this (string name) { do_something(name); } ~this() { undo_something(); } } Foo foo = void; void

Re: struct constructors and destructors.

2017-07-19 Thread SrMordred via Digitalmars-d
On Wednesday, 19 July 2017 at 14:09:32 UTC, SrMordred wrote: On Wednesday, 19 July 2017 at 09:09:40 UTC, Stefan Koch wrote: On Wednesday, 19 July 2017 at 07:48:28 UTC, Danni Coy wrote: Is there a reason that the following code struct Foo { this (string name) { do_something(name); }

Re: C++17 Init statement for if/switch

2017-08-17 Thread SrMordred via Digitalmars-d
On Thursday, 17 August 2017 at 13:11:51 UTC, Enamex wrote: On Wednesday, 16 August 2017 at 14:19:59 UTC, SrMordred wrote: On Tuesday, 15 August 2017 at 21:05:09 UTC, bachmeier wrote: [...] There are two thinks of c++ that I miss a little on D: - Structured binding - Uniform initialization

Re: D on quora ...

2017-10-06 Thread SrMordred via Digitalmars-d
On Friday, 6 October 2017 at 18:42:02 UTC, H. S. Teoh wrote: On Fri, Oct 06, 2017 at 06:09:58PM +, Ali via Digitalmars-d wrote: On Friday, 6 October 2017 at 17:27:03 UTC, H. S. Teoh wrote: > On Fri, Oct 06, 2017 at 05:14:51PM +, Rion via > Digitalmars-d wrote: > >

Re: D on quora ...

2017-10-07 Thread SrMordred via Digitalmars-d
I think the GC discussion think will never go away because of the amount of c++ coders that come here. If you want to flee from C++ you have two realistic options: Rust and D. When you are looking at D and comparing metaprogramming, traits, ranges, UFCS, etc, its amazing: 'SO MUCH better

Re: Proposal: Object/?? Destruction

2017-10-04 Thread SrMordred via Digitalmars-d
On Wednesday, 4 October 2017 at 10:03:56 UTC, aberba wrote: Upon reading this, It triggered an idea. On Saturday, 30 September 2017 at 16:10:44 UTC, Jonathan Marler wrote: [...] DIP reminds me of object destruction. /* extracts success & message from returned type. Could be tuple or

Re: Just playing with compiler explorer to see assembly line count.

2017-10-03 Thread SrMordred via Digitalmars-d
On Tuesday, 3 October 2017 at 17:15:04 UTC, Daniel Kozak wrote: is not bad https://godbolt.org/g/bSfubs Thats cool, I never used copy xD. (but you returned the .copy range, not the 'r' array ;p) //now with ldc 1.4 and -O3 -release -boundscheck=off foreach -> 99 lines .filter.copy ->

Re: D on quora ...

2017-10-16 Thread SrMordred via Digitalmars-d
From https://wiki.dlang.org/Vision/2017H2: 2. @nogc: Use of D without a garbage collector, most likely by using reference counting and related methods Unique/Weak references) for reclamation of resources. This task is made challenging by the safety requirement. Eventually it will come (I

Just playing with compiler explorer to see assembly line count.

2017-10-03 Thread SrMordred via Digitalmars-d
//D compiled with gdc 5.2 -O3 auto test(int[] arr, int cmp) { int[] r; foreach(v ; arr) if(v == cmp)r~=v; return r; } // 51 lines of assembly auto test(int[] arr, int cmp) { return arr.filter!((v)=>v==cmp).array; } //1450 lines... what? Ok let me look also at c++: //gcc

Re: Just playing with compiler explorer to see assembly line count.

2017-10-03 Thread SrMordred via Digitalmars-d
On Tuesday, 3 October 2017 at 13:53:38 UTC, rikki cattermole wrote: Be warned, x86 cpu's today are not like they were 10 years ago. A good portion of a symbol could be full of nop's and it could end up being faster than the one without them. Next, compare against ldc, not gdc primarily. Its

Re: What do people here use as an IDE?

2017-11-17 Thread SrMordred via Digitalmars-d
I keep jumping between VSCode and SublimeText3 atm using ST3. (but they are not IDEs ;P)

DConf 2018 Videos

2018-05-21 Thread SrMordred via Digitalmars-d
There is some place where I can find this year conference videos with or without slides? Thanks!

Re: DConf 2018 Videos

2018-05-21 Thread SrMordred via Digitalmars-d
We're working to get each talk into separate videos, but it may take a while. Thank you very much! (for some odd reason the day 2 and 3 didn´t appear to me on youtube when I searched)

Re: betterC error?

2018-06-12 Thread SrMordred via Digitalmars-d
Or use C malloc. We really should provide better tools to create arrays using C malloc (for those who want them). Like a betterC toolkit. -Steve Indeed, i´m creating my own "toolkit" for betterC stuff like alloc!Type(length); (much safer than malloc!) and other utilities :)

Re: betterC error?

2018-06-12 Thread SrMordred via Digitalmars-d
On Tuesday, 12 June 2018 at 12:29:17 UTC, rikki cattermole wrote: (...) this line: byte[] data = [0, 1]; is an dynamic array allocated with GC. But if you declare as a static array like byte[2] data = [0, 1]; than its not GC allocated.

Re: Tuple DIP

2018-01-12 Thread SrMordred via Digitalmars-d
On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote: As promised [1], I have started setting up a DIP to improve +1, please.

Re: This is why I don't use D.

2018-09-04 Thread SrMordred via Digitalmars-d
On Wednesday, 5 September 2018 at 01:58:50 UTC, Jonathan M Davis wrote: On Tuesday, September 4, 2018 7:18:17 PM MDT James Blachly via Digitalmars-d wrote: [...] This is part of why it's sometimes been discussed that we need a way to indicate which dub packages are currently maintained and

Re: Messing with betterC and string type.

2018-09-07 Thread SrMordred via Digitalmars-d
On Friday, 7 September 2018 at 08:26:11 UTC, Kagamin wrote: On Thursday, 6 September 2018 at 17:09:34 UTC, SrMordred wrote: void foo(string s) {} foo("this"); won't compile, since it won't make a String out of that immutable(char)[] literal without an explicit initialization of some sort.

Re: Messing with betterC and string type.

2018-09-07 Thread SrMordred via Digitalmars-d
On Friday, 7 September 2018 at 16:20:29 UTC, H. S. Teoh wrote: Yeah, I don't remember that either! Was this a recent addition? Or is it an accidental feature (aka bug)? :-P If it is a bug, please keep it ;)

Messing with betterC and string type.

2018-09-06 Thread SrMordred via Digitalmars-d
I'm most of the time exploring the betterC lands and was thinking about custom strings, and how to convert D into D-betterC hmm I wonder... struct String{} alias string = String; string x = "test"; //cannot implicitly convert expression "test" of type string to String ok then... struct

Re: Messing with betterC and string type.

2018-09-06 Thread SrMordred via Digitalmars-d
On Thursday, 6 September 2018 at 16:50:01 UTC, Adam D. Ruppe wrote: this(object.string x) {} Yep, this works. which will work - immutable(char)[] is what object.string actually is (and the compiler will often use that - immutable(char)[], the proper name - and string, the user-friendly

std.traits : Select - could it be better?

2018-07-05 Thread SrMordred via Digitalmars-d
alias U = Select!( isPointer!T, PointerTarget!T, T ); This don´t compile if T are not a pointer; so you have to do this: static if( isPointer!T ) alias U = PointerTarget!T; else alias U = T; Shouldnt the 'correct' way of Select to work is ignoring the choice that was not taken? I

Re: std.traits : Select - could it be better?

2018-07-05 Thread SrMordred via Digitalmars-d
On Thursday, 5 July 2018 at 20:29:02 UTC, Steven Schveighoffer wrote: On 7/5/18 4:27 PM, Steven Schveighoffer wrote: template BetterSelect(bool cond, alias temp1, alias temp2, Args...) {    import std.meta : Instantiate;    static if(cond)   alias BetterSelect = Instantiate!(temp1,

Re: Struct destructors not available in -betterC?

2018-07-10 Thread SrMordred via Digitalmars-d
On Tuesday, 10 July 2018 at 19:14:26 UTC, Gary Willoughby wrote: Looking at the page on -betterC it says that struct destructors are not available. See point 11: https://dlang.org/spec/betterc.html#consequences This doesn't seem to be true as I'm using them with no problem. Yep, the docs

Re: A Case for Oxidation: A potential missed opportunity for D

2018-06-29 Thread SrMordred via Digitalmars-d
and non-template-only Phobos. unless they are using betterC (undefined reference to '_d_arraycopy')? Are you sure about this? //flags: -betterC -noboundscheck extern(C): void main() { import core.stdc.stdlib; int[] x = ( cast(int*) malloc( int.sizeof * 10 ) )[0 .. 10]; int[] y

Re: [your code here] 99 bottles of beer

2018-10-15 Thread SrMordred via Digitalmars-d
import std.format; template Bootle(alias Beer = 0) { static if(Beer < 99) enum Bootle = Bootle!(Beer + 1); else enum Bootle = Beer; pragma(msg, format!"%d bottles of beer on the wall, %d bottles of beer. Take one down, pass it around, %d bottles of beer on the

Re: A Friendly Challenge for D

2018-10-10 Thread SrMordred via Digitalmars-d
On Wednesday, 10 October 2018 at 16:15:56 UTC, Jabari Zakiya wrote: [...] Looking forward to this :)

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

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 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++

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: 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)"

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: 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

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)); }

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

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

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: 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
Should I report this as a bug? I tried a C++ equivalent code and it execute in the expected order.

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

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: -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

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

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?

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

Re: D as a Better C

2017-08-23 Thread SrMordred via Digitalmars-d-announce
On Wednesday, 23 August 2017 at 15:53:11 UTC, Walter Bright wrote: On 8/23/2017 7:10 AM, Steven Schveighoffer wrote: It's only if you do something that needs the runtime, such as static ctors, or use the GC. Or use asserts, or even declare a struct. No structs in -betterC ???

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: D on Tiobe Index

2017-08-31 Thread SrMordred via Digitalmars-d-announce
On Thursday, 31 August 2017 at 14:57:28 UTC, bitwise wrote: https://www.tiobe.com/tiobe-index/d/ What happened in 2009?

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: 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

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
Nice, thank you!

Re: compile D to asm.js using ldc --betterC and emcc

2017-11-14 Thread SrMordred via Digitalmars-d-announce
On Sunday, 8 October 2017 at 09:48:57 UTC, Dukc wrote: On Saturday, 7 October 2017 at 17:31:37 UTC, cosinus wrote: I wrote a little working demo that shows how to use D inside firefox. It uses emscripten(emcc) and ldc. https://github.com/cosinus2/dlang-emscripten-demo Judging by looking at

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(

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...

__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: __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
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: SublimeLinter-contrib-dmd: dmd feedback as you type

2017-10-31 Thread SrMordred via Digitalmars-d-announce
Thank you , works perfectly! One idea: Integrating with dub. So you don´t have to manually set lib dirs and flags since its all on 'dub.json' already.

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: 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

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?

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: 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

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: 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 () {

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: 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.

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: 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

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: 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 :)

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

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: 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. :)

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:

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

hasAliasing with nested static array bug ?

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

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);

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: I have a plan.. I really DO

2018-07-10 Thread SrMordred via Digitalmars-d-announce
As I've already repeated twice, this is not true in D. You *can* predict precisely when the GC runs a collection cycle by calling GC.disable and then calling GC.collect according to *your* own schedule. This is not just a theoretical thing. I have actually done this in my own projects, and

Re: I have a plan.. I really DO

2018-07-10 Thread SrMordred via Digitalmars-d-announce
On Tuesday, 10 July 2018 at 17:44:59 UTC, Adam D. Ruppe wrote: On Tuesday, 10 July 2018 at 17:39:06 UTC, SrMordred wrote: After the GC.collect you now get 1GB of memory usage. http://dpldocs.info/experimental-docs/core.memory.GC.minimize.html yeah I was looking to this right now on the

Re: I have a plan.. I really DO

2018-07-10 Thread SrMordred via Digitalmars-d-announce
On Tuesday, 10 July 2018 at 17:03:01 UTC, H. S. Teoh wrote: AFAIK, the current GC does not release memory back to the OS. So you won't see the memory footprint decrease. However, it does free up memory for subsequent allocations. T if you put another int[] x; x.length = 1024 * 1024 *

Re: I have a plan.. I really DO

2018-07-11 Thread SrMordred via Digitalmars-d-announce
But for technical aspect like performance, very honestly I'm still not sure of its technical superiority over similar languages. Just have a look at this one, which is quite famous : https://www.techempower.com/benchmarks/ I know that many people here will simply tell me that all those

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-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
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: #include C headers in D code

2018-04-09 Thread SrMordred via Digitalmars-d-announce
On Monday, 9 April 2018 at 11:03:48 UTC, Atila Neves wrote: Here's my blog post about my project that allows directly #including C headers in D* https://atilanevesoncode.wordpress.com/2018/04/09/include-c-headers-in-d-code/ The summary is that, modulo bugs, things like this work:

Re: Beta 2.082.0

2018-10-18 Thread SrMordred via Digitalmars-d-announce
On Wednesday, 17 October 2018 at 12:14:55 UTC, Martin Nowak wrote: Glad to announce the first beta for the 2.083.0 release, ♥ to the 48 contributors for this release. http://dlang.org/download.html#dmd_beta http://dlang.org/changelog/2.083.0.html As usual please report any bugs at

Re: BindBC -- The successor to Derelict

2018-10-19 Thread SrMordred via Digitalmars-d-announce
On Friday, 19 October 2018 at 17:34:10 UTC, Mike Parker wrote: In the 14.5 (!) years I've been maintaining the Derelict bindings, I've restructured the source tree a few times (Derelict 1 - 3 to DerelictOrg), had three implementations of the loader (that I can remember), switched from

  1   2   >