Re: Dgame revived

2015-03-16 Thread Foo via Digitalmars-d-announce
On Sunday, 15 March 2015 at 23:17:10 UTC, Joel wrote: On Sunday, 15 March 2015 at 22:51:17 UTC, Namespace wrote: On Sunday, 15 March 2015 at 22:30:06 UTC, Joel wrote: I've been getting these errors: I found two places that have 'package(Dgame):' - source\Dgame\Graphic\Color.d(30) and

Re: Dgame revived

2015-03-15 Thread Foo via Digitalmars-d-announce
I think a tutorial on how to do tile map with sprites would be awesome http://dgame-dev.de/?page=tutorialtut=tilemap

Passing variadic arguments to C

2015-02-22 Thread Foo via Digitalmars-d-learn
Is this possible? Example: void foo(Args...)(auto ref Args args) { sprintf(str.ptr, fmt.ptr, args); }

Re: Passing variadic arguments to C

2015-02-22 Thread Foo via Digitalmars-d-learn
On Sunday, 22 February 2015 at 17:20:23 UTC, Foo wrote: On Sunday, 22 February 2015 at 17:15:06 UTC, anonymous wrote: On Sunday, 22 February 2015 at 17:09:27 UTC, Foo wrote: Is this possible? Example: void foo(Args...)(auto ref Args args) { sprintf(str.ptr, fmt.ptr, args); } yes

Re: Passing variadic arguments to C

2015-02-22 Thread Foo via Digitalmars-d-learn
On Sunday, 22 February 2015 at 17:15:06 UTC, anonymous wrote: On Sunday, 22 February 2015 at 17:09:27 UTC, Foo wrote: Is this possible? Example: void foo(Args...)(auto ref Args args) { sprintf(str.ptr, fmt.ptr, args); } yes I get the error, that I cannot pass a dynamic array

Re: const member function

2015-02-21 Thread Foo via Digitalmars-d-learn
On Saturday, 21 February 2015 at 06:38:18 UTC, rumbu wrote: Often I'm using the following code pattern: class S { private SomeType cache; public SomeType SomeProp() @property { if (cache is null) cache = SomeExpensiveOperation(); return cache; } } Is there any

Re: const member function

2015-02-21 Thread Foo via Digitalmars-d-learn
On Saturday, 21 February 2015 at 15:26:28 UTC, ketmar wrote: On Sat, 21 Feb 2015 08:27:13 +, rumbu wrote: My question was not how I do this, I know already. My question was if there is another way to safely call a non-const instance function on a const object. is there a way to been

Re: What is the Correct way to Malloc in @nogc section?

2015-02-21 Thread Foo via Digitalmars-d-learn
On Saturday, 21 February 2015 at 14:39:47 UTC, anonymous wrote: On Saturday, 21 February 2015 at 13:41:41 UTC, Foo wrote: Finally, I tried to take your criticism objectively and, as far as I can tell, I resolved the issues. Is there still any objections or misconduct? Nice. I think you fixed

Re: What is the Correct way to Malloc in @nogc section?

2015-02-21 Thread Foo via Digitalmars-d-learn
On Friday, 13 February 2015 at 22:55:27 UTC, anonymous wrote: On Thursday, 12 February 2015 at 23:52:41 UTC, Foo wrote: This is something I've done recently. Would be glad if my code will help you: https://github.com/Dgame/m3 Especially the m3.d module could be useful for you. /* Class and

Re: GC has a barbaric destroyng model, I think

2015-02-13 Thread Foo via Digitalmars-d-learn
On Friday, 13 February 2015 at 08:00:43 UTC, Kagamin wrote: On Thursday, 12 February 2015 at 17:29:34 UTC, Foo wrote: And since today it is @safe wherever possible. Well, you marked functions @trusted rather indiscriminately :) Such approach doesn't really improve safety, and the code could

Re: GC has a barbaric destroyng model, I think

2015-02-13 Thread Foo via Digitalmars-d-learn
On Friday, 13 February 2015 at 09:28:30 UTC, Kagamin wrote: On Friday, 13 February 2015 at 09:11:26 UTC, Foo wrote: And I wouldn't say indiscriminately. Every function I marked with @trusted was checked by me so far. What did you check them for? :) Just first example: make and destruct, being

