www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - No runtime attribute?

reply "bearophile" <bearophileHUGS lycos.com> writes:
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
Dec 10 2014
next sibling parent reply "Stefan Koch" <uplink.coder googlemail.com> writes:
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.
Dec 10 2014
parent reply "Mike" <none none.com> writes:
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
Dec 10 2014
parent "Mike" <none none.com> writes:
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
Dec 10 2014
prev sibling next sibling parent reply "Daniel Murphy" <yebbliesnospam gmail.com> writes:
"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?
Dec 10 2014
parent "John Colvin" <john.loughran.colvin gmail.com> writes:
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".
Dec 10 2014
prev sibling next sibling parent "Mike" <none none.com> writes:
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
Dec 10 2014
prev sibling next sibling parent ketmar via Digitalmars-d <digitalmars-d puremagic.com> writes:
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.
=20
 Do we have any use for a  noruntime attribute in D?
=20
 All  noruntime functions are also  nogc (so you don't need to put=20
 both attributes).
=20
=20
 This could give a compilation error:
=20
 void foo(int[] a)  noruntime {
      int[5] b =3D a[];
 }
=20
 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.
Dec 10 2014
prev sibling parent reply "Mike" <none none.com> writes:
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
Dec 10 2014
parent "Mike" <none none.com> writes:
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
Dec 10 2014