From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,HEADER_SPAM autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1032a1,4f5d9fdcc65429b5 X-Google-Attributes: gid1032a1,public X-Google-Thread: 103376,4f5d9fdcc65429b5 X-Google-Attributes: gid103376,public From: sb463ba@unidui.uni-duisburg.de (Georg Bauhaus) Subject: Re: Ada and Literate Programming Date: 2000/05/10 Message-ID: X-Deja-AN: 621428155 References: <8f6iue$pu5$1@news.fas.harvard.edu> <391728d1@pfaff.ethz.ch> Followup-To: comp.lang.ada,comp.programming.literate X-Trace: cac1.rdr.news.psi.ca 957934424 154.5.86.206 (Wed, 10 May 2000 00:53:44 EDT) Organization: Gerhard-Mercator-Universitaet - Gesamthochschule Duisburg NNTP-Posting-Date: Wed, 10 May 2000 00:53:44 EDT Newsgroups: comp.lang.ada,comp.programming.literate Date: 2000-05-10T00:00:00+00:00 List-Id: Robert Dewar (robert_dewar@my-deja.com) wrote: : Seeing as the substance of literate programming is very little : more than writing code that is properly documented, Well some people in c.l.literate would strongly object. Noweb, by default, produces no pretty printing of source lines, though you can plug in a filter. But the main points of LP have often been said to be these: - a way of reordering pieces of code according to the way you prefer thinking about them, not in the sequence the computer needs its sources, without using subprograms. (much of this can be done using declare and pragma Inline in Ada, I suppose) - automatic and semiautomatic indexing of identifiers or anything you wish. If the compiler supports repeated [[#line]] directives, in the Ada case repeated occurences of [[pragma Source_Reference]] in one source file, working with WEBs can be fun :) @ An ad hoc scrambled eggs non-exciting example of noweb code, hardly working at best, just to give an impression. Here is the main routine, having some vague similarities with a FSM, hobbyist's work, mind you. (If you are reading the WEB sources: Note that [[<<]] does not introduce Ada labels.) <>= <> procedure Test is Symbol: Character; -- one symbol from input begin loop <> end loop; end Test; @ Now read [[input symbols]], one by one, and according to whether a symbol is a digit, a letter, or something else, go on and further distinguish what needs to be done for each character in its category. <>= Text_IO.Get(Symbol); if Is_Digit(Symbol) then <> elsif Is_Letter(Symbol) then <> else <> end if; @ You are maybe thinking about digits already (because they appear first in the above conditional), but first, I have to tell you about letters, because then some things about digits will become clear more easily. Characters are categorized to be vowels, consonants, punctuation, candidates for the start of a sentecnce, ... <>= case Symbol is when 'a' .. 'z' => -- ... null; when 'A'|'E'|'I'|'O'|'U' => -- ... null; when '.'|',' => -- ... null; when others => -- ... raise Programmer_s_Error; end case; @ So, here is the promised section about digits. Digits can either be [[< 5]] or otherwise [[< 9]] ... In that case ... <>= case Symbol is when '0'|'1'|'2'|'3'|'4' => -- ... null; when '5'|'6'|'7'|'8'|'9' => -- ... null; when others => -- ... raise Programmer_s_Error; end case; @ Some symbols remain. Each of these has a special meaning. For example, [['*']] introduces a comment iff it is the first character on a line,... <>= -- ... null; @ Maybe unexpectedly, the list of units this program needs, appears in The End. :) <>= with Ada.Characters.Handling, Ada.Text_IO; use Ada.Characters.Handling, Ada; >< Now here is the same untangled, i.e. with original comments included. Note that this is not what you would work with. -- An ad hoc scrambled eggs non-exciting example of noweb code, hardly working -- at best, just to give an impression. Here is the main routine, having some -- vague similarities with a FSM, hobbyist's work, mind you. -- (If you are reading the WEB sources: Note that [[<<]] does not introduce -- Ada labels.) -- -- = -- Maybe unexpectedly, the list of units this program needs, appears in -- The End. :) -- -- = with Ada.Characters.Handling, Ada.Text_IO; use Ada.Characters.Handling, Ada; procedure Test is Symbol: Character; -- one symbol from input begin loop -- Now read [[input symbols]], one by one, and according to whether a -- symbol is a digit, a letter, or something else, go on and further -- distinguish what needs to be done for each character in its category. -- -- = Text_IO.Get(Symbol); if Is_Digit(Symbol) then -- So, here is the promised section about digits. -- Digits can either be [[< 5]] or otherwise [[< 9]] ... -- In that case ... -- -- = case Symbol is when '0'|'1'|'2'|'3'|'4' => -- ... null; when '5'|'6'|'7'|'8'|'9' => -- ... null; when others => -- ... raise Programmer_s_Error; end case; elsif Is_Letter(Symbol) then -- You are maybe thinking about digits already (because they appear -- first in the above conditional), but first, I have to tell you -- about letters, because then some things about digits will become -- clear more easily. -- -- Characters are categorized to be vowels, consonants, punctuation, -- candidates for the start of a sentecnce, ... -- -- = case Symbol is when 'a' .. 'z' => -- ... null; when 'A'|'E'|'I'|'O'|'U' => -- ... null; when '.'|',' => -- ... null; when others => -- ... raise Programmer_s_Error; end case; else -- Some symbols remain. Each of these has a special meaning. -- For example, [['*']] introduces a comment iff it is the -- first character on a line,... -- -- = -- ... null; end if; end loop; end Test; Hope this wasn't too long (though so much is missing ...;-). -# Georg Bauhaus