Prev: Question about default discriminants and mutable objects.
Next: Why is not Stream_Access defined Ada.Streams ?
From: Yannick Duchêne (Hibou57) on 7 May 2010 11:19 Le Fri, 07 May 2010 14:27:35 +0200, Robert A Duff <bobduff(a)shell01.theworld.com> a écrit: > "Randy Brukardt" <randy(a)rrsoftware.com> writes: > >> I actually don't buy the need for the Assert pragma in the first place: >> such >> checks are rarely expensive and thus should simply be part of the code >> always. > > If they're not expensive, then you're not using it enough. ;-) Hihi, nice > Also, the other advantage of pragma Assert over an Assert > procedure is that you can put the pragma in declarative parts > and package specs. That's what I like to do too : define Assert pragmas in package spec, so that it can be used to derive some property in the implementation or in some other part of the specification. This express coherence between some elements or other things (there are things which cannot be expressed with type properties), on which you can rely to say âthis and this, is valid, because of that (the Assert pragma somewhere)â. I find it useful to safely drop some runtime check whenever something must be fast or is looped thousands of times, or even simply to be sure something is OK (no need for execution speed requirements to wish that). If the assumptions are wrong and so what is derived from these too, well, the package simply raise an exception at elaboration instead of behaving oddly. -- No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just not lucky
From: Yannick Duchêne (Hibou57) on 7 May 2010 11:21 Le Fri, 07 May 2010 04:17:41 +0200, Randy Brukardt <randy(a)rrsoftware.com> a écrit: > always. (And the ones that are expensive need a lot more control than > simply > on or off: Janus/Ada uses trace switches that can be controlled on a > per-unit basis.) There was something similar with an Eiffel compiler (I don't remember if it was part of the Eiffel standard). That sounds interesting (thanks for explaining what is your compiler from times to times) -- No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just not lucky
From: Yannick Duchêne (Hibou57) on 7 May 2010 11:35 Le Fri, 07 May 2010 15:37:55 +0200, Georg Bauhaus <rm.dash-bauhaus(a)futureapps.de> a écrit: > Put (Num_Errors); > Put_Line (" errors detected."); Here is, that's also my preferred way to do to output execution logs. That's not so much annoying, while this is a written-once-used-many-times. However, I'm not so much sure the reason must be something like JavaScript's alert boxes leaking in Ada ; this may simply be a question coming from inquisitive peoples. -- No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just not lucky
From: Yannick Duchêne (Hibou57) on 7 May 2010 11:46 Le Fri, 07 May 2010 16:25:37 +0200, Robert A Duff <bobduff(a)shell01.theworld.com> a écrit: > And teaching beginners how to instantiate generics, > when there's a simple 'Image feature, is not a good idea. Mhhhh... don't agree. 'Image is a kind of hidden genericity, and students would get more benefit in learning the explicit one. Student will get more learning to instantiate generics which are used every-where, better than thinking the purpose of the language is to provide them tricky candies to quickly do this and that and that using Ada there are expected to play with or think about such tricky things. Generic instantiation (or user defined functions for user defined types) is a more proper way to reach the OP's given expectation than using an 'Image, which as Jean-Pierre said, should be reserved for quick and dirty stuff. 'Image is not a big deal of the language, that's its purpose. Forgive me for these wording I don't like : starting to have heavy requirement on the 'Image attribute would be the start of bloating and the start of Ada as a library instead of Ada as a language and as a design language.. -- No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just not lucky
From: Dmitry A. Kazakov on 7 May 2010 13:38
On Fri, 07 May 2010 17:46:09 +0200, Yannick Duch�ne (Hibou57) wrote: > Le Fri, 07 May 2010 16:25:37 +0200, Robert A Duff > <bobduff(a)shell01.theworld.com> a �crit: >> And teaching beginners how to instantiate generics, >> when there's a simple 'Image feature, is not a good idea. > Mhhhh... don't agree. 'Image is a kind of hidden genericity, Polymorphism. Genericity is a kind of polymorphism (static), but not all polymorphism is genericity. If you consider image statically polymorphic, then it is more the C++ way than the Ada's one. Compare: T'Image(X) image<T>(x) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de |