🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #4661

Programmable pretty-printers?

#4661
From: sommar
Date: Sun, 15 Feb 1987 19:04
97 lines
5384 bytes
A programmable pretty-printer (PPP) is an idea that's been in my head for a 
while and I have been thinking that I should write one if I ever get the
time. Unfortunately I have to spend my daytime writing the software the
customer pays my company for. Anyway, I thought it could be a good idea
to make survey on the net to get a glimpse of what is available today.
Perhaps I don't have to write anything at all.
  Before you post your reply, let me explain my notion of a PPP. Why I want
it and what I want it to do. 

As you may know there exists about as many formatting styles of programmes
as there are programmers. As you also may have discovered, every one else
writes code that is totally unreadable, while yourself you write the most
beautiful code. Another important fact is that in a programming project, you
want the same formatting style being used throughout all modules. Often
you even want a company standard. You can bet that the chances are small
that the standard conforms with your formatting style. 
  Although I think that every one recognizes these problems I'd like to 
give some examples of different way to write the same piece of code.
(The example is in Pascal where case is insignificant. I also assume that
underscore is allowed in identifiers, which deviates from the standard.)

(1)    If SomeValue > 23 then
       Begin
          DoApproriateAction(Parameter1, Parameter2, FunctionCall(SomeValue),
                             StatusParameter);
          NotifyUser('Some value is too large!');
       End;

(2)    IF some_value > 23 
       THEN BEGIN
         translation := function_call(some_value);
         do_approriate_action(parameter1, parameter2, translation, 
           status_parameter);
         notify_user('Some value is too large!');
       END;

(3)    if somevalue > 23 then begin
           doapproriateaction (parameter1, parameter2, functioncall(somevalue)
           , statusparameter);
           notifyuser ('Some value is too large!');
       end;

(4)    if SOME_VALUE > 23 then
          begin
          DO_APPRORIATE_ACTION( PARAMETER1, 
                                PARAMETER2, 
                                FUNCTION_CALL( SOME_VALUE ),
                                STATUS_PARAMETER );
          NOTIFY_USER( 'Some value is too large!' );
          end;

As you see we could make a lot of combinations of these versions.
  Privately I use (1). When I got into my first project at my current 
job, they were using (2). Writing reserved words with capital letters
I could accept and even appreciate. But putting THEN under IF I found
unreadable. So the code from that project contains IF statements
of both kinds. Since I made corrections while the other guys were on
holiday, there are even modules that contain both styles.

If we had had an PPP, this would never have occurred. Then we would
had our own profile for the PPP. If I wanted to read some of the other
guys' code I'd just run it through the PPP, and I would have gotten
something that was acceptable for me. And then there would have been
a project profile, to be used on delivery.

You see what I'm after? I want my PPP to be able to re-format the code
to any of the versions in the example above. (Perhaps with exception
of disallowing function calls in parameter lists as in (2). That
may be out of the scope, since it concerns programming style rather than 
formatting style.) 
  Another thing I find important that the PPP must be flexible to the 
language. Ideally, it would be capable to handle any language, but that is
not realistic. But, if it is going to be used on Pascal, there must be
a possibility to tell it about new syntax constructs, new standard names
etc. Pascal compilers often offers you a lot of extensions. It is also
usual, that you have a special pascal-type of language to be used with
one certain (industry) computer. You can't ask for a PPP for each one 
of these. Instead you want one you can take with you where ever you go. 
(As a consultant I change environment from project to project.)

Well, if you know anything that is similar to what I have described,
write a mail to sommar@enea.UUCP and tell me. I would be glad if you 
could supply the following information:
* Which language(s) it works upon.
* Under which OS(s) it runs if it is dependable.
* Costing money or not.
* Pointer to more information (author/vendor/distributor).
To be a bit specific, the languages I am mainly interested of are 
the Pascal dialects and Ada and I want the PPP to run under VMS.
I am however interested in others too, if not for my own use, so 
for the reference.

If this survey gives any interesting result, I will of course 
give a summary to the net.

Erland Sommarskog           sommar@enea.UUCP
ENEA DATA, Stockholm
Technical Details
Message-ID: <1704@enea.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!seismo!mcvax!enea!sommar

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!seismo!mcvax!enea!sommar
From: sommar@enea.UUCP
Newsgroups: comp.lang.misc
Subject: Programmable pretty-printers?
Message-ID: <1704@enea.UUCP>
Date: Sun, 15-Feb-87 14:04:44 EST
Article-I.D.: enea.1704
Posted: Sun Feb 15 14:04:44 1987
Date-Received: Mon, 16-Feb-87 01:58:41 EST
Reply-To: sommar@enea.UUCP(Erland Sommarskog)
Followup-To: comp.lang.misc
Organization: ENEA DATA Svenska AB, Sweden
Lines: 97