assert(obj) is a mystery

2011-11-08 Thread Davidson Corry
Over on the digitalmars.D newsgroup, On 11/8/2011 2:35 PM, Alex Rønne Petersen wrote (in a thread entitled "assert(obj) is an atrocity"): > Hi, > > As the title suggests, I'm going to be rather blunt about this. > assert(obj) testing the invariant *without* doing a null check is insane > for the f

immutable & alias this

2011-11-08 Thread bearophile
I find typedef useful still. While trying to create a poor's man typedef using a struct with alis this, I have found this problem: struct Typedef(T) { T data; alias data this; } alias int[] TA1; typedef int[] TA2; alias Typedef!(int[]) TA3; immutable TA1 a1; immutable TA2 a2; TA3 a3a;

web development in D programming

2011-11-08 Thread bioinfornatics
Dear, After read this thread: http://www.digitalmars.com/d/archives/digitalmars/D/learn/Web_Development_27414.html and this one: http://www.digitalmars.com/d/archives/digitalmars/D/learn/How_To_Dynamic_Web_Rendering_26770.html I am a little disapointed, so if you have many request for a web page t

Re: Is this a bug in __traits(hasMember..)?

2011-11-08 Thread Tobias Pankrath
http://d.puremagic.com/issues/show_bug.cgi?id=6910

Re: Is this a bug in __traits(hasMember..)?

2011-11-08 Thread Robert Clipsham
On 08/11/2011 20:09, Tobias Pankrath wrote: which is very confusing to me. Guess this is a bug? Tobias Looks like a bug to me. This works: struct Bag(S...) { alias S Types; } template Test(/*alias i,*/ B) { void fn() { foreach(t; B.Types) { pragma(msg,

Re: AI Challenge - Ants

2011-11-08 Thread bearophile
maarten van damme: > But I have also lost interest because of a couple of shortcommings, the > hell it is to debug that thing and when it finally compiles fine on 2 > machines it gives a cryptic error about glue.c (that had something to do > with rdmd) What is the message of this cryptic error, a

Re: AI Challenge - Ants

2011-11-08 Thread Marco Leise
Am 08.11.2011, 21:04 Uhr, schrieb maarten van damme : I have stolen an isvisible method from the c# bot bool isVisible(Loc loc){ Loc[] offsets; int squares = cast(int)floor(sqrt(_viewradius2)); for (int r = -1 * squares; r <= squares; ++r){ for (int c = -1 * squares; c <= squares; ++c){ int

Is this a bug in __traits(hasMember..)?

2011-11-08 Thread Tobias Pankrath
Please take a look at this code struct Bag(S...) { alias S Types; } template Test(alias i, B) { void fn() { foreach(t; B.Types) { switch(i) { case IndexOf!(t, B.Types): { pragma(msg, __tra

Re: AI Challenge - Ants

2011-11-08 Thread maarten van damme
I have stolen an isvisible method from the c# bot bool isVisible(Loc loc){ Loc[] offsets; int squares = cast(int)floor(sqrt(_viewradius2)); for (int r = -1 * squares; r <= squares; ++r){ for (int c = -1 * squares; c <= squares; ++c){ int square = r * r + c * c; if (square < _viewradius2){ Loc new

Re: What is shared functions?

2011-11-08 Thread Marco Leise
Am 23.10.2011, 21:51 Uhr, schrieb bearophile : Jonathan M Davis: my general take on it is that dmd should _never_ ignore attributes, I agree. Such sloppiness is a very good source for problems, long term ones too, and it makes it harder to learn D. Bye, bearophile +1 For example I stil

Re: AI Challenge - Ants

2011-11-08 Thread Marco Leise
Am 23.10.2011, 19:52 Uhr, schrieb Jesse Phillips : On Sun, 23 Oct 2011 16:24:09 +0200, maarten van damme wrote: I'm noticing some problems, there are some methods missing used in the tutorial like "unocupied", the do_setup part and the visible method. Is this package complete or am I missing

Re: extends and implements

2011-11-08 Thread Kagamin
Jesse Phillips Wrote: > The second is when I want to find its definition. Hmmm, should I be > greping for /class Window/, /interface Window/, or /struct Window/ [a-z]* Window ?

Re: Filling a Tuple-like struct in variadic member

2011-11-08 Thread RivenTheMage
> Or do you really need assignField to work with runtime values ? Yes, that's the problem.

Re: Filling a Tuple-like struct in variadic member

2011-11-08 Thread Philippe Sigaud
On Tue, Nov 8, 2011 at 12:21, RivenTheMage wrote: > Is it possible to do such thing without using string mixin? Hi, you can use another tuple: struct Key(T...) { T fields; uint numFields = T.length; void assignFields(U...)(U args) if (U.length == T.length) { foreach(i,

Filling a Tuple-like struct in variadic member

2011-11-08 Thread RivenTheMage
Is it possible to do such thing without using string mixin? import std.stdio; import std.metastrings; struct Key(T...) { static string declareFields() // compile-time { string declaration; foreach (index, type; T)

Re: Any othe options for inserting into associative array?

2011-11-08 Thread Richard Webb
I just looked at my local Juno source, and it does have the change that i mentioned in that forum post. I just added an extra version of opAssign: void opAssign(R)(R dg) if (is (R : MethodProxy) ) { method = dg.method; returnType = dg.returnType; paramTypes = dg.paramTypes; } I