Proposal: user defined attributes

Kapps opantm2+spam at gmail.com
Fri Mar 16 18:00:41 PDT 2012


On Saturday, 17 March 2012 at 00:54:02 UTC, Andrej Mitrovic wrote:
> On 3/17/12, Kapps <opantm2+spam at gmail.com> wrote:
>> @WebForm("Account");
>> @PostTo("Services/CreateAccount")
>> @SecureOnly(true)
>> struct CreateAccountForm {
>
> That kind of turns D from a structural to a declarative 
> language. :p

Web design is quite a declarative thing. :) The code is already 
written for you, why bother writing it again instead of just 
writing it once and passing along essentially parameters to it.

Anywho, something like that is a somewhat extreme case. Basic 
things include @serializable or @notserialized (or 
@serialized(false)). With the topic of dynamic/scripting 
languages, other things can include @scripted to indicate a 
method or class can be accessed from the script, or 
@scripted(Security.low) to indicate user scripts can access it 
and not just game scripts. This prevents having to make annoying 
bindings and communicate what's passed in to the script compiler. 
Instead, you can find out everything that can be passed in at 
compile-time, and upon script compilation you can verify the 
script has access to all of these methods, then statically call 
them without any of the performance hit you would normally have 
by using scripting, yet with the safety.


More information about the Digitalmars-d mailing list