Archive for June, 2006
Sunday, June 18th, 2006
Matthew Wilson popped back in to D-Land long enough to announce a new release of his “recursive ls” library. The short list of fixes/changes from the NG post:
Notable additions to core are:
+ supports “~” for representing home directory to search/stat functions
+ Recls_SearchFeedback() - provides callbacks, throughout searching, for
each directory traversed
+ Recls_GetSelectedRoots() - gets the host system roots according to
type (fixed, network, optical, …)
+ Recls_CombinePaths() - combines path fragments
+ Recls_DeriveRelativePath() - determines the path of an target path
relative to an origin path
+ Recls_SqueezePath() - squeezes paths, using …, into fixed maximum
width
+ RECLS_F_USE_TILDE_ON_NO_SEARCHROOT flag - assumes home directory if
NULL
+ RECLS_F_IGNORE_HIDDEN_ENTRIES_ON_WIN32 flag - skips hidden files on
Win32 (UNIX support in next version)
The long list and download links are at over at the recls download page.
Technorati Tags: D Programming Language, recls, Synesis, Matthew Wilson
Posted in News | No Comments »
Saturday, June 17th, 2006
A limitation that I quickly ran into with my attempt at templated, inherited policies was D’s lack of support for multiple inheritance. Normally, I have no need for MI, but this is one case where it would have been neat to have. As long as a class uses one policy, the templated, inherited approach is good enough. To solve the multiple policy problem, I went with templated containment:
import std.stdio;
class Host(G, M)
{
G g;
M m;
void doSomething()
{
g.foo();
m.bar();
}
}
class GreetPolicy
{
void foo() { writefln("Hello World!"); }
}
class MeetPolicy
{
void bar() { writefln("Nice to meet you!"); }
}
void main()
{
Host!(GreetPolicy, MeetPolicy) h = new Host!(GreetPolicy, MeetPolicy);
h.doSomething();
Host!(GreetPolicy, MeetPolicy) h2 =
new Host!(GreetPolicy, MeetPolicy)(new GreetPolicy(), new MeetPolicy());
h2.doSomething();
}
By using two constructors in the template, policies which require constructor args can still be used. The only drawback to this over the inheritance model is that the host does not inehrit the interface of the policies. The inheritance approach is pretty powerful in that regard. With the inheritance form of the template, if the host expects the policy to implement one non-private method but the policy actually implements more, the host inherits all of those methods as well. If there’s a way to mimic that with templated containment, I haven’t figured it out yet. Maybe someone else has?
Technorati Tags: D Programming, templates, generics, metaprogramming
Posted in Discussion | 1 Comment »
Friday, June 16th, 2006
I’m still a noob when it comes to templates in D (and in C++ for that matter). I have a basic understanding of what’s possible, but when people post complex templates on the NG I’m always left scratching my head. Today, I was working on a project and decided I wanted to implement a certain feature using a policy-based design. So I turned to my test folder (which I recently emptied, I do lots of little D tests to figure things out) and implemented policy.d:
import std.stdio;
class Host(T) : T
{
void doSomething()
{
T.foo();
}
}
class GreetPolicy
{
void foo() { writefln("Hello World!"); }
}
class GreetHost : Host!(GreetPolicy) { }
void main()
{
GreetHost host = new GreetHost();
host.doSomething();
Host!(GreetPolicy) h = new Host!(GreetPolicy);
h.doSomething();
}
I can’t stop thinking how cool that is. First, I had no idea if I would be able to let Host subclass(T). Second, I was sure the first example usage would work, since that’s how I implement Singletons in D. But, the second useage, I wasn’t really sure of. I was quite stoked when the script ran and printed “Hello World” twice. I can’t wait to wrap my head around more template magic.
Technorati Tags: D Programming, templates, generics, metaprogramming
Posted in Discussion | 8 Comments »
Wednesday, June 14th, 2006
Eric Anderton has announced Enki 1.1. From his NG post:
Enki 1.1 Changes:
- enhancement: semantic analysis of binding types by search is now in
declaration order
- bug: repeated binding declarations in generated parser
- bug: binding names were output as ‘bind_x’ in the comments for some
expressions
- enhancement: added function-call capability to ‘@’ operator
- enhancement: added ‘&’ (custom-terminal) operator
- enhancement: added minimal sourcecode for custom parsers to binary
distribution
Technorati Tags: D Programming Language, Enki, tools, utilities, parsers
Posted in News | No Comments »
Tuesday, June 13th, 2006
Clay Smith has announced the first release of his Arc 2D Game Library. Arc is written in D on top of OpenGL and SDL. Additionally, he has published two Arc tutorials at DMedia (1, 2). Good work, Clay!
Technorati Tags: D Programming Language, game programming, game development, 2D game programming, SDL, OpenGL
Posted in Gamedev/Games, News | No Comments »