Click here to Skip to main content
15,886,807 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Lorenzo Bertolino17-May-20 20:59
professionalLorenzo Bertolino17-May-20 20:59 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Richard Deeming18-May-20 1:28
mveRichard Deeming18-May-20 1:28 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
KateAshman17-May-20 21:57
KateAshman17-May-20 21:57 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
kalberts17-May-20 22:48
kalberts17-May-20 22:48 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Richard Deeming18-May-20 1:33
mveRichard Deeming18-May-20 1:33 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
kalberts18-May-20 4:30
kalberts18-May-20 4:30 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Richard Deeming18-May-20 4:39
mveRichard Deeming18-May-20 4:39 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
kalberts18-May-20 20:59
kalberts18-May-20 20:59 
Yes, you are missing something.

The BEGIN-END really has nothing to do with the exception handling - it does NOT announce the ON. It just creates a block out of smaller ones. It has multiple uses; you could e.g. label the block, and skip out of it if some test is not satisfied, like
C++
ManySteps:
BEGIN
   Step1();
   IF PreparationWentWrong THEN EXIT ManySteps;
   Step2();
   IF Specialcondition THEN EXIT ManySteps;
   Step3();
END ManySteps;
This is just a way to make a block that is not a loop, not a conditional statement, not a function body, but just a sequence of smaller blocks put togeteher for some purpose (such as here: For leaving, when conditions are right). Actually, I sometimes do something similar in C#, using a "do { ... } while (false);" to allow me many exits from the statement sequence without cdreating a deep nest of if-statements - but the C family allows just exiting the innermost block; in CHILL you can exit directly from any labeled surrounding block.

Whatever might be: The BEGIN-END has nothing to do with the try {...}. You may say that in CHILL, any block "implies a try {}".

I do not like redundant markup, whether extra keywords, braces, parentheses or whatever. If you say "Here come a DO-block" by using a DO keyword, then you should not need to add neither BEGIN nor a brace to say that "this is the block". Of course it is - you said so already! When you say "Here comes a conditional block" by using an IF keyword, you should not need to use an open parenthesis to say that "here comes the condition". Of course - how often do you see an if keyword not followed by a condition? So why do you have to announce it by opening a parentheses pair? In prose text, you never need to write the condition part of a question in parentheses, why do you have to in C?

If you want to treat two smaller blocks as one unit, whether for exception handling, exiting or whatever, one way or another you must identify which blocks you are talking about. THat markup is not redundant, whether it is done with keywords, braces or indentation alone. When you are comparing the try{} with the BEGIN-END, you are comparing apples with oranges, redundant with non-redundant markup. In C-style languages, the braces are there for the try (alone):
try {
  SingleStatement();
}
catch ...
Well, you could argue that in C languages, the parentheses are not redundant, as a single statement is not considered a block, so the braces are required to created on. That is a major flaw in the language "design". Conceptually, there it adds no information; the braces are conceptually redundant even though the syntax rules explain why they have to be there. In CHILL, there is no such need, neither for bracketing constructs nor for the try keyword.

Braces are fine for their brevity. But they are anonymous; they carry no distinguishing information neither to the compiler nor to the reader. At the end of a deep nest, in C languages there may be a lisp-like sequence of closing parentheses, and you may have a hard time seeing which one closes the outermost loop, the while, the function, the class... With a DO-OD, first, you need no redundant start-of-block brace, second, you know when you see the OD that this is not the end of the function or module or an if, but of the loop. If it is unclear which loop, you may label the statement and include the label after the OD, like I did with the END ManySteps; - this is optional, but if you use it, it is checked by the compiler.

Using OD rather than a closing brace also tells the compiler about your intention: It will match it up with the DO, and can therefore provide much better error reporting and error recovery so that it can go on with the parsing. If the compiler just sees a sequence of closing braces, it cannot tell which one is intended to match which opening brace. So, was the follwing statement intended to be part of the ELSE block? or the loop body? or...?

In my previous post I also illustrated how the explicitness of keywords makes extra bracketing of e.g. on-alternatives unneccessary; the keyword alone gives sufficient information.

For the BEGIN-END pair in particular, you might argue that no more information is added than with braces, so in that case you could use braces. But a mixture of some blocks being denoted by keywords, other by special symbols, looks rather messy. And, you do not that often need to combine an arbitrary sequence of smaller blocks (/statements) into a larger block: When you EXIT something, it is usually a loop, a function or something that is already a block and doesn't need any extra embracing. Same with exception handlers: You very often set them up for a function, a loop, a condition, or a single statement. For the quite few cases where you block up two or three statements for some purposes, you can affort that little handful of extra keystrokes. Especially considering the advantages to readability and improved compiler support.
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Richard Deeming18-May-20 23:40
mveRichard Deeming18-May-20 23:40 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
kalberts19-May-20 6:55
kalberts19-May-20 6:55 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Richard Deeming19-May-20 7:31
mveRichard Deeming19-May-20 7:31 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Stuart Dootson18-May-20 0:59
professionalStuart Dootson18-May-20 0:59 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
BryanFazekas18-May-20 2:21
BryanFazekas18-May-20 2:21 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
W Balboos, GHB18-May-20 2:35
W Balboos, GHB18-May-20 2:35 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Member 1181677618-May-20 3:47
Member 1181677618-May-20 3:47 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
sasadler18-May-20 8:51
sasadler18-May-20 8:51 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
nedzadarek18-May-20 10:25
nedzadarek18-May-20 10:25 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
B Alex Robinson18-May-20 13:45
B Alex Robinson18-May-20 13:45 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Vikram A Punathambekar26-Jun-20 2:57
Vikram A Punathambekar26-Jun-20 2:57 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
Kirk 1038982118-May-20 14:56
Kirk 1038982118-May-20 14:56 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
nedzadarek19-May-20 3:55
nedzadarek19-May-20 3:55 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
kalberts19-May-20 6:15
kalberts19-May-20 6:15 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
johnywhy23-Oct-21 3:45
johnywhy23-Oct-21 3:45 
GeneralRe: What's the Most Concise, Human-Understandable Practical Language? Pin
johnywhy23-Oct-21 3:50
johnywhy23-Oct-21 3:50 
AnswerRe: What's the Most Concise, Human-Understandable Practical Language? Pin
GuyThiebaut19-May-20 0:36
professionalGuyThiebaut19-May-20 0:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.