Jump to page: 1 2
Thread overview
[Issue 15437] documentation for typeof(someTemplate) == void
Dec 14, 2015
Sobirari Muhomori
Dec 14, 2015
Luís Marques
Dec 14, 2015
Sobirari Muhomori
Dec 14, 2015
ZombineDev
Dec 14, 2015
ZombineDev
May 05, 2018
Johannes Loher
May 05, 2018
Johannes Loher
Jan 03, 2020
berni44
Feb 14, 2022
Dlang Bot
Feb 15, 2022
Dlang Bot
December 14, 2015
https://issues.dlang.org/show_bug.cgi?id=15437

--- Comment #1 from Sobirari Muhomori <dfj1esp02@sneakemail.com> ---
IIRC, typeof(fun) gives the function's return type.

--
December 14, 2015
https://issues.dlang.org/show_bug.cgi?id=15437

--- Comment #2 from Luís Marques <luis@luismarques.eu> ---
But if it is a function *template* then the type will be void. That's what could be better documented, IMHO.

--
December 14, 2015
https://issues.dlang.org/show_bug.cgi?id=15437

--- Comment #3 from Sobirari Muhomori <dfj1esp02@sneakemail.com> ---
Maybe it's not an intended behavior and type of template should be `template`?

--
December 14, 2015
https://issues.dlang.org/show_bug.cgi?id=15437

ZombineDev <petar.p.kirov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |petar.p.kirov@gmail.com

--- Comment #4 from ZombineDev <petar.p.kirov@gmail.com> ---
Maybe something like this:

T add(T)(T a, T b) { return a + b; }

static assert (is(typeof(add) == template));

alias add2 = (a,b) => a + b;

static assert (is(typeof(add2) == template));

?

--
December 14, 2015
https://issues.dlang.org/show_bug.cgi?id=15437

--- Comment #5 from ZombineDev <petar.p.kirov@gmail.com> ---
Though this would add overlap to the functionality already provided by http://dlang.org/spec/traits.html#isTemplate.

Also related: https://github.com/D-Programming-Language/dmd/pull/5201

--
December 24, 2016
https://issues.dlang.org/show_bug.cgi?id=15437

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |trivial
                 CC|                            |andrei@erdani.com

--
May 05, 2018
https://issues.dlang.org/show_bug.cgi?id=15437

Johannes Loher <johannes.loher@fg4f.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johannes.loher@fg4f.de

--- Comment #6 from Johannes Loher <johannes.loher@fg4f.de> ---
Related: https://issues.dlang.org/show_bug.cgi?id=7947

I briefly talked to both Andrei and Walter today at dconf about this. They both agreed, that calling typeof on a template should be an error (similiar to how calling typeof on a type is an error).

Any thoughts on that?

--
May 05, 2018
https://issues.dlang.org/show_bug.cgi?id=15437

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |preapproved

--- Comment #7 from Andrei Alexandrescu <andrei@erdani.com> ---
preapproved

--
May 05, 2018
https://issues.dlang.org/show_bug.cgi?id=15437

--- Comment #8 from Johannes Loher <johannes.loher@fg4f.de> ---
Realated comment in the corresponding section in dmd:

/* Today, 'typeof(func)' returns void if func is a
 * function template (TemplateExp), or
 * template lambda (FuncExp).
 * It's actually used in Phobos as an idiom, to branch code for
 * template functions.
 */

Does anybody know where this is actually used in phobos? Wouldn't it be better to use isTemplate in this case?

--
January 03, 2020
https://issues.dlang.org/show_bug.cgi?id=15437

berni44 <bugzilla@d-ecke.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@d-ecke.de
           Severity|enhancement                 |normal

--
« First   ‹ Prev
1 2