Thread overview
[phobos] I applied @safe, @trusted, @system to Phobos!
May 22, 2010
SHOO
May 22, 2010
Masahiro Nakagawa
May 23, 2010
Walter Bright
May 23, 2010
SHOO
May 23, 2010
Walter Bright
May 23, 2010
Shin Fujishiro
May 23, 2010
Sean Kelly
May 23, 2010
Walter Bright
May 23, 2010
Sean Kelly
May 22, 2010
I succeeded in applying @safe, @trusted, @system to Phobos after hardship.

I made a branch, please look:

http://svn.dsource.org/projects/phobos/branches/devel/applying_safe_system_trusted

I discovered some bugs and problems about @safe, @trusted, @system during my work.

1. Bugzilla 4211 - struct with annotation(@safe)
    See also http://d.puremagic.com/issues/show_bug.cgi?id=4211

2. Bugzilla 4218 - safe function cannot call opApply
    See also http://d.puremagic.com/issues/show_bug.cgi?id=4218

3. I cannot apply @safe to intrinsic operation(eg: std.math.sqrt)
    This causes mangling that had been influenced by @safe/@trusted.
    dmd converts a specific symbol into intrinsic operation. However,
dmd cannot convert symbols that are marked by @safe/@trusted.
    I am skeptical about the influence on mangling rule by @safe.

4. dmd should not allow overload between @safe/@trusted and @system
    Document says "Functions are overloaded based on how well the
arguments to a function can match up with the parameters."
    But @safe functions can overload between @system functions, though
@safe is unrelated to parameters.
    It's enough to have only @safe function.

5. druntime's modules are not applying @safe/@system/@trusted
    This shows that Exception, TypeInfo, Thread and others are not
usable by the @safe function virtually.

6. You must make the template function @trusted by all means
    When you use template, type that is maked @system may be handed to
parameters.
    Therefore @trusted is required.
    This means that every template functions cannot take benefits from
@safe.

7. Some mysterious compile errors
    When @safe unittest...
    Some functions are going to call opAssign. (eg: std.range(2670))
    Some functions are going to call __cpctor. (eg: std.stdio(165))
    Some functions are going to call ~this. (eg: std.stdio(872))
    (I try compile command: "dmd -I.. -c -o- -unittest -debug stdio.d")

Please do not make it an useless treasure.
I really wait for the day when this is used effectively.

May 22, 2010
Great work!


On Sat, 22 May 2010 20:36:50 +0900, SHOO <zan77137 at nifty.com> wrote:

> I succeeded in applying @safe, @trusted, @system to Phobos after hardship.
>
> I made a branch, please look:
>
> http://svn.dsource.org/projects/phobos/branches/devel/applying_safe_system_trusted
>
[snip]
> 4. dmd should not allow overload between @safe/@trusted and @system
>     Document says "Functions are overloaded based on how well the
> arguments to a function can match up with the parameters."
>     But @safe functions can overload between @system functions, though
> @safe is unrelated to parameters.
>     It's enough to have only @safe function.

I agree this point.
This complicates the overloading rule if allows.

> 5. druntime's modules are not applying @safe/@system/@trusted
>     This shows that Exception, TypeInfo, Thread and others are not
> usable by the @safe function virtually.
>
> 6. You must make the template function @trusted by all means
>     When you use template, type that is maked @system may be handed to
> parameters.
>     Therefore @trusted is required.
>     This means that every template functions cannot take benefits from
> @safe.
>
> 7. Some mysterious compile errors
>     When @safe unittest...
>     Some functions are going to call opAssign. (eg: std.range(2670))
>     Some functions are going to call __cpctor. (eg: std.stdio(165))
>     Some functions are going to call ~this. (eg: std.stdio(872))
>     (I try compile command: "dmd -I.. -c -o- -unittest -debug stdio.d")
>
> Please do not make it an useless treasure.
> I really wait for the day when this is used effectively.
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos

