473,480 Members | 1,525 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Correct Identation/Contex can solve the too many compiler error messages problem when a closing bracket is missing.

Sometime ago on the comp.lang.c, I saw a teacher's post asking why C
compilers produce so many error messages as soon as a closing bracket is
missing. The response was simply because the compiler can't tell where a
bracket is missing.... a few weeks have past, I requested a feature for the
delphi ide/editor "automatic identation of code in begin/end statements etc"
and today when I woke up I suddenly released a very simple solution for this
problem by simply using something called "contex". Which is something
autistic people have great trouble recognizing and since many autistic
people work in the tech industry here is a short example to explain how
"context" can solve the problem.

Let's look at two identation styles.

The first one is my preferred style which is commonly used in pascal/delphi.
Some people in the delphi community recommended to use 2 spaces for identing
a few years ago. I do hope that they by now realize that using tabs is much
more efficient and works faster. I myself use 4 spaces for each tab
character. (Which is also used further down in this example (tabs converted
to spaces) )

Anyway let's get back to the styles.

The first style: pascal/delphi style/my style (the smart style):

begin
<identation>code
<identation>if a<b then
<identation>begin
<identation><identation>code
<identation><identation>code
<identation>end;
end;

The second style: perverted C/Java style (the dumb style):

{
<identation>code
<identation>if a<b {
<identation><identation>code
<identation><identation>code
<identation>}
}

Let's compare both styles.

The second/dumb style is much more hard to figure out where a missing
bracket is located.

Here is an example of the "dumb" style in action:

Can you tell where the missing closing bracket is ?

{
xxxxxxxxxxxxx{
xxxxxxxxxxxxxxxxxxxx{
xxxxxxxx}
xxxxxxxxxxxxxxxxxxxxxxxxx{
xxxxxxxx}xxxxxx{
xxxxxxxx}
xxxxxxxxxxxxxxxxxx{
xxxxxxxxxxxxxxxxxxxxxxxxx{
xxxxxxxx}
xxxx}
}

If you did manage to find it it must have costs you lot's of time to figure
it out ;) Since to figure it out a complex algorithm is necessary to find
the missing bracket.

Now I present to you the smart style:

{
xxxxxxxxxxxx
xxxx{
xxxxxxxxxxxxxxxxxxx
xxxxxxxx{
xxxxxxxx}
xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxx{
xxxxxxxx}xxxxx
xxxxxxxx{
xxxxxxxx}
xxxxxxxxxxxxxxxxx
xxxx{
xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxx{
xxxxxxxx}
xxxx}
}

You didn't spot it the first time ? Take a closer look ! ;)

Yeah now you see it don't you ;)

The 9th bracket is missing in both examples.

However it did cost you much less time to figure out where the missing
bracket is in the smart style.

Why can't a compiler do this ? Why does a compiler have to produce so many
error messages when a closing bracket is missing ? Why isn't the compiler
smart like us ? (well at least some of us)

The answer is: in the context. We are aware of the context.

The context is the identation. The identation indicates where a statement
block begins and ends.

The compiler works like an autistic person. The compiler doesn't recgonize
the context and only looks at the opening and closing brackets.

The compiler could be made more smart like us who use the smart style by
looking at the context. Even the more complex style (the dumb style) could
be used to figure out where a closing bracket should have been... since even
in the dumb style the closing brackets are located at the same positions as
in the smart style.

This shows you how important correct identation is. I myself requested
automatic identation on-the-fly simply because that would be much more
productive, especially when code needs to be cut and pasted in some other
section. In those cases the identation has to be changed everywhere in the
pasted code and it would be really handy if that was automatically done.

However automatic identation can conflict with the solution above. Automatic
identation depending on it's implementation could start moving the
brackets/identations back and forth when a bracket is accidently deleted,
thereby possibly cancelling the usefull information in the
context/identation. Solving this secondary problem remains a challenge for
now ;) =D(ofcourse it's not such a big problem in pascal/delphi since it's
impossible to delete begin/end with a single touch of a button, since it's a
multiple character word ;) unless
it somehow gets cut/deleted away :) )

And in case you were wondering what the real code was here it is:

"dumb style version":

{
if (a<b) {
if (sdfd<c) {
}
if (sqfd<342563) {
} else {
}
}

if (dddd=234) {
if (dsdfssdf=23) {
}
}
}

"smart style version":

{
if (a<b)
{
if (sdfd<c)
{
}
if (sqfd<342563)
{
} else
{
}
}

if (dddd=234)
{
if (dsdfssdf=23)
{
}
}
}

And here is how any other revealing arbitrary code/information was replaced
by x's to soley focus on the identation and brackets themselfes as to see
how easy or hard it would be to recognize where a bracket was missing in an
eye's blink ;) (the 9th bracket below is still present for completeness
sake.)

(Fixed character width font needed for easy viewing of the text below, like
courrier.)

"the dumb style:"

{
if (a<b) {
xxxxxxxxxxxxx{
if (sdfd<c) {
xxxxxxxxxxxxxxxxxxxx{
}
xxxxxxxx}
if (sqfd<342563) {
xxxxxxxxxxxxxxxxxxxxxxxxx{
} else {
xxxxxxxx}xxxxxx{
}
xxxxxxxx}
}
xxxx}
if (dddd=234) {
xxxxxxxxxxxxxxxxxx{
if (dsdfssdf=23) {
xxxxxxxxxxxxxxxxxxxxxxxxx{
}
xxxxxxxx}
}
xxxx}
}

"the smart style":

{
if (a<b)
xxxxxxxxxxxx
{
xxxx{
if (sdfd<c)
xxxxxxxxxxxxxxxxxxx
{
xxxxxxxx{
}
xxxxxxxx}
if (sqfd<342563)
xxxxxxxxxxxxxxxxxxxxxxxx
{
xxxxxxxx{
} else
xxxxxxxx}xxxxx
{
xxxxxxxx{
}
xxxxxxxx}
}
xxxx}
if (dddd=234)
xxxxxxxxxxxxxxxxx
{
xxxx{
if (dsdfssdf=23)
xxxxxxxxxxxxxxxxxxxxxxxx
{
xxxxxxxx{
}
xxxxxxxx}
}
xxxx}
}

