www.digitalmars.com         C & C++   DMDScript  

digitalmars.dip.ideas - "all functions are templates" flag

reply monkyyy <crazymonkyyy gmail.com> writes:
```d
import std;
auto foo()(){static assert(0);}
auto bar(){static assert(0);}
void main(){
     "hello world".writeln;
}
```

In the above code, foo doesnt break, bar does.

In the vain of removing the "unreachable statement" error and 
reducing phoboes interdependence( 
https://forum.dlang.org/post/xiprhwrxykatbhlhhcru forum.dlang.org), have a
debug flag that will treat bar as foo, with an empty template header. So only
used code breaks compiles.

In wasm with a broken libc, phoboes is unusable, for silly 
reasons like t_time being undefined so I cant use anything that 
imports chains to core.*, which as far as I know is all of Phobos

`-templateify`?
Jun 23
next sibling parent reply Denis Feklushkin <feklushkin.denis gmail.com> writes:
On Sunday, 23 June 2024 at 17:18:11 UTC, monkyyy wrote:

 In wasm with a broken libc, phoboes is unusable, for silly 
 reasons like t_time being undefined so I cant use anything that 
 imports chains to core.*, which as far as I know is all of 
 Phobos
All functions are templates except marked as extern or export? Because some functions can be called implictly from outside and you don’t even know about it
Jun 23
parent monkyyy <crazymonkyyy gmail.com> writes:
On Sunday, 23 June 2024 at 20:26:14 UTC, Denis Feklushkin wrote:
 On Sunday, 23 June 2024 at 17:18:11 UTC, monkyyy wrote:

 In wasm with a broken libc, phoboes is unusable, for silly 
 reasons like t_time being undefined so I cant use anything 
 that imports chains to core.*, which as far as I know is all 
 of Phobos
All functions are templates except marked as extern or export? Because some functions can be called implictly from outside and you don’t even know about it
I'm not sure I follow what situation you believe it would help? Such a flag would probably just break incremental/complex compilation.
Jun 23
prev sibling parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
On Sunday, 23 June 2024 at 17:18:11 UTC, monkyyy wrote:
 ```d
 import std;
 auto foo()(){static assert(0);}
 auto bar(){static assert(0);}
 void main(){
     "hello world".writeln;
 }
 ```

 In the above code, foo doesnt break, bar does.

 In the vain of removing the "unreachable statement" error and 
 reducing phoboes interdependence( 
 https://forum.dlang.org/post/xiprhwrxykatbhlhhcru forum.dlang.org), have a
debug flag that will treat bar as foo, with an empty template header. So only
used code breaks compiles.

 In wasm with a broken libc, phoboes is unusable, for silly 
 reasons like t_time being undefined so I cant use anything that 
 imports chains to core.*, which as far as I know is all of 
 Phobos

 `-templateify`?
the function is never called, it should never assert imo, why even compile unused functions?, sounds like the compiler is wasting time, but i am not a compiler dev so i am clueless here, just wanted to point that out, hopefully someone could enlighten us
Jun 24
parent monkyyy <crazymonkyyy gmail.com> writes:
On Monday, 24 June 2024 at 13:38:31 UTC, ryuukk_ wrote:
 On Sunday, 23 June 2024 at 17:18:11 UTC, monkyyy wrote:
 ```d
 import std;
 auto foo()(){static assert(0);}
 auto bar(){static assert(0);}
 void main(){
     "hello world".writeln;
 }
 ```

 In the above code, foo doesnt break, bar does.

 In the vain of removing the "unreachable statement" error and 
 reducing phoboes interdependence( 
 https://forum.dlang.org/post/xiprhwrxykatbhlhhcru forum.dlang.org), have a
debug flag that will treat bar as foo, with an empty template header. So only
used code breaks compiles.

 In wasm with a broken libc, phoboes is unusable, for silly 
 reasons like t_time being undefined so I cant use anything 
 that imports chains to core.*, which as far as I know is all 
 of Phobos

 `-templateify`?
the function is never called, it should never assert imo, why even compile unused functions?, sounds like the compiler is wasting time, but i am not a compiler dev so i am clueless here, just wanted to point that out, hopefully someone could enlighten us
"the c stack" was made in the 1970's or whatever for very different machines, headers were a helpful pre-pass for memory reasons, shared libs or incremental compilation; not only is d a little to close to c to change that default behavior but changing that to be bottom up would probably be more controversial then a gc for the "systems programming" crowd as youd need a workaround to even use c libs and current os's Eventually there are solutions to swap from a bottom up rather then a top down method, template languages must have them to work, but they came after the foundation we sit on.
Jun 24