May 22, 2010
That's great work. Walter, any chance you'd give one extra iota of priority to the bugs Shoo discovered?

Thanks,

Andrei

On 05/22/2010 06:36 AM, SHOO wrote:
> I succeeded in applying @safe, @trusted, @system to Phobos after hardship.
>
> I made a branch, please look:
>
> http://svn.dsource.org/projects/phobos/branches/devel/applying_safe_system_trusted
>
> I discovered some bugs and problems about @safe, @trusted, @system during my work.
>
> 1. Bugzilla 4211 - struct with annotation(@safe)
>      See also http://d.puremagic.com/issues/show_bug.cgi?id=4211
>
> 2. Bugzilla 4218 - safe function cannot call opApply
>      See also http://d.puremagic.com/issues/show_bug.cgi?id=4218
>
> 3. I cannot apply @safe to intrinsic operation(eg: std.math.sqrt)
>      This causes mangling that had been influenced by @safe/@trusted.
>      dmd converts a specific symbol into intrinsic operation. However,
> dmd cannot convert symbols that are marked by @safe/@trusted.
>      I am skeptical about the influence on mangling rule by @safe.
>
> 4. dmd should not allow overload between @safe/@trusted and @system
>      Document says "Functions are overloaded based on how well the
> arguments to a function can match up with the parameters."
>      But @safe functions can overload between @system functions, though
> @safe is unrelated to parameters.
>      It's enough to have only @safe function.
>
> 5. druntime's modules are not applying @safe/@system/@trusted
>      This shows that Exception, TypeInfo, Thread and others are not
> usable by the @safe function virtually.
>
> 6. You must make the template function @trusted by all means
>      When you use template, type that is maked @system may be handed to
> parameters.
>      Therefore @trusted is required.
>      This means that every template functions cannot take benefits from
> @safe.
>
> 7. Some mysterious compile errors
>      When @safe unittest...
>      Some functions are going to call opAssign. (eg: std.range(2670))
>      Some functions are going to call __cpctor. (eg: std.stdio(165))
>      Some functions are going to call ~this. (eg: std.stdio(872))
>      (I try compile command: "dmd -I.. -c -o- -unittest -debug stdio.d")
>
> Please do not make it an useless treasure.
> I really wait for the day when this is used effectively.
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
May 22, 2010
These are great comments, please add each to their own bugzilla entry if they aren't already.

SHOO wrote:
> I succeeded in applying @safe, @trusted, @system to Phobos after hardship.
>
> I made a branch, please look:
>
> http://svn.dsource.org/projects/phobos/branches/devel/applying_safe_system_trusted
>
> I discovered some bugs and problems about @safe, @trusted, @system during my work.
>
> 1. Bugzilla 4211 - struct with annotation(@safe)
>     See also http://d.puremagic.com/issues/show_bug.cgi?id=4211
>
> 2. Bugzilla 4218 - safe function cannot call opApply
>     See also http://d.puremagic.com/issues/show_bug.cgi?id=4218
>
> 3. I cannot apply @safe to intrinsic operation(eg: std.math.sqrt)
>     This causes mangling that had been influenced by @safe/@trusted.
>     dmd converts a specific symbol into intrinsic operation. However,
> dmd cannot convert symbols that are marked by @safe/@trusted.
>     I am skeptical about the influence on mangling rule by @safe.
>
> 4. dmd should not allow overload between @safe/@trusted and @system
>     Document says "Functions are overloaded based on how well the
> arguments to a function can match up with the parameters."
>     But @safe functions can overload between @system functions, though
> @safe is unrelated to parameters.
>     It's enough to have only @safe function.
>
> 5. druntime's modules are not applying @safe/@system/@trusted
>     This shows that Exception, TypeInfo, Thread and others are not
> usable by the @safe function virtually.
>
> 6. You must make the template function @trusted by all means
>     When you use template, type that is maked @system may be handed to
> parameters.
>     Therefore @trusted is required.
>     This means that every template functions cannot take benefits from
> @safe.
>
> 7. Some mysterious compile errors
>     When @safe unittest...
>     Some functions are going to call opAssign. (eg: std.range(2670))
>     Some functions are going to call __cpctor. (eg: std.stdio(165))
>     Some functions are going to call ~this. (eg: std.stdio(872))
>     (I try compile command: "dmd -I.. -c -o- -unittest -debug stdio.d")
>
> Please do not make it an useless treasure.
> I really wait for the day when this is used effectively.
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
>
> 
May 23, 2010
3. Bugzilla 4220 - I cannot apply @safe to intrinsic operation
     http://d.puremagic.com/issues/show_bug.cgi?id=4220