Bye,
Skybuck.
Nov 15 '05
102 5564
On Sat, 10 Sep 2005 23:26:37 GMT, Roedy Green
<lo*****@mindprod.com.invalid> wrote:
On Fri, 09 Sep 2005 12:31:41 -0700, Alan Balmer <al******@att.net>
wrote or quoted :
/* } probably this one, but you have to check the logic of the
program to
It was easy to see because all the distracting clutter of the program
itself was stripped away. That hints at a possible tool for helping
find the bugs.


Please note the end of my reply. It's not wise to trust the layout to
define blocks, unless you're writing Python.
The original request was that something AUTOMATICALLY find and correct
or prevent mismatch errors.
I don't think automatic correction is possible, since a matching
bracket could be inserted anywhere. The logic of the program would
change, probably dramatically, but it would be syntactically correct.
Count up the total hours you have wasted in your life chasing such
bugs. Surely a machine should be able to do this better than you will
a little tinkering to the IDE or the language.
Very few hours, and never in my own code. Such bugs are easily
prevented by always typing the closing bracket at the same time as the
opening bracket. With many (most?) editors, this can be automated.

If such bugs are present, most editors that I've used have a way of
matching brackets, which can be a great help.
If you enjoy this sort of work, perhaps you also enjoy collecting
rubber bands and rolling them into balls. Go ahead, but please don't
try to block those of us who find such work mind-numbing, pointless
and infuriating.


I'm not sure what brought on that particular bit of invective. I find
it much better to prevent the need for such work, than to dream about
a program which can magically guess what I meant to write.
--
Al Balmer
Balmer Consulting
re************************@att.net
Nov 15 '05 #51

"Skybuck Flying" <no****@hotmail.com> wrote in message
news:df**********@news4.zwoll1.ov.home.nl...
The point that I was making is that a computer/compiler can use the
"indentation" (tab characters or spaces) to identify where a statement block has ended. Thus it can also detect in which statement block a bracket is
missing.

However this creates an interesting possibility. Instead of using "begin"
and "end" or "{" and "}" to indicate the start and end of a statement
block, the indentication itself could also be used to identify the start end end of a statement block.


Unfortunately this locks authors into one particular layout. There are
almost as many different styles of writing Pascal / Delphi as there are
authors. Personally I know that I have more difficultly understanding code
written in styles that are significantly different from my own. This doesn't
mean that these styles, or my own, are poor, just different.

BTW Begin / End do not mark the start and end of a statement. They are a
statement. As is For / Do, If / Then [/ Else], With / Do, Repeat / Until,
While / Do, Case / End, etc.

I also wonder how one handles situations where an expression is too long to
comfortably fit on a single line. Does it mean that one now has to add a
line continuation marker to the language, a la VB? If so, YUK.

Nov 15 '05 #52

"Skybuck Flying" <no****@hotmail.com> wrote in message
news:df**********@news6.zwoll1.ov.home.nl...
I have proven that one style is cumbersome and therefore dumb and one style is handy and therefore smart.


Debatable. What you have really proven is that you do not understand the
grammar.
Nov 15 '05 #53

"Bruce Roberts" <be*@bounceitattcanada.xnet> wrote in message
news:nu*******************@news20.bellglobal.com.. .

"Skybuck Flying" <no****@hotmail.com> wrote in message
news:df**********@news4.zwoll1.ov.home.nl...
The point that I was making is that a computer/compiler can use the
"indentation" (tab characters or spaces) to identify where a statement

block
has ended. Thus it can also detect in which statement block a bracket is
missing.

However this creates an interesting possibility. Instead of using "begin"
and "end" or "{" and "}" to indicate the start and end of a statement
block, the indentication itself could also be used to identify the start

end
end of a statement block.


This is reminding me of a programming language I used 20 years ago named
Promal. It was a C/Pascal-like language that used indentation to show how
code is nested, instead of using begin-end or {}. It was available for
MS-DOS, Apple-II and the Commodore 64.

- David Harper

Nov 15 '05 #54

"Andrew McDonagh" <ne**@andrewcdonagh.f2s.com> wrote in message
news:df**********@news.freedom2surf.net...
Skybuck Flying wrote:
"Andrew McDonagh" <ne**@andrewcdonagh.f2s.com> wrote in message
news:df**********@news.freedom2surf.net...
Skybuck Flying wrote:

Sometime ago on the comp.lang.c, I saw a teacher's post asking why C
snipped very long message about badly written code and how to 'fix' it
by making indentation better....
You are missing the point....

No, I think you didn't read my post well enough.


I did, I just don't agree with your premise.


No, you didnt read or understand it well enough.

Here are the main points:

Point 1: With the pascal style bracketing/layout it is easier to spot
missing brackets.
The choice of '{}', 'begin end', ';', and any other language block
scoping identifiers is irrelevant - they all suffer the same problems of
people not aligning them.


I agree the choice of {} begin/end etc is irrelevant.

The aligning is most relevant.

The pascal style aligns it properly vertically like so:

if a<b then
begin

end;

Some C styles dont align like so:

if (A<b) {

}

Making it harder to spot where the brackets start and end in an eye's blink
like shown in previous examples.

Again you didnt read it well enough or didnt understand it ;)

You may find the words 'begin & end' to be easier to read and thats fine
- others find them cumbersome.
No you dont understand.
Point 2: Indentation can be used by the computer/compiler to spot missing brackets.
(It can figure out where statement blocks start and stop and where missing brackets are and can simply stop the flow of error messages. )
In some languages yes, but not all languages could.

Any modern IDE has a format code option which will layout the code
regardless of your brackets - allowing you to see where the problem is.

I dont know about that maybe I am missing some points or maybe you making this up.


Not making anything up...

Some questions:

Does borland delphi 2005 have such a code formatting option ?
Does visual studio .net 2003 have such a code formatting option ?
Does borland delphi 7 have such a code formatting option ?

I'm not sure about Delphi 2005 or VS2005 as haven't seen them...but let
me google it...hang on in there... I can't find much info about VS or
Delphi 2005 and Delphi 7 and earlier does not natively support
formatting, but there are plenty of add-ons...

http://www.google.co.uk/search?hl=en...e+Search&meta=

Can you name any modern IDE which has the claimed feature ?


Eclipse, IntelliJ, jbuilder and more.....

Second any method/procedure which is so long that its hard to see the
logical parts of it, is too long....making smaller will help in numerous
ways, not least making it easier to see the indent problems.

Point 2 does this automatically for you.
Point 1 helps you narrow it down.


True they would help with the symptom, but the cure would be not to
create such long methods/procedures which cause mismatching blocks in
the first place.

The smaller a method the easier to read and see, add in code formatters
and the problem 'justGoesAway'
Bye,
Skybuck.


cheerio

Andrew

Nov 15 '05 #55

"Bruce Roberts" <be*@bounceitattcanada.xnet> wrote in message
news:2w*******************@news20.bellglobal.com.. .

"Skybuck Flying" <no****@hotmail.com> wrote in message
news:df**********@news6.zwoll1.ov.home.nl...
I have proven that one style is cumbersome and therefore dumb and one style
is handy and therefore smart.


Debatable.


You can debate it all you want. Tests however will prove that one style is
fast at finding missing brackets and the other style is slow at it ;)
What you have really proven is that you do not understand the
grammar.


I don't feel there is anything wrong with it lol... but that's just me being
used to the dutch grammar.

I guess the correct english grammar could be:

I proofed... etc. instead of I have proven.

The difference could be something like this:

I proofed.... meaning: I did something

I have proven meaning: I own my own actions, I have done that... etc ;)

Bye,
Skybuck.
Nov 15 '05 #56

"Alan Balmer" <al******@att.net> wrote in message
news:cv********************************@4ax.com...
On Sat, 10 Sep 2005 23:26:37 GMT, Roedy Green
<lo*****@mindprod.com.invalid> wrote:
On Fri, 09 Sep 2005 12:31:41 -0700, Alan Balmer <al******@att.net>
wrote or quoted :
/* } probably this one, but you have to check the logic of the
program to


It was easy to see because all the distracting clutter of the program
itself was stripped away. That hints at a possible tool for helping
find the bugs.


Please note the end of my reply. It's not wise to trust the layout to
define blocks, unless you're writing Python.

The original request was that something AUTOMATICALLY find and correct
or prevent mismatch errors.


;)

The original request was about preventing compilers from generating enormous
ammounts of error messages as soon as a bracket is missing. For example by
programming mistake or accident.

The compiler could do this by looking at the indentation which if used
consistently indicates where a statement block starts and stops.

So at the end of a statement block there should be a closing bracket... if
there isn't the compiler could simply stop right there instead of looking at
the rest of the code etc and generating invalid/crazy/stupid error messages
;)

Bye,
Skybuck.
Nov 15 '05 #57
"Skybuck Flying" <no****@hotmail.com> writes:
[...]
The original request was about preventing compilers from generating enormous
ammounts of error messages as soon as a bracket is missing. For example by
programming mistake or accident.

The compiler could do this by looking at the indentation which if used
consistently indicates where a statement block starts and stops.

So at the end of a statement block there should be a closing bracket... if
there isn't the compiler could simply stop right there instead of looking at
the rest of the code etc and generating invalid/crazy/stupid error messages
;)


And how is the compiler supposed to detect the end of a statement
block? The closing brace *defines* the end of a statement block. (At
least it does in C; I'm reading this in comp.lang.c.)

As others have pointed out, there are languages, such as Python, in
which indentation is significant. (Old-style Fortran also requires
rigorous indentation, but that's a bad example.)

And as I mentioned here some time ago, it's possible for a compiler to
use indentation to guess at the intended structure of code, and
thereby give better error messages for missing braces. This doesn't
require indentation to be significant in the language.

None of this is new.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #58

Richard Heathfield wrote:
Another way to "help vi" which doesn't seem quite so funny at first is:

#define HOZE_LEFT_PAREN '('
#define HOZE_RIGHT_PAREN ')'
... On reflection, I am not sure which is worse. :-)

In case you're wondering... HOZE == Help Over-Zealous Editors


I'm not sure why vi's '%' command is over-zealous, especially since
user is under no obligation to ever push the '%' key.

Did you mean "under-zealous"? that vi doesn't attempt
to ignore characters within quotes?

I'm happy with vi's behaviour, conforming to the KISS
dictum: Keep it simple, sailor. In this regard I was horrified
at a suggestion some months ago, perhaps in this newsgroup,
that newsreaders which show lines beginning with "-- "
should be deprecated! Surely I'm not the only one
accustomed, due to Latex, to the "-- " formula for dashes?

James

Nov 15 '05 #59

"Keith Thompson" <ks***@mib.org> wrote in message
news:ln************@nuthaus.mib.org...
"Skybuck Flying" <no****@hotmail.com> writes:
[...]
The original request was about preventing compilers from generating enormous ammounts of error messages as soon as a bracket is missing. For example by programming mistake or accident.

The compiler could do this by looking at the indentation which if used
consistently indicates where a statement block starts and stops.

So at the end of a statement block there should be a closing bracket... if there isn't the compiler could simply stop right there instead of looking at the rest of the code etc and generating invalid/crazy/stupid error messages ;)
And how is the compiler supposed to detect the end of a statement
block? The closing brace *defines* the end of a statement block. (At
least it does in C; I'm reading this in comp.lang.c.)


Lol, easy:

Guess where the opening and closing brackets should be ;)

Something1;
Somethng2;

if (a<b)
Something3;
Something4;
Something5;

Something6;
Something7;
Something8;

if (c<d)
Something9;
Something10;

if (e<f)
Something11;
Something12;
else
Something13;
Something14;
else

if (g<h)
Something15;
Something16;
else
Something17;
Something18;

Something19;
As others have pointed out, there are languages, such as Python, in
which indentation is significant. (Old-style Fortran also requires
rigorous indentation, but that's a bad example.)

And as I mentioned here some time ago, it's possible for a compiler to
use indentation to guess at the intended structure of code, and
thereby give better error messages for missing braces. This doesn't
require indentation to be significant in the language.


Me and the teacher ;) and god knows who else looks forward to seeing this
feature in future compilers ;)

Next time somebody asks this question again I hope people in the comp.lang.c
will answer:

"You have a lazy compiler" ;)

Bye,
Skybuck =D
Nov 15 '05 #60
"Skybuck Flying" <no****@hotmail.com> writes:
"Tim Rentsch" <tx*@alumnus.caltech.edu> wrote in message
news:kf*************@alumnus.caltech.edu...
[newsgroups trimmed to comp.lang.c only]

"Skybuck Flying" <no****@hotmail.com> writes:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C
compilers produce so many error messages as soon as a closing bracket is
missing. The response was simply because the compiler can't tell where a
bracket is missing.... a few weeks have past, I requested a feature for the delphi ide/editor "automatic identation of code in begin/end statements etc" and today when I woke up I suddenly released a very simple solution for this problem by simply using something called "contex". Which is something
autistic people have great trouble recognizing and since many autistic
people work in the tech industry here is a short example to explain how
"context" can solve the problem.

Let's look at two identation styles.

[...snip...blah.blah.blah...]

Here is an example of the "dumb" style in action:

Can you tell where the missing closing bracket is ?

{
xxxxxxxxxxxxx{
xxxxxxxxxxxxxxxxxxxx{
xxxxxxxx}
xxxxxxxxxxxxxxxxxxxxxxxxx{
xxxxxxxx}xxxxxx{
xxxxxxxx}
xxxxxxxxxxxxxxxxxx{
xxxxxxxxxxxxxxxxxxxxxxxxx{
xxxxxxxx}
xxxx}
}


You gotta love a strawman argument.


You make it seem like a strawman argument, since you only converted one
example.

The actual code would look like this:

{
xxxxxxxxx{
xxxxxxxxxxxx{
}
xxxxxxxxxxxxxxxxx{
}xxxxxx{
}
xxxxxxxxxx{
xxxxxxxxxxxxx{
}
}
}

Only a moron couldn't see where the missing brace (aka "bracket")
should go in well under 30 seconds (and that's being generous).

Or perhaps someone who learned programming in Delphi...


Shall we keep things fair and convert the other example as well ?

Smart style:

{
xxxxxxxxxxxx
xxxx{
xxxxxxxxxxxxxxxxxxx
xxxxxxxx{
xxxxxxxx}
xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxx{
xxxxxxxx}xxxxx
xxxxxxxx{
xxxxxxxx}
xxxxxxxxxxxxxxxxx
xxxx{
xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxx{
xxxxxxxx}
xxxx}
}

I shall quote you and modify it:

"Only a moron couldn't see where the missing brace (aka "bracket")
should go in well under 5 seconds (and that's being generous)."


Imitation is the sincerest form of flattery. :)

As for the revised second example - res ipsa loquitur -
the way this example was rewritten speaks for itself.

I'll decline further comment.
Nov 15 '05 #61

"Skybuck Flying" <no****@hotmail.com> wrote in message
news:dg**********@news6.zwoll1.ov.home.nl...

"Bruce Roberts" <be*@bounceitattcanada.xnet> wrote in message
news:2w*******************@news20.bellglobal.com.. .
What you have really proven is that you do not understand the
grammar.


I don't feel there is anything wrong with it lol... but that's just me
being
used to the dutch grammar.


I think Bruce referring to the context-free grammar that describes the
Java language, not your usage of the English grammar.

- Oliver
Nov 15 '05 #62
<ju****@zeusedit.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
As a test I loaded this snippet of code into a test.cpp
file and sure enough the code folding quickly identified
the missing bracket.


In other words, this is (and has long been) a solved problem. Something
Skybuck seems to have trouble understanding. :/

- Oliver
Nov 15 '05 #63

"Oliver Wong" <ow***@castortech.com> wrote in message
news:ErBVe.271041$on1.217553@clgrps13...
I think Bruce referring to the context-free grammar that describes the
Java language, not your usage of the English grammar.


Actually, since I was posting from a Delphi ng, I was referring to the
context-free grammar that describes Delphi. Not that it makes any
difference. The fact is that the suggestion that layout impart grammatical
structure is not as simple as resolving matching compound statement
bracketing.

In Pascal a While loop has the grammar

While <expression> Do <statement>

With a layout dependant grammar one would have to define it

While <expression> Do <newline> <indent> <statement>

Seems to me to be an awful lot of extra fluff for little gain.
Nov 15 '05 #64

"Bruce Roberts" <be*@bounceitattcanada.xnet> wrote in message
news:9M*******************@news20.bellglobal.com.. .

"Oliver Wong" <ow***@castortech.com> wrote in message
news:ErBVe.271041$on1.217553@clgrps13...
I think Bruce referring to the context-free grammar that describes
the
Java language, not your usage of the English grammar.
Actually, since I was posting from a Delphi ng, I was referring to the
context-free grammar that describes Delphi.


Yeah, immediately after I had hit "send", I said to myself "Oh wait,
this guy crossposted to the C and Delphi guys too, right? Damn."
Not that it makes any
difference. The fact is that the suggestion that layout impart grammatical
structure is not as simple as resolving matching compound statement
bracketing.

In Pascal a While loop has the grammar

While <expression> Do <statement>

With a layout dependant grammar one would have to define it

While <expression> Do <newline> <indent> <statement>

Seems to me to be an awful lot of extra fluff for little gain.


Agreed. And if Skybuck is really serious about this idea, (s)he should
probably move the discussion to comp.compilers where it's more appropriate
to discuss language design issues.

- Oliver
Nov 15 '05 #65
Skybuck Flying wrote:

snipped

Here are the main points:

Point 1: With the pascal style bracketing/layout it is easier to spot
missing brackets.
The choice of '{}', 'begin end', ';', and any other language block
scoping identifiers is irrelevant - they all suffer the same problems of
people not aligning them.

I agree the choice of {} begin/end etc is irrelevant.


good...
The aligning is most relevant.
bad... you are missing the point....

The pascal style aligns it properly vertically like so:

if a<b then
begin

end;

Some C styles dont align like so:

if (A<b) {

}


snipped

As I said earlier - the real problem is the size of the method.
Trying to help enforce or aid alignment is focusing upon fixing the
symptom - not the real problem.

if your method only contains one use of blocks, then it does not matter
what alignment strategy the language or developer uses.

As soon as another block is needed, its a good indicator that the method
is trying to do more than one job.

so...


True they would help with the symptom, but the cure would be not to
create such long methods/procedures which cause mismatching blocks in
the first place.

The smaller a method the easier to read and see, add in code formatters
and the problem 'justGoesAway'

Nov 15 '05 #66

"Andrew McDonagh" <ne**@andrewcdonagh.f2s.com> wrote in message
news:dg**********@news.freedom2surf.net...
Skybuck Flying wrote:

snipped

Here are the main points:

Point 1: With the pascal style bracketing/layout it is easier to spot
missing brackets.

The choice of '{}', 'begin end', ';', and any other language block
scoping identifiers is irrelevant - they all suffer the same problems of
people not aligning them.

I agree the choice of {} begin/end etc is irrelevant.


good...
The aligning is most relevant.


bad... you are missing the point....


Nope. You think thing splitting code into multiple methods will solve the
problem somehow.

The point that you are missing is that a missing brace can be an accident ;)

The pascal style aligns it properly vertically like so:

if a<b then
begin

end;

Some C styles dont align like so:

if (A<b) {

}

snipped

As I said earlier - the real problem is the size of the method.


No it's not.

The real problem remains the alignment.

It doesn't matter if the code is split up into multiple methods.

The compiler will still produce a storm of error messages if there is a
missing bracket/brace *anywhere* ;)
Trying to help enforce or aid alignment is focusing upon fixing the
symptom - not the real problem.

if your method only contains one use of blocks, then it does not matter
what alignment strategy the language or developer uses.

As soon as another block is needed, its a good indicator that the method
is trying to do more than one job.

so...


True they would help with the symptom, but the cure would be not to
create such long methods/procedures which cause mismatching blocks in
the first place.

The smaller a method the easier to read and see, add in code formatters
and the problem 'justGoesAway'


Nope lol. A missing bracket/brace can occur on accident.

Bye,
Skybuck.
Nov 15 '05 #67

"Bruce Roberts" <be*@bounceitattcanada.xnet> wrote in message
news:9M*******************@news20.bellglobal.com.. .

"Oliver Wong" <ow***@castortech.com> wrote in message
news:ErBVe.271041$on1.217553@clgrps13...
I think Bruce referring to the context-free grammar that describes the Java language, not your usage of the English grammar.


Actually, since I was posting from a Delphi ng, I was referring to the
context-free grammar that describes Delphi. Not that it makes any
difference. The fact is that the suggestion that layout impart grammatical
structure is not as simple as resolving matching compound statement
bracketing.

In Pascal a While loop has the grammar

While <expression> Do <statement>

With a layout dependant grammar one would have to define it

While <expression> Do <newline> <indent> <statement>

Seems to me to be an awful lot of extra fluff for little gain.


That's not how you would parse it.

There would be something like an indentation count.

As soon as it increases a new statement block begins, as soon as it
decreases the end of a statement block has been reached.

However I like writing code like this in case there are many parameters:

if function(
a,b,c,d,
e,f,g,h,
i,j,k,l ) then
begin
blabla;
end;

This would be a problem unless parameters have to be passed in a special
way.. for example
by using twice the indentation:

if function(
a,b,c,d,
e,f,g,h,
i,j,k,l ) then
begin
blabla;
end;

Which would look like:

if function(
a,b,c,d,
e,f,g,h,
i,j,k,l ) then
blabla;

:)

Bye,
Skybuck.
Nov 15 '05 #68

"Oliver Wong" <ow***@castortech.com> wrote in message
news:btBVe.271042$on1.60786@clgrps13...
<ju****@zeusedit.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
As a test I loaded this snippet of code into a test.cpp
file and sure enough the code folding quickly identified
the missing bracket.
In other words, this is (and has long been) a solved problem.

Something Skybuck seems to have trouble understanding. :/


No I am not aware of any C IDE which does what you say ?

So from your description it would seem the editor loads a file and
completely folds it ???

Or did you fold it yourself manually which is ofcourse retarded... why do it
manually ?

The point is ease of use... so let the compiler or editor do it for you...
which is what this is all about.

Bye,
Skybuck.
Nov 15 '05 #69

"Oliver Wong" <ow***@castortech.com> wrote in message
news:btBVe.271042$on1.60786@clgrps13...
<ju****@zeusedit.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
As a test I loaded this snippet of code into a test.cpp
file and sure enough the code folding quickly identified
the missing bracket.
In other words, this is (and has long been) a solved problem.

Something Skybuck seems to have trouble understanding. :/


After reading your posts I decided to give it a try in visual studio .net
2003. It simply folds the code no matter if there are any missing braces so
at least in this IDE first of all it doesnt find the missing brace and
second of all I had to do it all manually.

// Test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
int a,b,c,sdfd,sqfd,dddd,dsdfssdf;
if (a<b)
{
if (sdfd<c)
{
}
if (sqfd<342563)
{
} else
{
}
if (dddd=234)
{
if (dsdfssdf=23)
{
}
}
return 0;
}
Oh look at that it didn't copy paste it right... well blame it on microsoft
outlook... not going to fix it *again* lol :)
Bye,
Skybuck.
Nov 15 '05 #70

"Oliver Wong" <ow***@castortech.com> wrote in message
news:btBVe.271042$on1.60786@clgrps13...
<ju****@zeusedit.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
As a test I loaded this snippet of code into a test.cpp
file and sure enough the code folding quickly identified
the missing bracket.
In other words, this is (and has long been) a solved problem.

Something Skybuck seems to have trouble understanding. :/


Hmm ok for some reason the previous message did not arrive at my newsreader.

Now I see what he is talking about ;) (Some kind of external editor called
zeus ;))

(Kinda strange that post didnt reach me, anybody have any idea why that is
???)

Ok I installed zeus and paste the code into it, the final result is lol:

You're an idiot.

It doesn't detect jack squat. (It simply folds everything etc lol
hahahahahaha)

Bye,
Skybuck.
Nov 15 '05 #71

"Skybuck Flying" <no****@hotmail.com> wrote in message
news:dg**********@news1.zwoll1.ov.home.nl...
That's not how you would parse it.
It doesn't matter how you would parse it. What matters is how the parser
would parse it. You might want to remember that the parser is doing the work
and it is limited to processing a non-ambiguous grammar.
There would be something like an indentation count.

As soon as it increases a new statement block begins, as soon as it
decreases the end of a statement block has been reached.
And what exactly defines an indent? <newline> followed by <space> or <tab>?
And what if there is a mixture? And how does the parser know what expansion
setting a user's editor was using for <tab> at the time the source was
created?
However I like writing code like this in case there are many parameters:

if function(
a,b,c,d, This would be a problem unless parameters have to be passed in a special
way.. for example
by using twice the indentation:


In Delphi / Pascal the parser has no problems with this since it is working
from a grammar that distinguishes actual parameters from statements. It
might be a problem in C derivatives since an expression can be a statement.
Nov 15 '05 #72

"Bruce Roberts" <be*@bounceitattcanada.xnet> wrote in message
news:aD*******************@news20.bellglobal.com.. .

"Skybuck Flying" <no****@hotmail.com> wrote in message
news:dg**********@news1.zwoll1.ov.home.nl...
That's not how you would parse it.
It doesn't matter how you would parse it. What matters is how the parser
would parse it. You might want to remember that the parser is doing the

work and it is limited to processing a non-ambiguous grammar.
There would be something like an indentation count.

As soon as it increases a new statement block begins, as soon as it
decreases the end of a statement block has been reached.
And what exactly defines an indent? <newline> followed by <space> or

<tab>?

Lookup the basic concept of indentation lol, shouldn't be to hard to grasp.

Here is what you do:

Turn the text into lines.

Then process each line.

How hard would that be ?

And ofcourse tab characters would be mandatory.
And what if there is a mixture? And how does the parser know what expansion setting a user's editor was using for <tab> at the time the source was
created?
See above.
However I like writing code like this in case there are many parameters:

if function(
a,b,c,d,
This would be a problem unless parameters have to be passed in a special
way.. for example
by using twice the indentation:


In Delphi / Pascal the parser has no problems with this since it is

working from a grammar that distinguishes actual parameters from statements. It
might be a problem in C derivatives since an expression can be a

statement.

Problem solved above.

Bye,
Skybuck.
Nov 15 '05 #73

Skybuck Flying wrote:
[]
;)

The original request was about preventing compilers from generating enormous
ammounts of error messages as soon as a bracket is missing. For example by
programming mistake or accident.
What is the big deal. The compiler dumps a lot of error messages you
look at the first one or two, fixing them, and you get to the third one
which doesn't make sense, so you just save your changes and compile
again. If it was a bracket error, most of the other errors all go away.
The compiler could do this by looking at the indentation which if used
consistently indicates where a statement block starts and stops.
I thought we managed to get beyond fixed format code, like FORTRAN II,
a long time ago. Now you want to make it worse by indicating blocks by
indentation. It is not the compiler that has to put in the indentation,
it is you, the programmer. I prefer my freeform C code, Thank you very
much.

So at the end of a statement block there should be a closing bracket... if
there isn't the compiler could simply stop right there instead of looking at
the rest of the code etc and generating invalid/crazy/stupid error messages
;)
Some compilers have options to have it stop after a certain number of
errors. If you are having so much trouble with closing your code
blocks, try switching that on so you have less to deal with when the
compiler barfs on your code. Personally I haven't had this problem due
to a missing close brace for a LONG (years at least.)
Bye,
Skybuck.


Like a similar discussion you started, I think you have a solution
looking for a problem.

Here's the big problem I see with this. You turned the problem of
errors due to missing a SINGLE closing brace into a duty of the
programmer to make sure EVERY line within the code block is indented to
the same level (and exactly how that gets done is still TBD). Not a
good solution in my view.

HTH,

ed

Nov 15 '05 #74
"Ed Prochak" <ed********@magicinterface.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
What is the big deal. The compiler dumps a lot of error messages you
look at the first one or two, fixing them, and you get to the third one
which doesn't make sense, so you just save your changes and compile
again. If it was a bracket error, most of the other errors all go away.


Incidentally, this is also a "solved" problem in compiler theory. There
are algorithms for detecting when one error is the result of another error,
and to supress those "derivative" error messages.

- Oliver
Nov 15 '05 #75

Skybuck Flying wrote:
"Bruce Roberts" <be*@bounceitattcanada.xnet> wrote in message
news:9M*******************@news20.bellglobal.com.. . []

In Pascal a While loop has the grammar

While <expression> Do <statement>

With a layout dependant grammar one would have to define it

While <expression> Do <newline> <indent> <statement>

Seems to me to be an awful lot of extra fluff for little gain.


That's not how you would parse it.

There would be something like an indentation count.

As soon as it increases a new statement block begins, as soon as it
decreases the end of a statement block has been reached.

However I like writing code like this in case there are many parameters:

[]
This would be a problem unless parameters have to be passed in a special
way.. for example
by using twice the indentation:

if function(
a,b,c,d,
e,f,g,h,
i,j,k,l ) then
begin
blabla;
end;

Which would look like:

if function(
a,b,c,d,
e,f,g,h,
i,j,k,l ) then
blabla;

:)

Bye,
Skybuck.


Care to present a grammer for this "indented block" structure?
Code examples don't count.

I don't think a valid grammer for this style can be written in a
context free grammer. In order to keep tract of the block level the
inner level must somehow know the level of the outer block. IOW the
block level is not context free. Bruce's example doesn't work for
anything beyond while loops with a single simple statement. (no sub
blocks like another WHILE or IF)

So show how serious you are by getting down in the works and get it to
happen.

And I agree with others that this solution is worse than the original
problem of missing a block bracket.
Enjoy,
ed

Nov 15 '05 #76

"Ed Prochak" <ed********@magicinterface.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...

Skybuck Flying wrote:
[]
;)

The original request was about preventing compilers from generating enormous ammounts of error messages as soon as a bracket is missing. For example by programming mistake or accident.
What is the big deal. The compiler dumps a lot of error messages you
look at the first one or two, fixing them, and you get to the third one
which doesn't make sense, so you just save your changes and compile
again. If it was a bracket error, most of the other errors all go away.


Well what you rather have:

Storm of bullshit.

Or storm of handy hints and error messages =D

Any sane person would prefer the second one ;)

So it's simply an improvement thing I guess... though you should ask the
teacher.. maybe his students started fucking up all the code ;)

The compiler could do this by looking at the indentation which if used
consistently indicates where a statement block starts and stops.


I thought we managed to get beyond fixed format code, like FORTRAN II,
a long time ago. Now you want to make it worse by indicating blocks by
indentation. It is not the compiler that has to put in the indentation,
it is you, the programmer. I prefer my freeform C code, Thank you very
much.


Fine, the compiler could still use the indentation to provide any possibly
hints and prevent bs-storm ;)

So at the end of a statement block there should be a closing bracket... if there isn't the compiler could simply stop right there instead of looking at the rest of the code etc and generating invalid/crazy/stupid error messages ;)
Some compilers have options to have it stop after a certain number of
errors. If you are having so much trouble with closing your code
blocks, try switching that on so you have less to deal with when the
compiler barfs on your code. Personally I haven't had this problem due
to a missing close brace for a LONG (years at least.)


Lol, how often do you program ? Once every 3 years ? ;)

Bye,
Skybuck.


Like a similar discussion you started, I think you have a solution
looking for a problem.


Nope problem is real look at any compiler today ;)

Here's the big problem I see with this. You turned the problem of
errors due to missing a SINGLE closing brace into a duty of the
programmer to make sure EVERY line within the code block is indented to
the same level (and exactly how that gets done is still TBD). Not a
good solution in my view.


Ahhhh see my second solution: automatic and mandatory indentation ;)

See how the pieces of the puzzle fit together ? =D

Bye,
Skybuck.
Nov 15 '05 #77

"Oliver Wong" <ow***@castortech.com> wrote in message
news:gm%Ve.274399$on1.126208@clgrps13...
"Ed Prochak" <ed********@magicinterface.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
What is the big deal. The compiler dumps a lot of error messages you
look at the first one or two, fixing them, and you get to the third one
which doesn't make sense, so you just save your changes and compile
again. If it was a bracket error, most of the other errors all go away.
Incidentally, this is also a "solved" problem in compiler theory.

There are algorithms for detecting when one error is the result of another error, and to supress those "derivative" error messages.


Sure wong. After reading your previous bullshit about folding... I'll take
this post with a grain of salt.

I know the delphi compiler does a fine job of stoping bs-storms ;) but
delphi is a class of it's own.

C compilers on the other hand LOLOLOLOLOLOLOLOL.

That's all I can say about C compilers LOLOLOL.

Bye,
Skybuck =D
Nov 15 '05 #78

"Ed Prochak" <ed********@magicinterface.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...

Skybuck Flying wrote:
"Bruce Roberts" <be*@bounceitattcanada.xnet> wrote in message
news:9M*******************@news20.bellglobal.com.. . []

In Pascal a While loop has the grammar

While <expression> Do <statement>

With a layout dependant grammar one would have to define it

While <expression> Do <newline> <indent> <statement>

Seems to me to be an awful lot of extra fluff for little gain.


That's not how you would parse it.

There would be something like an indentation count.

As soon as it increases a new statement block begins, as soon as it
decreases the end of a statement block has been reached.

However I like writing code like this in case there are many parameters:

[]

This would be a problem unless parameters have to be passed in a special
way.. for example
by using twice the indentation:

if function(
a,b,c,d,
e,f,g,h,
i,j,k,l ) then
begin
blabla;
end;

Which would look like:

if function(
a,b,c,d,
e,f,g,h,
i,j,k,l ) then
blabla;

:)

Bye,
Skybuck.


Care to present a grammer for this "indented block" structure?
Code examples don't count.

I don't think a valid grammer for this style can be written in a
context free grammer. In order to keep tract of the block level the


Who cares about context free grammer. I dont care about.

I am all for context.

Runtime information is a sort of context.
inner level must somehow know the level of the outer block. IOW the
block level is not context free. Bruce's example doesn't work for
anything beyond while loops with a single simple statement. (no sub
blocks like another WHILE or IF)

So show how serious you are by getting down in the works and get it to
happen.
Lol, Why should I ? Python already does it.

And I agree with others that this solution is worse than the original
problem of missing a block bracket.


Then I guess you wont be programming in python lol ;)

(where there are no brackets in the first place lol =D)

Bye,
Skybuck.
Nov 15 '05 #79
Skybuck Flying wrote:
"Ed Prochak" <ed********@magicinterface.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...

Some compilers have options to have it stop after a certain number of
errors. If you are having so much trouble with closing your code
blocks, try switching that on so you have less to deal with when the
compiler barfs on your code. Personally I haven't had this problem due
to a missing close brace for a LONG (years at least.)


Lol, how often do you program ? Once every 3 years ? ;)


Two points come to mind.

For coders who produce a lot of code, indentation and putting in closing
braces is something you hardly think about - it just happens.

Ed did not explicitly say he never missed a close brace. As I read it he
is saying that, for years, he has not had a problem with the compiler
barfing as a result.
Nov 15 '05 #80

"Bruce Roberts" <be*@bounceitattcanada.xnet> wrote in message
news:eC*******************@news20.bellglobal.com.. .

"Skybuck Flying" <no****@hotmail.com> wrote in message
news:dg*********@news4.zwoll1.ov.home.nl...
And what exactly defines an indent? <newline> followed by <space> or <tab>?

Lookup the basic concept of indentation lol, shouldn't be to hard to

grasp.

So you can't provide a definition. Makes it difficult to take your
suggestion seriously. (Well I can't say that I ever did, anyway.)


You making this much harder than necessary. The Dictionary is your friend :)
Here is what you do:

Turn the text into lines.
And that is done how?


Figure it out yourself please or have other people figure it out for you. I
am not your daddy holding your hand lol.
Then process each line.
And that is done how?

Most compilers leave the processing of text to the lexical analyser,
allowing the parser to concentrate on the token stream. The lexer needs to
know how to recognize tokens, and you need to provide a non-ambiguous
definition of indentation it your scheme is to have a chance.


The compilers might have to work in a different way to be able to handle
"context" ;)

So dont try to force a different concept into it ;)
And ofcourse tab characters would be mandatory.
So those of us that like using spaces are out of luck. What about the
thousands, nay millions of lines of existing source that uses spaces

and/or tabs?
Easily converted.
See above.


Yup, really makes sense. Lets break millions of lines of code to satisfy
someone who can't seem to match their begins and ends.


You are exaggarting ;)

Frankly I am getting quite tired of your posts asking obvious questions and
assuming something can't be done etc etc etc, so I don't feel any need to
spent more energy on your posts than absolutely necessary =D

Bye,
Skybuck.
Nov 15 '05 #81

"Oliver Wong" <ow***@castortech.com> wrote in message
news:JKfWe.277332$on1.42122@clgrps13...

"Skybuck Flying" <no****@hotmail.com> wrote in message
news:dg**********@news3.zwoll1.ov.home.nl...

"Ed Prochak" <ed********@magicinterface.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I don't think a valid grammer for this style can be written in a
context free grammer. In order to keep tract of the block level the
Who cares about context free grammer. I dont care about.

I am all for context.

Runtime information is a sort of context.


Since you don't seem to know what context-free grammars are, I suggest
you read up on them before further embarassing yourself on topics of
programming language design. You can start with Wikipedia:
http://en.wikipedia.org/wiki/Context-free_grammar As an aside, there's no
shame in not knowing what CFGs are (most programmers don't), but it is

very discouraging that, rather than showing a curiosity or desire to learn more
about them, you dismiss them entirely.
I like to keep things practical and simple... the above website is the
opposite of that, and useless for anybody wanting to learn.

Bye,
Skybuck.

If you are not willing to learn, it will be much more difficult (perhaps impossible) for you to become as knowlegeable as someone who IS willing to
learn.
So show how serious you are by getting down in the works and get it to
happen.
Lol, Why should I ? Python already does it.


So in other words, what you want has already been done. It's called
Python, and you're satisfied with Python. So why don't you code in Python,
post on Python related newsgroups, and let the Delphi/C/Java people code

in whatever languages they want?
Then I guess you wont be programming in python lol ;)

(where there are no brackets in the first place lol =D)


Hilarious.

- Oliver

Nov 15 '05 #82

"Thomas Schodt" <sp******@xenoc.demon.co.uk.invalid> wrote in message
news:dg*******************@news.demon.co.uk...
Skybuck Flying wrote:
"Ed Prochak" <ed********@magicinterface.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...

Some compilers have options to have it stop after a certain number of
errors. If you are having so much trouble with closing your code
blocks, try switching that on so you have less to deal with when the
compiler barfs on your code. Personally I haven't had this problem due
to a missing close brace for a LONG (years at least.)


Lol, how often do you program ? Once every 3 years ? ;)


Two points come to mind.

For coders who produce a lot of code, indentation and putting in closing
braces is something you hardly think about - it just happens.

Ed did not explicitly say he never missed a close brace. As I read it he
is saying that, for years, he has not had a problem with the compiler
barfing as a result.


Exactly. I have been coding for 10 years and I dont have a problem with it.

Though sometimes with C when I am newby to some complex C code it could be
nasty, if it's just a simple missing brace somewhere.

So I also have two points:

1. For newby programmers it's always a problem.

2. For advanced programmers new to somebody elses code contain missing
braces it's also a problem.

SWWwwwing =D

Bye,
Skybuck =D

Nov 15 '05 #83

"Skybuck Flying" <no****@hotmail.com> wrote in message
news:dg**********@news1.zwoll1.ov.home.nl...
You making this much harder than necessary. The Dictionary is your friend :)

I take it that you cannot provide a definition of your own concept. ISTM
that this means that you have given no real thought to your own suggestion.
Figure it out yourself please or have other people figure it out for you. I am not your daddy holding your hand lol.
You are the one suggesting the change, not me. If you cannot describe the
basic parameters of your own suggestion its obvious that the suggestion
lacks any real merit.
The compilers might have to work in a different way to be able to handle
"context" ;)

So dont try to force a different concept into it ;)
I see, change a compiler to add a questionable "enhancement". <heavy
sarcasm> Makes sense to me.
Easily converted.
Really? You can't even define what it is to be converted to. How easy is
that?
Yup, really makes sense. Lets break millions of lines of code to satisfy
someone who can't seem to match their begins and ends.


You are exaggarting ;)


You think so? I guess you haven't stopped to consider just how many lines of
Delphi source are kicking around. I know that just on my development machine
I have over 1m lines.
Frankly I am getting quite tired of your posts asking obvious questions and assuming something can't be done etc etc etc, so I don't feel any need to
spent more energy on your posts than absolutely necessary =D


Since you don't spend any time or energy thinking about your own ideas, I'm
not at all surprised that you have to chicken out when pressed for details.

Its not my job to read your mind. If you want a suggestion to go anywhere
you are going to have to explain it and defend it with reasonable detail.
Suggesting that a dictionary will provide an explanation doesn't cut it. I
want to know what you mean by a term, not what some natural language experts
think might be meant.
Nov 15 '05 #84

"Skybuck Flying" <no****@hotmail.com> wrote in message
news:dg**********@news5.zwoll1.ov.home.nl...

Exactly. I have been coding for 10 years and I dont have a problem with
it.
You've been coding for 10 years professionally (i.e. getting paid to do
so), or just 10 years of what you would like to call "coding"? That last
statement may seem a bit antagonistic, but you seem to have a habit of
mis-using words.
Though sometimes with C when I am newby to some complex C code it could be
nasty, if it's just a simple missing brace somewhere.

[snip]
2. For advanced programmers new to somebody elses code contain missing
braces it's also a problem.


I don't know where you've been coding, but I have never been in a
situation where my boss hands me a piece of code written by somebody else
with a missing bracket and told me to work with it. In a business setting,
all the programs I've been handed have, at the very least, compiled.

- Oliver
Nov 15 '05 #85

Skybuck Flying wrote:
The original request was about preventing compilers from generating enormous
ammounts of error messages as soon as a bracket is missing. For example by
programming mistake or accident.

The compiler could do this by looking at the indentation which if used
consistently indicates where a statement block starts and stops.

So at the end of a statement block there should be a closing bracket... if
there isn't the compiler could simply stop right there instead of looking at
the rest of the code etc and generating invalid/crazy/stupid error messages
;)

Rather than trying to change billions of lines of existing code, and
everyone else's behavior for no good reason, if this bothers you so
much consider using one of the Lint packages that will warn you about
odd indentation patterns. If you get a bad block pairing, there will
likely be an "illogical indentation" message.

OTOH, the odds of your code making through Lint seem rather small.

Nov 15 '05 #86
Stop trolling dude.

1. First of all indentation is nothing new so it's not my concept in the
first place.
2. Spaces can easily be converted to tab characters thanks to "tabout" for
textpad try it sometime ;)
3. I do not feel the need to reinvent that which already exists. If you are
really interested in this I would suggest to take a look at python or if
that is unsuited because python is an interpreter instead of a compiler...
then first see if there are other compilers exist which already do this and
are open source and then lastly if all this fails then and only then should
you start using your own brain for a change lol.. since it's not that hard
in the first place.

Let's be honest... if you can't even split a text file into seperates lines
then what can you do ?

Simply put you shouldn't be writing compilers in the first place.

Bye,
Skybuck.

"Bruce Roberts" <be*@bounceitattcanada.xnet> wrote in message
news:_C*******************@news20.bellglobal.com.. .

"Skybuck Flying" <no****@hotmail.com> wrote in message
news:dg**********@news1.zwoll1.ov.home.nl...
You making this much harder than necessary. The Dictionary is your friend
:)

I take it that you cannot provide a definition of your own concept. ISTM
that this means that you have given no real thought to your own suggestion.
Figure it out yourself please or have other people figure it out for you.
I
am not your daddy holding your hand lol.
You are the one suggesting the change, not me. If you cannot describe the
basic parameters of your own suggestion its obvious that the suggestion
lacks any real merit.
The compilers might have to work in a different way to be able to handle
"context" ;)

So dont try to force a different concept into it ;)


I see, change a compiler to add a questionable "enhancement". <heavy
sarcasm> Makes sense to me.
Easily converted.


Really? You can't even define what it is to be converted to. How easy is
that?
Yup, really makes sense. Lets break millions of lines of code to satisfy someone who can't seem to match their begins and ends.


You are exaggarting ;)


You think so? I guess you haven't stopped to consider just how many lines

of Delphi source are kicking around. I know that just on my development machine I have over 1m lines.
Frankly I am getting quite tired of your posts asking obvious questions and
assuming something can't be done etc etc etc, so I don't feel any need

to spent more energy on your posts than absolutely necessary =D


Since you don't spend any time or energy thinking about your own ideas,

I'm not at all surprised that you have to chicken out when pressed for details.
Its not my job to read your mind. If you want a suggestion to go anywhere
you are going to have to explain it and defend it with reasonable detail.
Suggesting that a dictionary will provide an explanation doesn't cut it. I
want to know what you mean by a term, not what some natural language experts think might be meant.

Nov 15 '05 #87

"Oliver Wong" <ow***@castortech.com> wrote in message
news:C1BWe.282270$on1.225345@clgrps13...

"Skybuck Flying" <no****@hotmail.com> wrote in message
news:dg**********@news5.zwoll1.ov.home.nl...

Exactly. I have been coding for 10 years and I dont have a problem with
it.
You've been coding for 10 years professionally (i.e. getting paid to

do so), or just 10 years of what you would like to call "coding"? That last
statement may seem a bit antagonistic, but you seem to have a habit of
mis-using words.
Though sometimes with C when I am newby to some complex C code it could be nasty, if it's just a simple missing brace somewhere.


[snip]
2. For advanced programmers new to somebody elses code contain missing
braces it's also a problem.


I don't know where you've been coding, but I have never been in a
situation where my boss hands me a piece of code written by somebody else
with a missing bracket and told me to work with it. In a business setting,
all the programs I've been handed have, at the very least, compiled.


Lol, I couldn't care a rat's ass less about this bussiness bullshit.

If you want to talk bussiness find another newsgroup.

Here we discuss programming and that is what I am here for.

I cant even count the number of times I downloaded some C source and it
didnt compile etc... and the end result is a storm of BS making my doubt
heavily if it's any use in the first place ;) =D

Nonononono that's a bad first impression dude oh no oh no oh no ohhhhh
noooo.

Bye,
Skybuck :P:P:P:P wieh.
Nov 15 '05 #88

<ro***********@yahoo.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...

Skybuck Flying wrote:
The original request was about preventing compilers from generating enormous ammounts of error messages as soon as a bracket is missing. For example by programming mistake or accident.

The compiler could do this by looking at the indentation which if used
consistently indicates where a statement block starts and stops.

So at the end of a statement block there should be a closing bracket... if there isn't the compiler could simply stop right there instead of looking at the rest of the code etc and generating invalid/crazy/stupid error messages ;)

Rather than trying to change billions of lines of existing code, and
everyone else's behavior for no good reason, if this bothers you so
much consider using one of the Lint packages that will warn you about
odd indentation patterns. If you get a bad block pairing, there will
likely be an "illogical indentation" message.


Mhoaw... rather small improvement really. Nothing to big.
OTOH, the odds of your code making through Lint seem rather small.

Nov 15 '05 #89
> Ok I installed zeus and paste the code into it, the final result is lol:
It doesn't detect jack squat. (It simply folds everything etc lol
hahahahahaha)
If you paste the code into Zeus and fold the first opening brace it
displays this:

{ ....

Notice it does not display the expected result which is this:

{ .... }

Take a guess why?

Ok I will tell you. The "{ .." indicates a fold is missing.

So now open up the fold and try folding the next brace and see if
if folds correctly. Repeat this process a few times and with a
minimal amount of trial and error it quickly becomes clear where
the missing brace should be.

It does require a bit of user input but it certainly aint no rocket
science. Using you example it took me about 20 seconds to
find the missing brace.
You're an idiot.


Don't blame the tool if you don't know how to use it.

Jussi Jumppanen
Author: Zeus for Windows

Nov 15 '05 #90

<ju****@zeusedit.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Ok I installed zeus and paste the code into it, the final result is lol:
It doesn't detect jack squat. (It simply folds everything etc lol
hahahahahaha)


If you paste the code into Zeus and fold the first opening brace it
displays this:

{ ....

Notice it does not display the expected result which is this:

{ .... }

Take a guess why?

Ok I will tell you. The "{ .." indicates a fold is missing.


Ok thanks for this explanation ;)

Bye,
Skybuck =D
Nov 15 '05 #91

Skybuck Flying wrote:
"Ed Prochak" <ed********@magicinterface.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...

Skybuck Flying wrote:
[]
;)

The original request was about preventing compilers from generating enormous ammounts of error messages as soon as a bracket is missing. For example by programming mistake or accident.
What is the big deal. The compiler dumps a lot of error messages you
look at the first one or two, fixing them, and you get to the third one
which doesn't make sense, so you just save your changes and compile
again. If it was a bracket error, most of the other errors all go away.


Well what you rather have:

Storm of bull**expletive**.

Or storm of handy hints and error messages =D

Any sane person would prefer the second one ;)


But your suggestion does NOTHING to really solve the problem.

So it's simply an improvement thing I guess... though you should ask the
teacher.. maybe his students started **expletive**ing up all the code ;)
Sounds like you are the one still in school. If you want to know how
difficult it is to produce those "handy hints", try writing a compiler
with that feature. From the compiler's side it really is had to read
the mind of the programmer to figure out what was intended versus what
was programmed.

The compiler could do this by looking at the indentation which if used
consistently indicates where a statement block starts and stops.
I thought we managed to get beyond fixed format code, like FORTRAN II,
a long time ago. Now you want to make it worse by indicating blocks by
indentation. It is not the compiler that has to put in the indentation,
it is you, the programmer. I prefer my freeform C code, Thank you very
much.


Fine, the compiler could still use the indentation to provide any possibly
hints and prevent bs-storm ;)


Repeating your suggestion does nothing to support it.

So at the end of a statement block there should be a closing bracket... if there isn't the compiler could simply stop right there instead of looking at the rest of the code etc and generating invalid/crazy/stupid error messages ;)
Some compilers have options to have it stop after a certain number of
errors. If you are having so much trouble with closing your code
blocks, try switching that on so you have less to deal with when the
compiler barfs on your code. Personally I haven't had this problem due
to a missing close brace for a LONG (years at least.)


Lol, how often do you program ? Once every 3 years ? ;)


I might ask: when do you plan to start programming? 8^)

Bye,
Skybuck.
Like a similar discussion you started, I think you have a solution
looking for a problem.


Nope problem is real look at any compiler today ;)


The problem is minor. I used to worry about such things when compiling
took a long time and result listings were on paper. Now with compile
times on the order of seconds, I fix whatever missing bracket typo I
have and recompile to find the next one. IOW, this is not a significant
problem except perhaps for inexperienced programmers and you.

Here's the big problem I see with this. You turned the problem of
errors due to missing a SINGLE closing brace into a duty of the
programmer to make sure EVERY line within the code block is indented to
the same level (and exactly how that gets done is still TBD). Not a
good solution in my view.
Ahhhh see my second solution: automatic and mandatory indentation ;)


And how do you determine "automatically" when one block ends?
Point is you cannot.

See how the pieces of the puzzle fit together ? =D

Bye,
Skybuck.


You sure are a puzzle.

Nov 15 '05 #92

Skybuck Flying wrote:
"Ed Prochak" <ed********@magicinterface.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...

Skybuck Flying wrote: [snip]
Care to present a grammer for this "indented block" structure?
Code examples don't count.

I don't think a valid grammer for this style can be written in a
context free grammer. In order to keep tract of the block level the
Who cares about context free grammer. I dont care about.


The compiler writers care about it.

I am all for context.

Runtime information is a sort of context.
We are discussing COMPILE time errors. There isn't even an executable
yet, as far as this discussion goes, let alone RUNTIME context.
inner level must somehow know the level of the outer block. IOW the
block level is not context free. Bruce's example doesn't work for
anything beyond while loops with a single simple statement. (no sub
blocks like another WHILE or IF)

So show how serious you are by getting down in the works and get it to
happen.
Lol, Why should I ? Python already does it.


So then go program in Python. C programmers have been doing fine
without this "improvement" for a long time now.

And I agree with others that this solution is worse than the original
problem of missing a block bracket.
Then I guess you wont be programming in python lol ;)


I don't have problems programming in C, braces and all, thank you very
much.
If I left out a brace in C, I get compile errors. If I mis-indent a
line in python, I might not know until runtime, maybe. (I don't know
since I haven't used python.)

(where there are no brackets in the first place lol =D)
Exactly why the compiler might miss a line in the wrong block.
Bye,
Skybuck.


So far I haven't had a need to learn PYTHON. Certainly identifying
blocks by indentation is not a compelling reason for me to check it
out.

have a good day in school Skybuck. Your teachers miss you.
Ed

Nov 15 '05 #93

Patricia Shanahan wrote:
Ed Prochak wrote:
...
I don't think a valid grammer for this style can be written in a
context free grammer. In order to keep tract of the block level the
inner level must somehow know the level of the outer block. IOW the
block level is not context free. Bruce's example doesn't work for
anything beyond while loops with a single simple statement. (no sub
blocks like another WHILE or IF)


The usual solution to inability to represent a rule in a CFG is to move
it out of the grammar.

For example, whether a token has the correct form to be a Java
identifier can be represented in a CFG. Trying to include in the grammar
issues such as whether there is an in-scope declaration, and if so what
the type is, would prevent the gramme from being context free, so they
are kept out of the grammar that is used for Java parsing.

Similarly, there are ways of fitting a reflection of indentation rules
into a CFG. I've seen it done with abstract INDENT and DEDENT tokens
that increase and reduce the indentation, and take the place of braces
in the CFG. A tokenizer, counting leading whitespace, can determine the
placement of INDENT and DEDENT tokens.

Patricia


But the issue is whether such indentation rules will reduce compiler
errors. I think the answer is No. Skybuck thinks yes

Adding such indentation rules to C will do little to solve Skybucks
inability to understand and use the error messages produced by his C
compiler.

The INDENT/DEDENT rules sound interesting, but I don't see how they
help the problem of errors. If the programmer happens to indent lines
of code to the wrong level, how does the INDENT/DEDENT syntax stop the
compiler from generating, as Skybuck like to say, lots of
bull<expletive> lines of errors?

Ed.

Nov 15 '05 #94
"Ed Prochak" <ed********@magicinterface.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
If the programmer happens to indent lines
of code to the wrong level, how does the INDENT/DEDENT syntax stop the
compiler from generating, as Skybuck like to say, lots of
bull<expletive> lines of errors?


I don't think the INDENT/DEDENT syntax itself with stop the compiler
from generating lots of lines of errors, the concept of INDENT/DEDENT is
orthogonal to the concept of intelligent error message supression, which is
a moderately well understood problem.

To give you an example, consider the following line:

int i = a + (b + (c + (d + e)));

Imagine that a, b, c and d are all integers, while e is something else,
such that you cannot add an integer and whatever e is together. So the
expression "d + e" results in a type error, and will yield an error message.
But that means the type of the expression "(d + e)" (which is distinct from
the expression "d + e") is also erroneous. And the type of "(c + (d + e))"
is erroneous as well, and so on.

What is usually done then is that the compiler has a dummy "error_type"
type that it uses in the type checking phase. When it sees "d + e", it'll
report the error message, but then claim that the type of the expression is
"error_type" (as opposed to say, "int"). Then, by definition, any operation
with an error_type is "legal" in the sense that it generates no errors. So
adding an int to an error_type doesn't generate an error message.

That's how the compiler is able to generate just one error message for
the case above, instead of half a dozen errors.

Handling missing block structure tokens (e.g. '{' and '}' in C-like
languages) is a bit trickier, but still doable, depending on the complexity
of the language, from a parsing point of view. I've never tried to write a C
compiler, so I don't know how hard it'd be in C, but I know that the grammar
that describes the Java language is relatively simple. For example, in Java,
when you encounter a method declaration, you'll know it's a method
declaration for sure; it cannot be confused as a cast operation or a
variable declaration or anything like that.

When the parser encounters something that it doesn't expect, it knows
something's gone wrong (it may be a missing closing bracket, or something
else). In these situations, it can just report the error of seeing something
it doesn't expect, and then stumble along until it encounters something it
recognizes, for example, a method declaration. Since method declarations
can't be nested in Java, if it sees a new method declaration, the parser can
know to close the old method declaration, and just continue parsing on from
there. The idea is to not complain or generate error messages about all
those strange tokens it saw during the "stumbling along" phase, since the
structure of the parse tree is too damaged to make any informed error
messages anyway. Once it grounds itself again, and can establish where it is
located in the parse tree, it can turn error reporting on again, and
continue on its merry way.

- Oliver
Nov 15 '05 #95
Skybuck Flying wrote:
The pascal style aligns it properly vertically like so:

if a<b then
begin

end;


That is your style, not "the pascal style".

I use

if (a<b) then begin
foo();
end;

I find that a lot easier on the eye.

Al
Nov 15 '05 #96
On Fri, 9 Sep 2005 16:45:10 +0200, "Skybuck Flying"
<no****@hotmail.com> wrote:

Mostly Skybuck you spout a lot of junk

However :-
Which is something
autistic people have great trouble recognizing and since many autistic
people work in the tech industry


That is a very astute observation

- on par with a knowledgeable poster's observation that :-

Few programmers have linguistic skills

I'm beginning to think that in a few years, you might get rather good

This one is flogging a dead horse, both Pascal and C were designed for
the compiler - not the programmer
Nov 15 '05 #97

"J French" <er*****@nowhere.uk> wrote in message
news:43**************@news.btopenworld.com...

Few programmers have linguistic skills
While this statement may be true, I think it is misleading. It implies
that computer science and linguistics are diametrically opposed when in fact
the reverse is true. A less misleading statement might be "Computer science
and linguistics are intertwined; unfortunately, few programmers excel in
either domain."
This one is flogging a dead horse, both Pascal and C were designed for
the compiler - not the programmer


I don't know about C and haven't spoken to Thompson and Ritchie to find
out what their intents were, but the above statement is factually false in
the case of Pascal. Pascal was designed to TEACH programming, and in fact,
originally it was only a theoretical language (i.e. there was no intention
to ever actually write a compiler for Pascal).

The fact that Pascal is easy to parse is probably a side effect of it
being developped mainly by academics, who like elegance.

- Oliver
Nov 15 '05 #98

"Oliver Wong" <ow***@castortech.com> wrote in message
news:7GWXe.268436$tt5.162455@edtnps90...
While this statement may be true, I think it is misleading. It implies
that computer science and linguistics are diametrically opposed when in fact the reverse is true. A less misleading statement might be "Computer science and linguistics are intertwined; unfortunately, few programmers excel in
either domain."
Sad, but true.
I don't know about C and haven't spoken to Thompson and Ritchie to find out what their intents were, but the above statement is factually false in
the case of Pascal. Pascal was designed to TEACH programming, and in fact,
originally it was only a theoretical language (i.e. there was no intention
to ever actually write a compiler for Pascal).


For C history see http://www.bell-labs.com/history/unix/btoc.html.

From Pascal User Manual & Report, 2nd Edition, Jensen & Wirth,
Springer-Verlag, 1975, 1st paragraph of Report (pg 133):

"The development of the language Pascal is based on two principal aims. The
first is to make available a language suitable to teach programming . . .
The second is to develop implementations of this language which are both
reliable and efficient on presently available computers."
Nov 15 '05 #99
"Bruce Roberts" <be*@bounceitattcanada.xnet> wrote in message
news:gM********************@news20.bellglobal.com. ..

"Oliver Wong" <ow***@castortech.com> wrote in message
news:7GWXe.268436$tt5.162455@edtnps90...
Pascal was designed to TEACH programming, and in fact,
originally it was only a theoretical language (i.e. there was no
intention
to ever actually write a compiler for Pascal).


From Pascal User Manual & Report, 2nd Edition, Jensen & Wirth,
Springer-Verlag, 1975, 1st paragraph of Report (pg 133):

"The development of the language Pascal is based on two principal aims.
The
first is to make available a language suitable to teach programming . . .
The second is to develop implementations of this language which are both
reliable and efficient on presently available computers."


Hmm, interesting...

I couldn't find any reference to support my earlier statement, except
for this relatively weak one from Wikipedia
(http://en.wikipedia.org/wiki/PASCAL): "Initially, Pascal was a
*HYPOTHETICAL* language intended to teach students structured programming"
(emphasis mine).

- Oliver
Nov 15 '05 #100

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2075
by: doug | last post by:
I am working on a C++ program in .NET. The compiler generates error messages that are associated with the wrong line numbers (which is extremely frustrating). Also, the debugger arrow is...
2
1898
by: Jon Maz | last post by:
Hi All, To allow myself to make development changes directly on a remote server *without* having to compile on my local dev machine and then upload the dll's to remote, I have created a...
1
2632
by: intl04 | last post by:
I am getting strange print-related error messages when trying to create (not print!) reports. For example, when I click 'new' to create a report then choose 'design view', I get an error message...
2
1240
by: Timbit | last post by:
Hi, this is probably an old question, and I have had no luck finding answers to this one on the internet that has helped me out. I installed VS .NET 2003, then I installed IIS 5.1 after that. I...
0
3717
by: Jono | last post by:
Hello, I've been getting this message when closing excel (not necessarily when closing the workbook by itself, but when closing Excel and the workbook at the same time): ...
1
5544
by: Artie | last post by:
Hi, Is there any way to tell an XSD Schema that you want custom error codes for particular validation failures in an XML document? To show what I mean, here's an example: XSD excerpt ...
0
6924
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7124
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6778
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7057
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5376
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4808
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4511
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3023
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
576
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.