Take the 2-minute tour ×

I have the following code in D

import std.stdio;

class Thing
  // Fields
  private string Name;
  // Accessors
  public string name() { return Name; }

class Place: Thing
  // Fields
  private Place[string] Attached;
  // Modifiers
  public void attach(Place place) { Attached[place.name()] = place; }
  public void detach(Place place) { Attached.remove[place.name()]; }  // error line

Whenever I try to compile with dmd2.0 I get the following errors

Error: function core.stdc.stdio.remove (in const(char*) filename) is not callable using argument types (Place[string])
Error: cannot implicitly convert expression (this.Attached) of type Place[string] to const(char*)
Error: remove((__error)) must be an array or pointer type, not int

The current D2.0 documentation advices to use array.remove[key] for what I'm trying to do, but it looks like the compiler thinks I'm trying to call a std.c(stdc?) function. Why would this be occurring? Is this just a bug in dmd2.0?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

Try using


Notice the use of parentheses instead of square brackets. Square brackets are used for indexing only.

share|improve this answer
Oh gods, of course. –  Eli Aug 4 '10 at 21:02
That is a really bad error message... :( –  BCS Aug 5 '10 at 14:32
Yes, it is. The reason for the error is because D allows you to call functions of the type fun(a) using a.fun so it begins by deducing that you are trying to call core.c.stdio.remove and then tries to work from there. –  Peter Alexander Aug 6 '10 at 16:04
Thanks for the background, hopefully that will elucidate future errors for me. –  Eli Aug 9 '10 at 14:53
add comment

Your Answer


