Prev: TXL Grammar for Ada 2005
Next: Building an Embedded Device/System? Tell VDC about your experiences for a chance to WIN!
From: Cyrille on 18 May 2010 05:45 On May 18, 10:15 am, "Dmitry A. Kazakov" <mail...(a)dmitry-kazakov.de> wrote: > But if I were to make a proposal, then I would do the useless pargma Assert > useful. E.g. > > pragma Assert (Condition, Message); > > [Change] > Dynamic semantics: Message is evaluated only if Condition is evaluated to > true. Then a user-defined assertion handler is called, if any (to be set by > Assertion_Policy). Otherwise Assertion_Error is propagated. something like pragma Check & Check_Policy in GNAT, right? see http://www.adacore.com/wp-content/files/auto_update/gnat-unw-docs/html/gnat_rm_2.html#SEC18 btw, concerning logging facilities, there is a relatively complete one provided as part of GNATColl. See http://www.adacore.com/wp-content/files/auto_update/gnatcoll-docs/gnatcoll.html#Logging-information
From: Dmitry A. Kazakov on 18 May 2010 06:26 On Tue, 18 May 2010 02:45:35 -0700 (PDT), Cyrille wrote: > On May 18, 10:15�am, "Dmitry A. Kazakov" <mail...(a)dmitry-kazakov.de> > wrote: > >> But if I were to make a proposal, then I would do the useless pargma Assert >> useful. E.g. >> >> � �pragma Assert (Condition, Message); >> >> [Change] >> Dynamic semantics: Message is evaluated only if Condition is evaluated to >> true. Then a user-defined assertion handler is called, if any (to be set by >> Assertion_Policy). Otherwise Assertion_Error is propagated. > > something like pragma Check & Check_Policy in GNAT, right? Important is laziness in the evaluation of the message expression. Switching off by compiler is rather a disadvantage, because logging is to be configured dynamically. BTW, it could be a statement, e.g. conditional call: <procedure/entry-call> when <condition>; A similar thing is badly needed for declarations as well, e.g. awful: if Object in T'Class then declare T_Object : T'Class renames T'Class (Object); begin ... end; end if; (cannot invent any good syntax for that) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de
From: Gautier write-only on 18 May 2010 07:27 OK, I missed the point about "&", To_String etc., as the example below shows. If you combine Stefan's solution and the Inline pragma, it should be fine... Gautier _____________ with Log; -- Try preventing compiler from optimizing parameters out... -- -> Dynamic data. with Ada.Command_Line, Ada.Strings.Unbounded; -- procedure Test_Opti_inline is use Ada.Strings.Unbounded; -- procedure Tricky(Param_Name: Unbounded_String; X: Integer) is pragma Inline(Tricky); begin Log.Write (Text => "Parameter " & To_String (Param_Name) & " Value = " & Integer'Image (X), Level => 0); end Tricky; -- Param_Name: Unbounded_String:= To_Unbounded_String(Ada.Command_Line.Command_Name); X: Integer:= Ada.Command_Line.Argument_Count; begin Log.Write (Text => "Blabla...", Level => 5); Log.Write (Text => "No no no!", Level => 0); Tricky (Param_Name => Param_Name, X => X); -- Hope: this is optimized out. end;
From: Georg Bauhaus on 18 May 2010 08:10 On 18.05.10 12:26, Dmitry A. Kazakov wrote: > BTW, it could be a statement, e.g. conditional call: > > <procedure/entry-call> when <condition>; Wouldn't conditional expression work this way? Proc ((if Condition then This else That));
From: Georg Bauhaus on 18 May 2010 08:15 On 18.05.10 14:10, Georg Bauhaus wrote: > On 18.05.10 12:26, Dmitry A. Kazakov wrote: > >> BTW, it could be a statement, e.g. conditional call: >> >> <procedure/entry-call> when <condition>; > > Wouldn't conditional expression work this way? > > Proc ((if Condition then This else That)); (except they don't make the call conditional, yes.)
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: TXL Grammar for Ada 2005 Next: Building an Embedded Device/System? Tell VDC about your experiences for a chance to WIN! |