Prev: Question about default discriminants and mutable objects.
Next: Why is not Stream_Access defined Ada.Streams ?
From: Robert A Duff on 7 May 2010 17:36 "Randy Brukardt" <randy(a)rrsoftware.com> writes: > It doesn't work very well, either, if you are outputting to a message box or > to a log manager: in both cases the entire message string has to be passed > at once. (That's the case in virtually all of my newer programs.) Not many > real programs do much output to Standard Output. Right, that's exactly what I meant when I said elsewhere in this thread that it's a good idea to separate formatting from output. Sometimes you want "format some stuff and dump it immediately to a file". Other times you want "format some stuff" (and then sort the messages and grind upon them etc.) and then much later "send to log manager" or whatever. - Bob
From: Simon Wright on 7 May 2010 17:59 Robert A Duff <bobduff(a)shell01.TheWorld.com> writes: > Now why isn't this: > > Put_Line ((Finish_Time - Start_Time)'Img); > > legal? Can the compiler be expected to work out what that function "-" is?
From: Yannick Duchêne (Hibou57) on 7 May 2010 18:09 Le Fri, 07 May 2010 23:27:55 +0200, Randy Brukardt <randy(a)rrsoftware.com> a écrit: >> Well, that "Put (Num_Errors);" is hiding something. You have to >> instantiate Text_IO.Integer_IO for all the integer types you >> need to output. That's annoying. > > It doesn't work very well, either, if you are outputting to a message > box or > to a log manager: in both cases the entire message string has to be > passed > at once. (That's the case in virtually all of my newer programs.) Not > many > real programs do much output to Standard Output. > > Randy. Le Fri, 07 May 2010 23:36:04 +0200, Robert A Duff <bobduff(a)shell01.theworld.com> a écrit: > "Randy Brukardt" <randy(a)rrsoftware.com> writes: > Right, that's exactly what I meant when I said elsewhere in this > thread that it's a good idea to separate formatting from output. > Sometimes you want "format some stuff and dump it immediately > to a file". Other times you want "format some stuff" (and then > sort the messages and grind upon them etc.) and then much later > "send to log manager" or whatever. > > - Bob There are alternatives, and here are two. The first one : the log manager could have an open/close logic to output a log line. Open Write chunk Write next chunk ... Close Another alternative I have used some months ago, was to use an abstraction of what a text is : I was passing procedure writing text instead of strings (to be exact, this was not access to procedures, this was tagged types with a single method). I though about it when I faced a brick-wall where I could not figure what could be the good minimum and maximum length for a particular string index type range. Then I though what was relevant, was not so much the strings, instead, this was what was written (that's not the same). So I decided to pass procedure writing strings instead of strings, so I could drop the trouble with strings allocation I was needed for formating purpose. There was no more strings, just writing of chunks of text each one after the other in turn. I'm not to say this is an easy suitable for beginners (as we were also talking about ease of access for beginners), I'm just exposing this as example alternatives to the one-string-bulk way. -- No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just not lucky
From: Jeffrey R. Carter on 7 May 2010 18:16 Robert A Duff wrote: > > A beginner needs to learn how to write a "Hello, world" program > first, and soon thereafter, some simple thing that involves > printing out integer values. I think one of my first assignments > way back when was to write a program to add up two numbers > and print out the answer. If that's hard, it gives a bad > first impression. (In fact, it WAS hard -- it involved > horsing around with Fortran FORMAT statements and Hollerith codes, > which is worse than horsing around with Ada generics.) Ah, the Good Old Days. FORTRAN 66, punched cards, FORMAT statements, 5HHELLO, and the like. Am I glad that's changed. > I disagree. Certainly removing the extra blank would not introduce > bloat. And in fact, giving 'Image the exact same functionality > as Integer_Text_IO would _simplify_ the language, by making > it more uniform. Yes, I was thinking along similar lines: a language with a decent 'Image would not need the I/O generics, just 'Image and text I/O. -- Jeff Carter "Oh Lord, bless this thy hand grenade, that with it thou mayst blow thine enemies to tiny bits, in thy mercy." Monty Python and the Holy Grail 24
From: Jeffrey R. Carter on 7 May 2010 18:18
Randy Brukardt wrote: > > If I actually used a signature line, I think I'd be using that one!! > > Randy. > > You can never forget too much about C++. - Jeffrey Carter Thanks. Why not use a signature line? -- Jeff Carter "Oh Lord, bless this thy hand grenade, that with it thou mayst blow thine enemies to tiny bits, in thy mercy." Monty Python and the Holy Grail 24 |