Re: What is the Correct way to Malloc in @nogc section?

2015-02-13 Thread Foo via Digitalmars-d-learn
On Friday, 13 February 2015 at 22:55:27 UTC, anonymous wrote: On Thursday, 12 February 2015 at 23:52:41 UTC, Foo wrote: This is something I've done recently. Would be glad if my code will help you: https://github.com/Dgame/m3 Especially the m3.d module could be useful for you. /* Class and

Re: What is the Correct way to Malloc in @nogc section?

2015-02-13 Thread Foo via Digitalmars-d-learn
On Friday, 13 February 2015 at 23:13:05 UTC, anonymous wrote: On Friday, 13 February 2015 at 23:04:25 UTC, Foo wrote: Don't understand me wrong. My code is not perfect, but maybe it can be helpful for someone. As it is right now, I fear it may do more harm than good. Always the same in this

Re: This Week in D: Issue #4

2015-02-12 Thread Foo via Digitalmars-d-announce
On Thursday, 12 February 2015 at 10:06:43 UTC, Dominikus Dittes Scherkl wrote: On Wednesday, 11 February 2015 at 14:32:46 UTC, Adam D. Ruppe wrote: On Wednesday, 11 February 2015 at 11:21:46 UTC, Dominikus Dittes Scherkl wrote: Did I missed issue #5 ? No, I did; I was sick most of last week

Re: What is the Correct way to Malloc in @nogc section?

2015-02-12 Thread Foo via Digitalmars-d-learn
On Thursday, 12 February 2015 at 23:27:51 UTC, Kitt wrote: I'm currently trying to write a personal Associate Array class that can be used in @nogc sections. Obviously, this means I'll want to use malloc/free, however I'm not sure what the Correct way to do this is. In a few places online I've

Re: GC has a barbaric destroyng model, I think

2015-02-12 Thread Foo via Digitalmars-d-learn
On Thursday, 12 February 2015 at 14:44:07 UTC, Kagamin wrote: On Thursday, 12 February 2015 at 12:52:03 UTC, Andrey Derzhavin wrote: If we can't relay on GC wholly, there is no need for GC. All of the objects, that I can create, I can destroy manually by myself, without any doubtful GC

Re: Module for manual memory management

2015-02-07 Thread Foo via Digitalmars-d
On Saturday, 7 February 2015 at 11:29:51 UTC, Jacob Carlborg wrote: On 2015-02-04 21:55, Walter Bright wrote: No need to reinvent this: https://github.com/D-Programming-Language/phobos/blob/master/std/file.d line 194 Just for the record, you can get a link to the exact line by

Re: Should we remove int[$] before 2.067?

2015-02-07 Thread Foo via Digitalmars-d
Maybe someone should remove this from the Changelog? http://dlang.org/changelog.html#partial-type

Re: Module for manual memory management

2015-02-05 Thread Foo via Digitalmars-d
On Thursday, 5 February 2015 at 07:53:34 UTC, Andrei Alexandrescu wrote: On 2/4/15 11:48 PM, Foo wrote: I would be glad if you or Walter could review the other parts as well. I'm very sure that your review will be very helpful and I'm convinced that the modules Array or Smart Pointer could be

Re: Module for manual memory management

2015-02-04 Thread Foo via Digitalmars-d
For what it's worth, today I finished the current work. Now we will start working with it. If someone has critique, improvement suggestions or want to take some ideas, he is free to do so. To repeat myself: we rewrote some functionality which already existed in D, but were improvable. For

Re: Module for manual memory management

