public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/46115] New: Feature request: anonymous functions (complementing anon aggregates)
@ 2010-10-21 12:40 robert.staudinger at gmail dot com
  2010-10-21 18:38 ` [Bug c/46115] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: robert.staudinger at gmail dot com @ 2010-10-21 12:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46115

           Summary: Feature request: anonymous functions (complementing
                    anon aggregates)
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: robert.staudinger@gmail.com


It would be great if GCC would consider addition of anonymous functions along
the lines of anonymous aggreates, i.e. deferring the formal parameters from the
preceding cast expression.

Example:

void (*func_ptr)(int) = (void (*)(int i)) { printf ("%i", i); };


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/46115] Feature request: anonymous functions (complementing anon aggregates)
  2010-10-21 12:40 [Bug c/46115] New: Feature request: anonymous functions (complementing anon aggregates) robert.staudinger at gmail dot com
@ 2010-10-21 18:38 ` pinskia at gcc dot gnu.org
  2010-10-22  8:33 ` robert.staudinger at gmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-10-21 18:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46115

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-10-21 18:38:31 UTC ---
This sounds like C++ lambda functions.

Second,  I think this is a bad idea for C.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/46115] Feature request: anonymous functions (complementing anon aggregates)
  2010-10-21 12:40 [Bug c/46115] New: Feature request: anonymous functions (complementing anon aggregates) robert.staudinger at gmail dot com
  2010-10-21 18:38 ` [Bug c/46115] " pinskia at gcc dot gnu.org
@ 2010-10-22  8:33 ` robert.staudinger at gmail dot com
  2010-10-25  7:32 ` robert.staudinger at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: robert.staudinger at gmail dot com @ 2010-10-22  8:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46115

--- Comment #2 from Rob Staudinger <robert.staudinger at gmail dot com> 2010-10-22 08:33:46 UTC ---
There obviously is some relation, but this proposal evades syntactical
overloading of operators, unlike C++ lambda functions or LLVM blocks.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/46115] Feature request: anonymous functions (complementing anon aggregates)
  2010-10-21 12:40 [Bug c/46115] New: Feature request: anonymous functions (complementing anon aggregates) robert.staudinger at gmail dot com
  2010-10-21 18:38 ` [Bug c/46115] " pinskia at gcc dot gnu.org
  2010-10-22  8:33 ` robert.staudinger at gmail dot com
@ 2010-10-25  7:32 ` robert.staudinger at gmail dot com
  2015-03-15 23:10 ` shawn at churchofgit dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: robert.staudinger at gmail dot com @ 2010-10-25  7:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46115

--- Comment #3 from Rob Staudinger <robert.staudinger at gmail dot com> 2010-10-25 07:31:59 UTC ---
For the record, this is already possible using bracketed expressions, but the
syntactical sugar of not having to pick a function name would be great.

#include <stdio.h>
#include <stdlib.h>

int
main (int argc, char **argv)
{
  void (*func_ptr)(int) = ({ void func(int i) { printf ("%i\n", i); };
                             func;
                           });

  func_ptr (3);

  return EXIT_SUCCESS;
}


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/46115] Feature request: anonymous functions (complementing anon aggregates)
  2010-10-21 12:40 [Bug c/46115] New: Feature request: anonymous functions (complementing anon aggregates) robert.staudinger at gmail dot com
                   ` (2 preceding siblings ...)
  2010-10-25  7:32 ` robert.staudinger at gmail dot com
@ 2015-03-15 23:10 ` shawn at churchofgit dot com
  2015-03-15 23:11 ` shawn at churchofgit dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: shawn at churchofgit dot com @ 2015-03-15 23:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46115

Shawn Landden <shawn at churchofgit dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |shawn at churchofgit dot com

--- Comment #4 from Shawn Landden <shawn at churchofgit dot com> ---
There is also the Apple blocks extension to C.
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1370.pdf
http://clang.llvm.org/docs/Block-ABI-Apple.html#history


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/46115] Feature request: anonymous functions (complementing anon aggregates)
  2010-10-21 12:40 [Bug c/46115] New: Feature request: anonymous functions (complementing anon aggregates) robert.staudinger at gmail dot com
                   ` (3 preceding siblings ...)
  2015-03-15 23:10 ` shawn at churchofgit dot com
@ 2015-03-15 23:11 ` shawn at churchofgit dot com
  2015-03-15 23:15 ` pinskia at gcc dot gnu.org
  2021-01-16 12:58 ` muecker at gwdg dot de
  6 siblings, 0 replies; 8+ messages in thread
From: shawn at churchofgit dot com @ 2015-03-15 23:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46115

--- Comment #5 from Shawn Landden <shawn at churchofgit dot com> ---
http://mackyle.github.io/blocksruntime/#download


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/46115] Feature request: anonymous functions (complementing anon aggregates)
  2010-10-21 12:40 [Bug c/46115] New: Feature request: anonymous functions (complementing anon aggregates) robert.staudinger at gmail dot com
                   ` (4 preceding siblings ...)
  2015-03-15 23:11 ` shawn at churchofgit dot com
@ 2015-03-15 23:15 ` pinskia at gcc dot gnu.org
  2021-01-16 12:58 ` muecker at gwdg dot de
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-03-15 23:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46115

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Rob Staudinger from comment #3)
> For the record, this is already possible using bracketed expressions, but
> the syntactical sugar of not having to pick a function name would be great.

Actually that is not valid as func is local to that scope and now it escapes.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/46115] Feature request: anonymous functions (complementing anon aggregates)
  2010-10-21 12:40 [Bug c/46115] New: Feature request: anonymous functions (complementing anon aggregates) robert.staudinger at gmail dot com
                   ` (5 preceding siblings ...)
  2015-03-15 23:15 ` pinskia at gcc dot gnu.org
@ 2021-01-16 12:58 ` muecker at gwdg dot de
  6 siblings, 0 replies; 8+ messages in thread
From: muecker at gwdg dot de @ 2021-01-16 12:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46115

Martin Uecker <muecker at gwdg dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |muecker at gwdg dot de

--- Comment #7 from Martin Uecker <muecker at gwdg dot de> ---
The documentation implies that the pointer escaping the scope and calling the
function is safe as long as it does not access a variable of the enclosing
function that went out of scope.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-01-16 12:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-21 12:40 [Bug c/46115] New: Feature request: anonymous functions (complementing anon aggregates) robert.staudinger at gmail dot com
2010-10-21 18:38 ` [Bug c/46115] " pinskia at gcc dot gnu.org
2010-10-22  8:33 ` robert.staudinger at gmail dot com
2010-10-25  7:32 ` robert.staudinger at gmail dot com
2015-03-15 23:10 ` shawn at churchofgit dot com
2015-03-15 23:11 ` shawn at churchofgit dot com
2015-03-15 23:15 ` pinskia at gcc dot gnu.org
2021-01-16 12:58 ` muecker at gwdg dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).