Guest User

ada verbosity experiment hn 05/31/2015

a guest
May 31st, 2015
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. Begin Age
  2.  
  3. Int Age with range 0..120;
  4.  
  5. Print "Hello, how old are you?";
  6. Get(Age);
  7.  
  8. If Age<18 Then
  9. Print "Ha! You're just a baby";
  10. Elseif Age<60 then
  11. Print "Working hard?";
  12. Else
  13. Print "Now take it easy old fella!"
  14. End if
  15.  
  16. Onerror constraint_error =>
  17. Print "Sorry, only ages 0 through 120 are accepted.";
  18.  
  19. End Age
  20.  
  21. As in BASIC, the input-output routine is built-in: no need for that include. The procedure & variable definitions are simplified while conveying same meaning. Other changes are a mix of Ada, BASIC, and Wirth languages. Print is closer to how people think. Could ditch the Then's and End If by using braces. However, I think this is more readable and we all agree that's more important than saving programmers typing. I modified error handling to be simpler. Kept the function ending style. So, this is more readable than the original while taking fewer lines of code.
Advertisement
Add Comment
Please, Sign In to add comment