A colleague of mine is proposing that we use a set of preprocessor
definitions to make our C code more readable:
#define BEGIN {
#define ENG }
#define EQ ==
etc.
My initial reaction is "Yuck!" (Not too different from the FAQ, which just
says "Bleah").
Aside from that, what are some good reasons to do this, or not to do this?
A few negatives I come up with include:
* Won't work with some tools, such as
- syntax-aware editors
- metrics
- static analysis tools
- coding style enforcement
- code indenters/reformatters
- pretty printers
* Does not check for mismatches (e.g., "{" vs. "END").
* Does not prevent use of {, }, ==, etc., just adds alternatives.
* Requires re-training of C developers who are used to standard C syntax. 57 7527
Mike Malone wrote: A colleague of mine is proposing that we use a set of preprocessor definitions to make our C code more readable:
#define BEGIN { #define END } #define EQ == etc.
My initial reaction is "Yuck!" (Not too different from the FAQ, which just says "Bleah").
Aside from that, what are some good reasons to do this, or not to do this? A few negatives I come up with include:
* Won't work with some tools, such as - syntax-aware editors - metrics - static analysis tools - coding style enforcement - code indenters/reformatters - pretty printers
* Does not check for mismatches (e.g., "{" vs. "END").
* Does not prevent use of {, }, ==, etc., just adds alternatives.
* Requires re-training of C developers who are used to standard C syntax.
Why don't you use a sed script to modify some of your code
and see how you like it?
It takes a while to get used to it
and you will be obliged to invest some time
to adjust your tools to work with it
but, in the end, you will find that
people can get used to just about anything
and that they actually become quite fond of these things.
But, generally, I don't think that it's a good idea
to clutter up your macro namespace unnecessarily.
I believe that "coding style enforcement"
is a source of mischief and such issues
should be left up to the individual programmer.
"Mike Malone" <mr*@prodigy.ne t> writes: A colleague of mine is proposing that we use a set of preprocessor definitions to make our C code more readable:
#define BEGIN { #define ENG } #define EQ ==
The third is similar to the equivalents given in iso646.h:
and &&
and_eq &=
bitand &
bitor |
compl ~
not !
not_eq !=
or ||
or_eq |=
xor ^
xor_eq ^=
I don't know whether that's an argument for or against.
--
Just another C hacker.
Pro - fewer nesting errors...
"Mike Malone" <mr*@prodigy.ne t> writes: A colleague of mine is proposing that we use a set of preprocessor definitions to make our C code more readable:
#define BEGIN { #define ENG } #define EQ == etc.
My initial reaction is "Yuck!" (Not too different from the FAQ, which just says "Bleah").
Aside from that, what are some good reasons to do this, or not to do this? A few negatives I come up with include:
* Won't work with some tools, such as - syntax-aware editors - metrics - static analysis tools - coding style enforcement - code indenters/reformatters - pretty printers
* Does not check for mismatches (e.g., "{" vs. "END").
* Does not prevent use of {, }, ==, etc., just adds alternatives.
* Requires re-training of C developers who are used to standard C syntax.
"Mike Malone" <mr*@prodigy.ne t> writes: A colleague of mine is proposing that we use a set of preprocessor definitions to make our C code more readable:
#define BEGIN { #define ENG } #define EQ == etc.
My initial reaction is "Yuck!" (Not too different from the FAQ, which just says "Bleah").
Aside from that, what are some good reasons to do this, or not to do this?
[...]
There are no good reasons to do this.
--
Keith Thompson (The_Other_Keit h) 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.
Many moons ago someone suggested just this, it was called 'Easy C' and it turned
C into a weird form of Pascal, there were macros and even a small preprocessor.
There were several problems:
1) C programmers had difficulty reading the code
2) Pascal programmers kept thinking it was Pascal
3) People who learnt Easy C had to relearn C when the trainer wheels were removed
The big problem for C programmers is that programs became verbose without saying
more.
#define IF if(
#define THEN )
#define BEGIN {
#define END }
#define eq ==
converts this:
if(x == 1) {
puts("The value is 1");
}
into this:
IF x eq 1 THEN
BEGIN
puts("The value is 1");
END
They will produce the same output but the punctuation now takes up much more space.
"Mike Malone" <mr*@prodigy.ne t> a écrit dans le message de
news:dY******** **********@news svr19.news.prod igy.com... A colleague of mine is proposing that we use a set of preprocessor definitions to make our C code more readable:
#define BEGIN { #define ENG } #define EQ == etc.
My initial reaction is "Yuck!" (Not too different from the FAQ, which
just says "Bleah").
Aside from that, what are some good reasons to do this, or not to do this? A few negatives I come up with include:
* Won't work with some tools, such as - syntax-aware editors - metrics - static analysis tools - coding style enforcement - code indenters/reformatters - pretty printers
* Does not check for mismatches (e.g., "{" vs. "END").
* Does not prevent use of {, }, ==, etc., just adds alternatives.
* Requires re-training of C developers who are used to standard C syntax.
One thing that could be done to make more readable code, instead of
modifying original C syntax, would be to use conventions of identation and
comments.
That helps A LOT MORE than those kind of tricks, in my opinion.
K
"Peter Hickman" <pe***@semantic o.com> wrote in message
news:41******** *************** @news.easynet.c o.uk... Many moons ago someone suggested just this, it was called 'Easy C' and it
turned C into a weird form of Pascal, there were macros and even a small
preprocessor. There were several problems:
1) C programmers had difficulty reading the code 2) Pascal programmers kept thinking it was Pascal 3) People who learnt Easy C had to relearn C when the trainer wheels were
removed The big problem for C programmers is that programs became verbose without
saying more.
#define IF if( #define THEN ) #define BEGIN { #define END } #define eq ==
converts this:
if(x == 1) { puts("The value is 1"); }
into this:
IF x eq 1 THEN BEGIN puts("The value is 1"); END
They will produce the same output but the punctuation now takes up much
more space.
And clutters up the view on the actual *payload*.
On Tue, 14 Dec 2004 03:18:33 GMT, Mike Malone
<mr*@prodigy.ne t> wrote: A colleague of mine is proposing that we use a set of preprocessor definitions to make our C code more readable:
How about your colleague learning C instead? Yes, it is possible to
write 'unreadable' C code, but that is possible with any language,
putting macros round constructs doesn't help.
#define BEGIN { #define ENG } #define EQ == etc.
I've seen it done. But why not counter-suggest that EQ is not
'readable' and it should be EQUALS, NOT_EQUALS, GREATER_THAN etc.?
Don't forget INTEGER instead of int, CHARACTER instead of char, PLUS and
MINUS, INCREMENT and DECREMENT...
You could make the language 'readable' as English like that, and also
increase your source code size by an order of magnitude, thus pleasing
management who will think you are working harder...
My initial reaction is "Yuck!" (Not too different from the FAQ, which just says "Bleah").
Mine as well.
Aside from that, what are some good reasons to do this, or not to do this? A few negatives I come up with include:
I can't see any good reasons to do it. If you want to program in Pascal
or Fortran, get a compiler for the language you like.
* Won't work with some tools, such as - syntax-aware editors - metrics - static analysis tools - coding style enforcement - code indenters/reformatters - pretty printers
Syntax-aware editors alone are a big reason to not do it, they often
save a lot of time all by themselves (for instance automatically
indenting and highlighting -- or rather failing to highlight -- typos in
keywords while typing).
* Requires re-training of C developers who are used to standard C syntax.
And retraining of people who have learned with the odd syntax.
Don't forget source-level debuggers, which are often confused by macros.
Chris C
dandelion wrote: "Peter Hickman" <pe***@semantic o.com> wrote in message
Many moons ago someone suggested just this, it was called 'Easy C' and it turned C into a weird form of Pascal, there were macros and even a small preprocessor. There were several problems:
1) C programmers had difficulty reading the code 2) Pascal programmers kept thinking it was Pascal 3) People who learnt Easy C had to relearn C when the trainer wheels were removed
The big problem for C programmers is that programs became verbose without saying more.
#define IF if( #define THEN ) #define BEGIN { #define END } #define eq ==
converts this:
if(x == 1) { puts("The value is 1"); }
into this:
IF x eq 1 THEN BEGIN puts("The value is 1"); END
They will produce the same output but the punctuation now takes up much more space.
And clutters up the view on the actual *payload*.
At least format the quasi-Pascal properly:
IF x eq 1 THEN BEGIN
puts("The value is 1"); END;
or better:
IF x eq 1 THEN puts("The value is 1");
which still is neither fish nor fowl, real Pascal being:
IF x = 1 THEN writeln('The value is 1');
--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andy |
last post by:
Hi All!
We are doing new development for SQL Server 2000 and also moving from
SQL 7.0 to SQL Server 2000.
What are cons and pros for using IDENTITY property as PK in SQL SERVER
2000?
Please, share your experience in using IDENTITY as PK .
|
by: Zhou Lei |
last post by:
Hi friends I'm a newbie learning XSLT to transform an XML to some other
documents. Now I have some questions, anyone could give me some suggestions
on them?
1. If we save our documents in XML rules and these files should be published
on Internet through WWW, what we can benefit from the XML files? And what
are the drawbacks (is it too complex or time-consuming because we have to
define a new set of XML elements to save the documents, and...
|
by: Fred |
last post by:
Not much expertise on XSLT and trying to understand it's uses when creating
apps in VS.NET?
If I wanted flexibility on the UI (View aspect of M.V.C.):
- How does it compare with creating business components that can be consumed
by WebForms, WinForms, mobile devices, etc? Is it even fair to compare the
such technologies?
- How about for cases when you need to display dynamic elements on the
form/grid (as compared to knowing data elements...
|
by: scott |
last post by:
Hi,
Just wondering what sort of problems and advantages people have found using
stored procedures. I have an app developed in VB6 & VB.NET and our
developers are starting to re-write some of the code in stored procedures
(im advocating encryption of them). When deploying an application however
stored procedure seem to add another level of complexity to installation. In
future we also plan to have an basic ASP app with some of the...
|
by: JayCallas |
last post by:
I have a requirement where I need to perform a query for position
information. But for some types of entries, I need to "expand" the row
to include additional position rows. Let me explain with an example:
An index is a security that is made up of components where each
component has a "weight" or a number of shares. So if I have 1 share of
the index, I have X shares of each component.
AAPL is an Equity, CSCO is an Equity, SPY is an...
| |
by: Andrea |
last post by:
Hello everyone,
I'd like to know which are the main pros and cons of using XML
implementation in business organizations.
>From a technical perspective, I find XML powerful, but looks like it is
being pushed more from technical people than from businessmen...
So, some questions:
1. Pros and cons
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |