Make your own free website on Tripod.com

MKoD - D Programming Language

D-Sourcery, variant thru the boxer template in D - code-name Boxed.d

Very Kool! Boxer template example:

/+
 ' Source  : Boxed.d - example of the box / unbox template
 ' Author  : Burton Radons (burton-radons[at]smocky[dot]com)
 ' Created : 06-May-2005
 ' Ref     : http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=23272
 ' ----------------------------------------------------------------------------
 ' Note   : When using the std.boxer module, always compile with the "-release"
 '          dmd commandline switch, otherwise you'll get a linker error.
 +/
private import std.stdio;
private import std.boxer; // now in D v0.124

void main()
{
    Box x = box(4);
    int y = unbox!(int)(x);       

    Box z = box("foobar");
    char[] w = unbox!(char[])(z); 

    writefln("y=%d", y);
    writefln("w=%s", w);
}
C:\dmd>dmd boxed.d -release
C:\dmd\bin\..\..\dm\bin\link.exe boxed,,,user32+kernel32/noi;

C:\dmd>boxed
y=4
w=foobar

C:\dmd>
Mars: fourth Rock from the Sun.