Counter-Proposal: restrict & tagged functions
Dmitry Olshansky
dmitry.olsh at gmail.com
Sat Sep 1 14:51:08 PDT 2012
On 02-Sep-12 01:13, foobar wrote:
[snip]
>
> I skipped the details but I do agree with the general sentiment.
> This long post begs the question - Why a general annotation
> mechanism isn't enough to justify adding so much complexity to
> the language?
It's quite short compared to all of the features it replaces and it had
to allow for backwards compatibility. And it had to leave place for
other @annotations as I felt restricting blocks of code is not the only
use case for annotations.
Also sadly it reiterates a lot of trivia around how tagged functions and
pointers interact with each another.
About general annotation mechanism. Nobody yet put together a proper
proposal (if any at all), all I see is people that keep saying: "it's
simple - just add the general annotation mechanism!".
> Me thinks that simply tagging malloc/alloca/GC.allocate/etc..
> with a _user defined_ annotation should be sufficient without the
> need to introduce all of the above syntax to the language.
Simple tags have no much use on their own - need syntax to use them.
The compiler can deduce their meaning so you also need a way tell the
compiler: this function can only use "yellow" and "green" functions.
Then some tags need to be compatible (or convertible with others), then
there is a need to bundle tags together and so on.
I agree that simply tagging functions with red/green is attractive and
simple concept but to implement things like say @safe you need more then
that. You need to tweak what compiler puts in there for you (and
forbid/allow as it suits your needs).
In
> fact, I have a vague memory of reading about green/red marking of
> code via templates in plain old c++. No extra syntax required.
>
But xxtra works obviously :)
The method entails carrying around tag arguments apparently. It could be
labeled as creative but a very backward way to do something simple. More
specifically it shows that this has to be a language feature so that
developers can focus on using it instead of being busy implementing it
by hand.
> Here's the link:
> http://www.artima.com/cppsource/codefeaturesP.html
--
Olshansky Dmitry
More information about the Digitalmars-d
mailing list