On 2013-09-15 19:34, matovitch wrote:
Hi everyone,

I read the documentation about user defined attributes, but I don't see
their uses.

I'm using it in my serialization library:

struct Foo
{
    int a;
    @nonSerialized int b;
}

Indicates "b" will not be serialized.

struct Bar
{
    int a;

    @onSerializing void foo ()
    {
        // called when "Bar" is being serialized
    }
}

"foo" will be called when "Bar" is being serialized

For another project I'm using it as part of a testing framework:

@describe("Lexer")
{
    @context("valid string literal")
    {
@it("should return a token with the type TokenKind.stringLiteral") unittest
        {
            auto code = `"asd"`;
            auto lexer = new Lexer(code);

            assert(lexer.scan.kind == TokenKind.stringLiteral);
        }
    }
}

--
/Jacob Carlborg

Reply via email to