2015-02-04 Thread Foo via Digitalmars-d
On Wednesday, 4 February 2015 at 20:55:59 UTC, Walter Bright wrote: On 2/4/2015 12:42 PM, Foo wrote: On Wednesday, 4 February 2015 at 20:15:37 UTC, Andrei Alexandrescu wrote: @trusted @nogc char[] read(const string filename) nothrow { Yes that is correct, currently there is no error checking,

Re: Module for manual memory management

2015-02-04 Thread Foo via Digitalmars-d
On Wednesday, 4 February 2015 at 20:15:37 UTC, Andrei Alexandrescu wrote: On 2/4/15 9:13 AM, Foo wrote: For what it's worth, today I finished the current work. Now we will start working with it. If someone has critique, improvement suggestions or want to take some ideas, he is free to do so.

Re: Module for manual memory management

2015-02-04 Thread Foo via Digitalmars-d
On Wednesday, 4 February 2015 at 20:55:59 UTC, Walter Bright wrote: On 2/4/2015 12:42 PM, Foo wrote: On Wednesday, 4 February 2015 at 20:15:37 UTC, Andrei Alexandrescu wrote: @trusted @nogc char[] read(const string filename) nothrow { Yes that is correct, currently there is no error checking,

Re: Module for manual memory management

2015-02-04 Thread Foo via Digitalmars-d
On Wednesday, 4 February 2015 at 20:15:37 UTC, Andrei Alexandrescu wrote: On 2/4/15 9:13 AM, Foo wrote: For what it's worth, today I finished the current work. Now we will start working with it. If someone has critique, improvement suggestions or want to take some ideas, he is free to do so.

Re: Want to read a whole file as utf-8

2015-02-04 Thread Foo via Digitalmars-d-learn
Since I'm now almost finished, I'm glad to show you my work: https://github.com/Dgame/m3 You're free to use it or to contribute to it.

Re: Improving reviewing and scrutiny

2015-02-04 Thread Foo via Digitalmars-d
On Wednesday, 4 February 2015 at 23:01:48 UTC, Andrei Alexandrescu wrote: I just stepped into a disaster zone in std.file and submitted https://issues.dlang.org/show_bug.cgi?id=14125. This reveals the merits of reviewing pull requests carefully, and the issues that can crop in when that

Want to read a whole file as utf-8

2015-02-03 Thread Foo via Digitalmars-d-learn
How can I do that without any GC allocation? Nothing in std.file seems to be marked with @nogc I'm asking since it seems very complicated to do that with C++, maybe D is a better choice, then we would probably move our whole project from C++ to D.

Re: Want to read a whole file as utf-8

2015-02-03 Thread Foo via Digitalmars-d-learn
On Tuesday, 3 February 2015 at 19:56:37 UTC, FG wrote: On 2015-02-03 at 20:50, Tobias Pankrath wrote: Use std.utf.validate instead of decode. It will only allocate one exception if necessary. Looks to me like it uses decode internally... But Foo, do you have to use @nogc? It still looks like

Re: Want to read a whole file as utf-8

2015-02-03 Thread Foo via Digitalmars-d-learn
On Tuesday, 3 February 2015 at 19:44:49 UTC, FG wrote: On 2015-02-03 at 19:53, Foo wrote: How can I do that without any GC allocation? Nothing in std.file seems to be marked with @nogc I'm asking since it seems very complicated to do that with C++, maybe D is a better choice, then we would

Re: Conway's game of life

2015-02-01 Thread Foo via Digitalmars-d-learn
On Sunday, 1 February 2015 at 21:00:07 UTC, gedaiu wrote: Hi, I implemented Conway's game of life in D. What do you think that I can improve to this program to take advantage of more D features? https://github.com/gedaiu/Game-Of-Life-D Thanks, Bogdan For each remove you create a new array.

Re: Module for manual memory management

2015-01-31 Thread Foo via Digitalmars-d
On Saturday, 31 January 2015 at 01:07:21 UTC, Andrei Alexandrescu wrote: On 1/30/15 3:49 PM, Foo wrote: Is there interest in such a thing? I'm currently working on something for my own use and I'm curious if anyone else would be interested in something like that. I'm aware of Unique,

Re: Module for manual memory management

2015-01-31 Thread Foo via Digitalmars-d
On Saturday, 31 January 2015 at 01:07:21 UTC, Andrei Alexandrescu wrote: On 1/30/15 3:49 PM, Foo wrote: Is there interest in such a thing? I'm currently working on something for my own use and I'm curious if anyone else would be interested in something like that. I'm aware of Unique,

Re: Should we remove int[$] before 2.067?

2015-01-30 Thread Foo via Digitalmars-d
On Friday, 30 January 2015 at 17:37:44 UTC, Nick Treleaven wrote: On 30/01/2015 16:53, Nick Treleaven wrote: This version of staticArray allows the user to (optionally) specify the element type. Actually, I'm having trouble implementing staticArray like that, perhaps there are compiler

Re: Should we remove int[$] before 2.067?

2015-01-30 Thread Foo via Digitalmars-d
On Friday, 30 January 2015 at 19:07:53 UTC, Andrei Alexandrescu wrote: On 1/30/15 10:40 AM, Foo wrote: On Friday, 30 January 2015 at 17:37:44 UTC, Nick Treleaven wrote: On 30/01/2015 16:53, Nick Treleaven wrote: This version of staticArray allows the user to (optionally) specify the element

Module for manual memory management

2015-01-30 Thread Foo via Digitalmars-d
Is there interest in such a thing? I'm currently working on something for my own use and I'm curious if anyone else would be interested in something like that. I'm aware of Unique, RefCounted, Scoped, emplace and so on, but I'm not a big fan of some implementations (in my opinion not much of

Re: Arrays, garbage collection

2015-01-30 Thread Foo via Digitalmars-d
On Friday, 30 January 2015 at 01:08:31 UTC, bearophile wrote: The D type inference for array literals is now more flexible: void main() { auto[$][$] m1 = [[1, 2], [3, 4], [5, 6]]; pragma(msg, typeof(m1)); // int[2][3] const auto[string] aa1 = [red: 1, blue: 2]; pragma(msg,

Re: accept @pure @nothrow @return attributes

2015-01-26 Thread Foo via Digitalmars-d
On Monday, 26 January 2015 at 16:10:53 UTC, Jonathan Marler wrote: I agree with Jonathan's points, this solution doesn't seem like an improvement. If I understand the problem, we don't want to make every attribute use the '@' symbol because it looks bad and would cause a lot of code changes

Re: accept @pure @nothrow @return attributes

2015-01-26 Thread Foo via Digitalmars-d
On Monday, 26 January 2015 at 21:25:57 UTC, Jonathan Marler wrote: On Monday, 26 January 2015 at 21:12:50 UTC, Walter Bright wrote: On 1/26/2015 12:45 PM, Jonathan Marler wrote: Just because they are function attributes does not mean they were tokenized as keywords. The lexer has no idea

Re: accept @pure @nothrow @return attributes

2015-01-26 Thread Foo via Digitalmars-d
On Monday, 26 January 2015 at 21:41:31 UTC, Jonathan Marler wrote: On Monday, 26 January 2015 at 21:28:14 UTC, Foo wrote: On Monday, 26 January 2015 at 21:25:57 UTC, Jonathan Marler wrote: On Monday, 26 January 2015 at 21:12:50 UTC, Walter Bright wrote: On 1/26/2015 12:45 PM, Jonathan Marler

Re: Fastest Way of Accessing Entries in an AA

2015-01-08 Thread Foo via Digitalmars-d-learn
On Thursday, 8 January 2015 at 23:06:39 UTC, Nordlöw wrote: On Thursday, 8 January 2015 at 16:11:07 UTC, ketmar via Digitalmars-d-learn wrote: how can it? compiler doesn't know what the code is supposed to do. if compilers will know such things someday, we can stop writing programs altogether,

Re: D idioms list

2015-01-08 Thread Foo via Digitalmars-d-announce
I saw recently (at last in this thread: http://forum.dlang.org/thread/tdfydchrairigdlgt...@forum.dlang.org#post-qakiogaqvmiwlneimhgu:40forum.dlang.org) that many users use key in aa ? aa[key] : ValueType.init; instead of auto ptr = key in aa; ptr ? *ptr : ValueType.init;

Re: Fastest Way of Accessing Entries in an AA

2015-01-08 Thread Foo via Digitalmars-d-learn
On Friday, 9 January 2015 at 06:18:53 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: On Friday, January 09, 2015 00:20:07 Foo via Digitalmars-d-learn wrote: On Thursday, 8 January 2015 at 23:06:39 UTC, Nordlöw wrote: On Thursday, 8 January 2015 at 16:11:07 UTC, ketmar via Digitalmars-d

Re: D idioms list

2015-01-08 Thread Foo via Digitalmars-d-announce
On Thursday, 8 January 2015 at 20:00:11 UTC, Foo wrote: On Thursday, 8 January 2015 at 10:21:26 UTC, ponce wrote: I've started a list of curated D tips and tricks here: http://p0nce.github.io/d-idioms/ Anything that you wished you learned earlier at one point in the D world is welcome to be

VLA in Assembler

2014-12-17 Thread Foo via Digitalmars-d-learn
Hi, Could someone explain me, if and how it is possible to allocate a variable length array with inline assembly? Somewhat like int[] arr; int n = 42; asm { // allocate n stack space for arr } I know it is dangerous and all that, but I just want it know. ;)

Re: VLA in Assembler

2014-12-17 Thread Foo via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 10:59:09 UTC, bearophile wrote: Foo: Hi, Could someone explain me, if and how it is possible to allocate a variable length array with inline assembly? Somewhat like int[] arr; int n = 42; asm { // allocate n stack space for arr } I know it is

Re: VLA in Assembler

2014-12-17 Thread Foo via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 12:15:23 UTC, uri wrote: On Wednesday, 17 December 2014 at 11:39:43 UTC, Foo wrote: On Wednesday, 17 December 2014 at 10:59:09 UTC, bearophile wrote: Foo: Hi, Could someone explain me, if and how it is possible to allocate a variable length array with

Re: VLA in Assembler

2014-12-17 Thread Foo via Digitalmars-d-learn
And it is using malloc... ;) I wanted something that increases the stack pointer ESP. e.g. void main() { int[] arr; int n = 42; writeln(arr.length); writeln(arr.ptr); asm { mov EAX, n; mov [arr + 8],

Re: VLA in Assembler

2014-12-17 Thread Foo via Digitalmars-d-learn
On Wednesday, 17 December 2014 at 16:10:40 UTC, Adam D. Ruppe wrote: On Wednesday, 17 December 2014 at 14:11:32 UTC, Foo wrote: asm { mov EAX, n; mov [arr + 8], ESP; sub [ESP], EAX; mov [arr + 0], EAX; } but that

Re: German D Community?

2014-12-01 Thread Foo via Digitalmars-d-announce
On Monday, 1 December 2014 at 09:38:35 UTC, trgy wrote: On Monday, 1 December 2014 at 09:22:47 UTC, Stefan Koch wrote: On Monday, 1 December 2014 at 09:17:42 UTC, trgy wrote: Hello, is there a german D community? I cannot find a forum/wiki or something else. I hope you can help me. :)

Re: Scope and Ref and Borrowing

2014-11-14 Thread Foo via Digitalmars-d
Remembers me a bit of http://wiki.dlang.org/DIP36

Re: RFC: moving forward with @nogc Phobos

2014-09-30 Thread Foo via Digitalmars-d
On Tuesday, 30 September 2014 at 13:38:43 UTC, Foo wrote: I hate the fact that this will produce template bloat for each function/method. I'm also in favor of let the user pick, but I would use a global variable: enum MemoryManagementPolicy { gc, rc, mrc } immutable gc =

Re: RFC: moving forward with @nogc Phobos

2014-09-30 Thread Foo via Digitalmars-d
I hate the fact that this will produce template bloat for each function/method. I'm also in favor of let the user pick, but I would use a global variable: enum MemoryManagementPolicy { gc, rc, mrc } immutable gc = ResourceManagementPolicy.gc, rc = ResourceManagementPolicy.rc,

Re: RFC: moving forward with @nogc Phobos

2014-09-30 Thread Foo via Digitalmars-d
On Tuesday, 30 September 2014 at 13:59:23 UTC, Andrei Alexandrescu wrote: On 9/30/14, 6:38 AM, Foo wrote: I hate the fact that this will produce template bloat for each function/method. I'm also in favor of let the user pick, but I would use a global variable: enum

Re: is there any reason UFCS can't be used with 'new'?

2014-09-28 Thread Foo via Digitalmars-d-learn
On Sunday, 28 September 2014 at 19:11:23 UTC, Jay wrote: i want to chain 'new' with method calls on the created object. i found this on the internet: window.mainWidget = (new Button()).text(Hello worldd).textColor(0xFF); it would look much nicer with UFCS: window.mainWidget =

Re: Escaping the Tyranny of the GC: std.rcstring, first blood

2014-09-27 Thread Foo via Digitalmars-d
Consider: struct MyRefCounted void opInc(); void opDec(); int x; } MyRefCounted a; a.x = 42; MyRefCounted b = a; b.x = 43; What is a.x after this? Andrei a.x == 42 a.ref_count == 1 (1 for init, +1 for copy, -1 for destruction) b.x == 43 b.ref_count == 1 (only init)

Re: Escaping the Tyranny of the GC: std.rcstring, first blood

2014-09-27 Thread Foo via Digitalmars-d
On Saturday, 27 September 2014 at 19:11:08 UTC, Andrei Alexandrescu wrote: On 9/27/14, 1:11 AM, Foo wrote: Consider: struct MyRefCounted void opInc(); void opDec(); int x; } MyRefCounted a; a.x = 42; MyRefCounted b = a; b.x = 43; What is a.x after this? Andrei a.x == 42

Re: Multiple alias this is coming.

2014-09-18 Thread Foo via Digitalmars-d-announce
On Thursday, 18 September 2014 at 18:38:57 UTC, Ali Çehreli wrote: On 09/18/2014 04:20 AM, IgorStepanov wrote: I've created pull request, which introduces multiple alias this. https://github.com/D-Programming-Language/dmd/pull/3998 Please see the additional tests and comment it. Awesome!

Re: Programming a Game in D? :D

2014-08-02 Thread Foo via Digitalmars-d-learn
On Saturday, 2 August 2014 at 20:38:59 UTC, David wrote: Hi, not too sure if there's still someone reading this post, but i do have another question. So, I heared so much good stuff about D, it's powerfull, fast the syntax is nice, but well, why is D actually not used for common games yet? (I

mixin assembler does not work?

2014-07-21 Thread Foo via Digitalmars-d-learn
Hey guys. Can someone explain me, why this code does only works with the inline assembler version but not with the mixin? Thanks in advance! Code: import std.stdio : writeln; import std.conv : to; template Vala(uint count, alias arr) { immutable string c = to!string(count);

Re: mixin assembler does not work?

2014-07-21 Thread Foo via Digitalmars-d-learn
For clarification: how would that work without mixin + string?

Re: mixin assembler does not work?

2014-07-21 Thread Foo via Digitalmars-d-learn
On Sunday, 20 July 2014 at 14:44:07 UTC, sigod wrote: On Sunday, 20 July 2014 at 14:18:58 UTC, Foo wrote: template Vala(uint count, alias arr) { immutable string c = to!string(count); enum Vala = asm { sub ESP, ~ c ~ ; mov ~ arr.stringof ~ , ~ c ~ ; mov ~ arr.stringof ~ + 4,

Re: mixin assembler does not work?

2014-07-21 Thread Foo via Digitalmars-d-learn
On Sunday, 20 July 2014 at 14:46:32 UTC, bearophile wrote: enum Vala(uint count, alias arr) = format( asm { sub ESP, %d; // Reserve 'count' bytes mov %s, %d; // Set a.length = 'count' mov %s + 4, ESP; // Set a[0] to reserved bytes }, count, arr.stringof,

Re: mixin assembler does not work?

2014-07-21 Thread Foo via Digitalmars-d-learn
On Sunday, 20 July 2014 at 14:55:00 UTC, Foo wrote: For clarification: how would that work without mixin + string? I tried this: mixin template Vala2(uint count, alias arr) { asm { sub ESP, count; mov arr, count; mov arr + 4, ESP;

Re: mixin assembler does not work?

2014-07-21 Thread Foo via Digitalmars-d-learn
On Sunday, 20 July 2014 at 15:54:15 UTC, bearophile wrote: mixin template Vala2(uint count, alias arr) { What about disallowing mixin templatename unless you add mixin before the template keyword? Bye, bearophile I do not understand?