6 days ago
On Thursday, 19 November 2020 at 00:07:12 UTC, Dibyendu Majumdar wrote:
> I have simple test program:
>
> import core.stdc.stdio : printf;
>
> void test() {
>     int* a;
>     printf("a == null %d\n", a == null);
> }
>
> int function() fp = test;
>
> extern (C) void main() {
>     fp();
> }
>
> Why do I get:
>
> \d\dmd-2.092.1\windows\bin64\dmd.exe -betterC tests.d
> tests.d(5): Error: printf cannot be interpreted at compile time, because it has no available source code
>
> This is on Windows

IMO another problem here is that `function` and `delegate` are special cases of the `*` postfix. With a syntax like

    int()* fp = test

it would be more obvious to new comers that `&` is missing.
This is a syntax I experiment in STYX for example [1].


Note that then there's also the problem with functions pointers requiring a context. This context is not necessarily a `this` (for closures it's a frame obviously).

[1] https://gitlab.com/basile.b/styx/-/blob/master/tests/backend/function_pointers.sx#L10
6 days ago
On Thursday, 19 November 2020 at 00:20:50 UTC, Dibyendu Majumdar wrote:
> Okay thanks. Bad idea IMO.

That's kinda how I see C taking the address of various things implicitly.
6 days ago
On Thursday, 19 November 2020 at 14:34:38 UTC, Adam D. Ruppe wrote:
> On Thursday, 19 November 2020 at 00:20:50 UTC, Dibyendu Majumdar wrote:
>> Okay thanks. Bad idea IMO.
>
> That's kinda how I see C taking the address of various things implicitly.

good example
6 days ago
On Thursday, 19 November 2020 at 14:34:38 UTC, Adam D. Ruppe wrote:
> On Thursday, 19 November 2020 at 00:20:50 UTC, Dibyendu Majumdar wrote:
>> Okay thanks. Bad idea IMO.
>
> That's kinda how I see C taking the address of various things implicitly.

To be honest it seems irrelevant what C does.
Next ›   Last »
1 2