View Issue Details

IDProjectCategoryView StatusLast Update
0000617LDMud 3.3Compilation, Installationpublic2009-05-05 13:50
Reporter_xtian_ Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Summary0000617: relax syntax and warn about obvious coding errors?
DescriptionSince most of the MUD coders are not necessary experienced programmers, why not modify the compiler to catch some obvious mistakes. These could be issued as warnings or even compile-errors.

I just stumbled over:

  if (...);

There is no useful case for this statement, even if it is syntactically correct.
There surely are a lot of other items like this one.

What is the general opinion here? Should we adhere to syntactic rules or enhance useability?
TagsNo tags attached.

Activities

Gnomi

2009-03-31 04:01

manager   ~0001009

Just a few hours ago I stumbled upon the same.

But in a if-elseif-else chain it's only useless if it is the last statement that is empty. Also a foreach loop with an empty statement is useless.

zesstra

2009-04-08 02:36

administrator   ~0001012

Mhmm, isn't that actually making the syntax stricter? Ok, maybe not the syntax itself but I mean, we would make syntactically correct code to raise errors/warning upon compilation. That is not necessarily a bad thing, I appreciate if errors can be caught at compile-time, but I think the title of this issue is confusing in this context.

_xtian_

2009-04-15 20:51

reporter   ~0001041

Yes, the title is weird. I was thinking around the lines of "relaxing the necessity to adhere to syntactic correcteness" ... well, anyhow ...

Having given it some thought I would suggest to issue warnings for these cases and if #pragma pedantic is set - errors.
Also pragmas #warn/no_warn_common_mistakes to switch them on/off.

If the user can switch them off/on on a per-file basis, we can also think about issueing warnings for common mistake cases that could even have real uses, like:
probably: for(...;...;...);
and *maybe* while(...);

fufu

2009-04-16 09:39

manager   ~0001043

Hmm, I'd be more likely to have an empty body in a for loop than in a while loop.

Anyway, as long as these warnings can be switched off, I'm happy.

We can also think about adding a keyword or pseudo efun for intentionally empty statements. I.e. for(;;) ; would give a warning while for(;;) nop; (or whatever) would not.

Gnomi

2009-04-16 10:00

manager   ~0001044

There is a difference between statements that are guaranteed to be useless ('if(expr);' is always the same as 'expr;' as long as no 'else' is following) and statements that might be a mistake. I wouldn't lump them together.

Issue History

Date Modified Username Field Change
2009-03-31 03:53 _xtian_ New Issue
2009-03-31 04:01 Gnomi Note Added: 0001009
2009-04-08 02:36 zesstra Note Added: 0001012
2009-04-15 20:51 _xtian_ Note Added: 0001041
2009-04-16 09:39 fufu Note Added: 0001043
2009-04-16 10:00 Gnomi Note Added: 0001044
2009-05-05 13:50 zesstra Project LDMud => LDMud 3.3