comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: My first compiler bug: work around or redesign?
Date: Mon, 26 Mar 2012 23:47:17 +0200
Date: 2012-03-26T23:47:17+02:00	[thread overview]
Message-ID: <4f70e3e5$0$6566$9b4e6d93@newsspool4.arcor-online.net> (raw)
In-Reply-To: <slrnjn1ch7.1lme.lithiumcat@sigil.instinctive.eu>

On 26.03.12 20:15, Natasha Kerensikova wrote:

> Somewhere in parser internals I use another kind of callbacks, that I
> call lexers (but I'm not completely sure I use the word with its correct
> meaning, though it does refer to code that find token start and end in a
> given String). These callbacks match the following type:
>
>     type Element_Lexer is
>        access procedure
>          (State : in out Lexer_State_Type;
>           Source : String;
>           Position : in out Positive;
>           Renderer : in not null Element_Renderer;
>           Renderer_State : in out Renderer_State_Type;
>           Render_Param : in out Parameter_Map);
>
> At this point, it does not make sense for Renderer to be null, because
> as explained above, a null value would have disabled the element and the
> Element_Lexer would never be called. So I added the "not null"
> constrained.

Looks quite right to me to say "not null" when a parameter shouldn't
be null.  If this condition is checked at compile time, it avoids
the embarrassment that potential null pointers can cause :-) For ease
of software maintenance (in the presence of bugs in the compiler), one
might also define a null excluding subtype.  The workaround is
then easily turned on and off in the single declaration in case there
are more occurrences of "not null Element_Renderer".  Don't know if the
immediate presence of "not null" would be stylistically preferable,
on the other hand.

    subtype Valid_Element_Renderer is not null Element_Renderer;

(I have chosen Valid_ just to have a name for the subtype, with no
aspiration to quality of naming.)


> Is it really worth reporting?

Yes. An observable bug is a bug, whatever the laws are.




  parent reply	other threads:[~2012-03-26 21:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-23 16:29 My first compiler bug: work around or redesign? Natasha Kerensikova
2012-03-23 17:51 ` Ludovic Brenta
2012-03-23 21:20   ` Natasha Kerensikova
2012-03-23 17:56 ` Jeffrey Carter
2012-03-23 18:22 ` Jeffrey Carter
2012-03-23 21:23   ` Natasha Kerensikova
2012-03-23 22:54     ` Jeffrey Carter
2012-03-23 18:29 ` Simon Wright
2012-03-23 18:37 ` Dmitry A. Kazakov
2012-03-23 18:48   ` Robert A Duff
2012-03-23 21:40     ` Natasha Kerensikova
2012-03-24  0:04       ` Georg Bauhaus
2012-03-24  9:50         ` Natasha Kerensikova
2012-03-23 21:34   ` Natasha Kerensikova
2012-03-23 19:04 ` Jeffrey Carter
2012-03-26 18:15 ` Natasha Kerensikova
2012-03-26 18:43   ` Simon Wright
2012-03-26 18:55   ` Ludovic Brenta
2012-03-28 15:30     ` Natasha Kerensikova
2012-03-29  8:25       ` Ludovic Brenta
2012-03-30 23:42         ` onox
2012-04-02 20:51           ` Ludovic Brenta
2012-04-03  2:50             ` onox
2012-03-26 21:47   ` Georg Bauhaus [this message]
2012-03-27  5:34     ` Per Sandberg
2012-03-27  7:30     ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox