"all functions are templates" flag
monkyyy
crazymonkyyy at gmail.com
Mon Jun 24 14:02:33 UTC 2024
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.
More information about the dip.ideas
mailing list