Thread overview
No runtime attribute?
Dec 10, 2014
bearophile
Dec 10, 2014
Stefan Koch
Dec 10, 2014
Mike
Dec 10, 2014
Mike
Dec 10, 2014
Daniel Murphy
Dec 10, 2014
John Colvin
Dec 10, 2014
Mike
Dec 10, 2014
ketmar
Dec 10, 2014
Mike
Dec 10, 2014
Mike
December 10, 2014
The #[no_std] attribute is used to avoid the runtime in Rust.

Do we have any use for a @noruntime attribute in D?

All @noruntime functions are also @nogc (so you don't need to put both attributes).


This could give a compilation error:

void foo(int[] a) @noruntime {
    int[5] b = a[];
}

Bye,
bearophile
December 10, 2014
On Wednesday, 10 December 2014 at 10:46:58 UTC, bearophile wrote:
> The #[no_std] attribute is used to avoid the runtime in Rust.
>
> Do we have any use for a @noruntime attribute in D?
>
> All @noruntime functions are also @nogc (so you don't need to put both attributes).
>
>
> This could give a compilation error:
>
> void foo(int[] a) @noruntime {
>     int[5] b = a[];
> }
>
> Bye,
> bearophile

In a similar vain.
It would be very nice if we could subsitute individual functions of the runtime library by  other functions or function pointers.
December 10, 2014
"bearophile"  wrote in message news:pibnlncyjzetohcnwyps@forum.dlang.org...

> The #[no_std] attribute is used to avoid the runtime in Rust.
>
> Do we have any use for a @noruntime attribute in D?
>
> All @noruntime functions are also @nogc (so you don't need to put both attributes).
>

Why would you ever be writing code at this level and yet somehow not be able to just use the linker errors? 

December 10, 2014
On Wednesday, 10 December 2014 at 11:15:44 UTC, Stefan Koch wrote:

> It would be very nice if we could subsitute individual functions of the runtime library by  other functions or function pointers.

I believe this is already possible with DMD because all druntime functions are compiled as weak symbols.  I don't believe this is the case for LDC and GDC, however.  If LDC and GDC provided something equivalent to GCC's weak attribute, and the runtime functions were decorated with it, then the same method would work for all compilers.

Mike
December 10, 2014
On Wednesday, 10 December 2014 at 12:18:47 UTC, Mike wrote:
> On Wednesday, 10 December 2014 at 11:15:44 UTC, Stefan Koch wrote:
>
>> It would be very nice if we could subsitute individual functions of the runtime library by  other functions or function pointers.
>
> I believe this is already possible with DMD because all druntime functions are compiled as weak symbols.  I don't believe this is the case for LDC and GDC, however.  If LDC and GDC provided something equivalent to GCC's weak attribute, and the runtime functions were decorated with it, then the same method would work for all compilers.


Actually, I just remembered I've done this before with GDC and LDC.  You do it with ld's -wrap switch.

Example: http://forum.dlang.org/post/gqyzyldgdqhamtouyvcl@forum.dlang.org
LD's documentation: http://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html (see the bottom of the page)

Mike
December 10, 2014
On Wednesday, 10 December 2014 at 10:46:58 UTC, bearophile wrote:
> The #[no_std] attribute is used to avoid the runtime in Rust.
>
> Do we have any use for a @noruntime attribute in D?
>
> All @noruntime functions are also @nogc (so you don't need to put both attributes).
>
>
> This could give a compilation error:
>
> void foo(int[] a) @noruntime {
>     int[5] b = a[];
> }
>

Yes, it would be nice to separate *language* from *library*, but I've proposed such ideas in the past and they've only met resistance.

Mike

December 10, 2014
On Wed, 10 Dec 2014 10:46:56 +0000
bearophile via Digitalmars-d <digitalmars-d@puremagic.com> wrote:

> The #[no_std] attribute is used to avoid the runtime in Rust.
> 
> Do we have any use for a @noruntime attribute in D?
> 
> All @noruntime functions are also @nogc (so you don't need to put both attributes).
> 
> 
> This could give a compilation error:
> 
> void foo(int[] a) @noruntime {
>      int[5] b = a[];
> }
> 
> Bye,
> bearophile
this can be useful if compiler will generate error message with exact runtime function signatures. i.e. something like:

  Error: foo() requires '_runtimeA(void*, size_t)'

or even better: add a command-line switch to generate such reports.


December 10, 2014
On Wednesday, 10 December 2014 at 12:04:13 UTC, Daniel Murphy wrote:
> "bearophile"  wrote in message news:pibnlncyjzetohcnwyps@forum.dlang.org...
>
>> The #[no_std] attribute is used to avoid the runtime in Rust.
>>
>> Do we have any use for a @noruntime attribute in D?
>>
>> All @noruntime functions are also @nogc (so you don't need to put both attributes).
>>
>
> Why would you ever be writing code at this level and yet somehow not be able to just use the linker errors?

That was my thought too. I don't see the value of having a semantic promise for this.

bearophile: can you describe a practical use-case where there is an advantage to @noruntime, other than "linker errors aren't pretty to read".
December 10, 2014
On Wednesday, 10 December 2014 at 10:46:58 UTC, bearophile wrote:
> The #[no_std] attribute is used to avoid the runtime in Rust.
>
> Do we have any use for a @noruntime attribute in D?
>
> All @noruntime functions are also @nogc (so you don't need to put both attributes).
>
>
> This could give a compilation error:
>
> void foo(int[] a) @noruntime {
>     int[5] b = a[];
> }
>

I just remembered I had an idea for this specific feature that would require no special attribute.  You simply take all the hard-coded symbols out of the compiler and put them in a .di header file.  Then you can version out, @deprectate, @disable, or not import the .di file if you don't want any or all of the runtime.

I tried to implement this in GDC, but failed.  I need to put more time into it to try and figure it out.  Theoretically, though, I think it should work.

Mike
December 10, 2014
On Wednesday, 10 December 2014 at 12:50:19 UTC, Mike wrote:

>
> I just remembered I had an idea for this specific feature that would require no special attribute.  You simply take all the hard-coded symbols out of the compiler and put them in a .di header file.  Then you can version out, @deprectate, @disable, or not import the .di file if you don't want any or all of the runtime.
>
> I tried to implement this in GDC, but failed.  I need to put more time into it to try and figure it out.  Theoretically, though, I think it should work.
>
> Mike

Here's the previous thread where I discussed this:
http://forum.dlang.org/post/psssnzurlzeqeneagora@forum.dlang.org

Mike