This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GNU C extension: Function Error vs. Success
- From: Shahbaz Youssefi <shabbyx at gmail dot com>
- To: Basile Starynkevitch <basile at starynkevitch dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 10 Mar 2014 17:30:26 +0100
- Subject: Re: GNU C extension: Function Error vs. Success
- Authentication-results: sourceware.org; auth=none
- References: <CALeOzZ8kAOepbUsqRNWnGvHc=vAGC2M_NkHZ6+VZz3ybfs59HA at mail dot gmail dot com> <20140310152623 dot GA32185 at ours dot starynkevitch dot net>
Thanks for the hint. I would try to learn how to do that and
experiment on the idea if/when I get the time. I could imagine why the
community isn't interested in new syntax in general. Still, you may
never know if an idea would be attractive enough to generate some
attention! :)
On Mon, Mar 10, 2014 at 4:26 PM, Basile Starynkevitch
<basile@starynkevitch.net> wrote:
> On Mon, Mar 10, 2014 at 03:27:06PM +0100, Shahbaz Youssefi wrote:
>> Hi,
>>
>> First, let me say that I'm not subscribed to the mailing list, so
>> please CC myself when responding.
>>
>> This post is to discuss a possible extension to the GNU C language.
>> Note that this is still an idea and not refined.
> [....]
>>
>> The Extension (Basic)
>> =====================
>>
>> First, let's introduce a new syntax (note again, this is just an
>> example. I don't suggest these particular symbols):
>>
>> float inverse(int x)
>> {
>> if (x == 0)
>> fail;
>> return 1.0f / x;
>> }
>>
>> ...
>> y = inverse(x) !! goto exit_inverse_failed;
>>
>
>
> Syntax is not that important. To experiment your idea,
> I would suggest using a mixture of pragmas and builtins;
> you could perhaps have a new builtin_shahbaz_fail() and a pragma
> #pragma SHAHBAZ and then your temporary syntax would be
>
> float inverse(int x)
> {
> if (x == 0) builtin_shahbaz_fail();
> return 1.0f / x;
> }
>
> #pragma SHAHBAZ on_error_goto(exit_inverse_failed)
> { y = inverse(x); }
>
>
> Then, you don't need to dig into GCC parser to add these builtin and pragma.
> You could add them with a GCC plugin (in C++) or using MELT http://gcc-melt.org/
>
> Once you added a GCC pass to support your builtin and pragma
> (which is difficult, and means understanding the details of internals of GCC)
> you could convince other people.
>
> Notice that the GCC community is not friendly these days to new syntactic constructs.
>
> BTW, once you have implemented a builtin and a pragma you could use preprocessor macros
> to make these look more like your syntax.
>
>
> I would believe that MELT is very well suited for such experiments.
>
> Regards.
>
> PS. Plugins cannot extend the C syntax (except thru attributes, builtins, pragmas).
>
> --
> Basile STARYNKEVITCH http://starynkevitch.net/Basile/
> email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
> 8, rue de la Faiencerie, 92340 Bourg La Reine, France
> *** opinions {are only mines, sont seulement les miennes} ***