Reddit: SafeD - The Safe Subset of D
Kevin Bealer
kevinbealer at gmail.com
Tue Mar 25 10:48:25 PDT 2008
Walter Bright Wrote:
> Clay Smith wrote:
> > Is SafeD just a label for the programmer selectively using D features?
>
> Yes, but it would also be enforced by a compiler switch.
When a project gets to a certain size you will often want to add some unsafe
code, but a switch suggests that the whole file (or project) now has to be safe
or unsafe as a single block. A version statement could be used to mark the
unsafe areas of an otherwise "safe" file:
version(unsafe) {
some code;
}
or
version(unsafe):
This allows islands of unsafety. A compiler switch could be defined as a way of disabling
all unsafe code within a module, then an "unsafe" marker in a class could indicate parts of the API that are hidden from "safe" code.
class MyVector {
int foo();
int bar();
unsafe:
int baz();
};
MyVector v...;
v.baz(); // error
version(unsafe) {
b.baz(); // okay
}
Is the "in" operator (for AAs) safe?
Kevin
More information about the Digitalmars-d-announce
mailing list