4. Bugzilla 4221 - dmd should not allow overload between @safe/@trusted
and @system
     http://d.puremagic.com/issues/show_bug.cgi?id=4221

5. Bugzilla 4222 - druntime should apply @safe/@system/@trusted
     http://d.puremagic.com/issues/show_bug.cgi?id=4222

But, 6th and 7th are not reported. Because there is still room for argument in the 6th, and I didn't understand causes about the 7th problem well.

Walter Bright ????????:
> These are great comments, please add each to their own bugzilla entry if they aren't already.
> 

May 22, 2010

SHOO wrote:
>
> 6. You must make the template function @trusted by all means
>     When you use template, type that is maked @system may be handed to
> parameters.
>     Therefore @trusted is required.
>     This means that every template functions cannot take benefits from
> @safe.
> 

One possibility is to have the template function 'inherit' its default safety attribute from its arguments.

> 7. Some mysterious compile errors
>     When @safe unittest...
>     Some functions are going to call opAssign. (eg: std.range(2670))
>     Some functions are going to call __cpctor. (eg: std.stdio(165))
>     Some functions are going to call ~this. (eg: std.stdio(872))
>     (I try compile command: "dmd -I.. -c -o- -unittest -debug stdio.d")
>
> 

I don't know about this.
May 23, 2010
SHOO <zan77137 at nifty.com> wrote:
> I succeeded in applying @safe, @trusted, @system to Phobos after hardship.
> 
> I made a branch, please look: http://svn.dsource.org/projects/phobos/branches/devel/applying_safe_system_trusted
> 

Great work!

> 7. Some mysterious compile errors
>     When @safe unittest...
>     Some functions are going to call opAssign. (eg: std.range(2670))
>     Some functions are going to call __cpctor. (eg: std.stdio(165))
>     Some functions are going to call ~this. (eg: std.stdio(872))
>     (I try compile command: "dmd -I.. -c -o- -unittest -debug stdio.d")

It seems module-global @safe is not applied into struct/class scopes. I'm not sure if this is a bug though.

This example doesn't compile:
--------------------
@safe:
struct S {
    void foo() { }
    @safe unittest { foo(); }
}
--------------------
% dmd -o- -c -unittest test
test.d(4): Error: safe function '__unittest1' cannot call...
--------------------

While this one compiles:
--------------------
@safe:
struct S {
@safe: // <-- !!
    void foo() { }
    unittest { foo(); }
}
--------------------

Hope this can be helpful for you. :)

Shin
May 23, 2010
FWIW, I just discovered that header generation doesn't preserve the '@' symbol for attributes.  Or at least not the "property" attribute.
May 23, 2010
bugzilla?

Sean Kelly wrote:
> FWIW, I just discovered that header generation doesn't preserve the '@' symbol for attributes.  Or at least not the "property" attribute.
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
>
> 
May 23, 2010
Gonna. Been a busy day.

Sent from my iPhone

On May 23, 2010, at 3:58 PM, Walter Bright <walter at digitalmars.com> wrote:

> bugzilla?
>
> Sean Kelly wrote:
>> FWIW, I just discovered that header generation doesn't preserve the
>> '@' symbol for attributes.  Or at least not the "property" attribute.
>> _______________________________________________
>> phobos mailing list
>> phobos at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/phobos
>>
>>
>>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos