@safe status
Michel Fortin
michel.fortin at michelf.com
Mon Feb 8 12:17:01 PST 2010
On 2010-02-08 14:31:06 -0500, bearophile <bearophileHUGS at lycos.com> said:
> Michel Fortin:
>> I think SafeD as currently implemented has the right design, except
>> when it comes to passing delegates and functions as arguments to
>> templates or functions.
>
> The less significant bit of the function/delegate pointer can be used
> to denote safe/unsafe :o)
What would be the point?
The problem is when you have a safe function taking a delegate, like this:
@safe void test(void delegate() run) {
run();
}
void main() {
test({ writeln("hello world"); });
}
Here, the delegate literal is unsafe and you give it to a safe
function. The compiler disallow test() from calling run() because it is
unsafe. This is just too restricting. Do we really want to have to
create two versions of test(), one with a safe delegate the other with
an unsafe one?
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list