Csound Csound-dev Csound-tekno Search About

Re: b (ignore first)

Date1999-01-18 03:03
FromMichael Gogins
SubjectRe: b (ignore first)
What is wrong with macros is:

1. Macros themselves are impossible to debug, and code written with macros
can be quite difficult to debug.

2. People do not usually use macros to do anything that can't be done using
the facilities of the language itself.

3. Macros essentially redefine a part, small or maybe not so small, of the
language. This makes the macro-infested code more difficult to understand.

4. Macros can break the type-safety of the expressions they encode.

5. Clearly defined layers of abstraction can be created by writing
appropriate classes or functions without any of the untoward side effects of
macros.

6. Macros undoubtedly produce highly efficient code, but inlined functions
are exactly as efficient.

I have found through years of experience that writing code in a very
straightforward, uncompressed, text-book style, paying a lot of attention to
naming functions and variables, avoiding macros and other complex
constructions, and allowing the compiler to take care of optimization, is a
good approach. I can write such code quickly, it is easy to understand after
the fact, and the compiler usually makes it faster than I can make it by
trying to get fancy. I find in addition that relying heavily on the highly
standardized, highly debugged core of the language is easier, safer, and
faster than using fancier features. For example, in C++, I tend to avoid
operator overloading, use only simple exception handling, and use regular
"for" loops for iterators rather than creating special iterator classes.


-----Original Message-----
From: J P Fitch 
To: Nicola Bernardini 
Cc: Csound mailing list 
Date: Sunday, January 17, 1999 9:13 AM
Subject: Re: b (ignore first)


>If you changed the sources have you ever thought of helping the community
>and reporting what was changed?
>
>Personally i do not see what is wrong with macros as they can be very
>helpful in abstraction.
>
>==John ff

Date1999-01-18 04:08
FromRicardo MadGello
SubjectMacros and operator overload
Michael Gogins wrote the following snippet
--
What is wrong with macros is:
:snip
For example, in C++, I tend to avoid operator overloading, use only simple
exception handling, and use regular "for" loops for iterators rather than
creating special iterator classes.
:snip
------------------

Is this what is causing the following message when I try to compile Csound
Canonical sources with VC++ 5?
------
:snip
CWIN.CPP
E:\Csound\CWIN.CPP(3807) : error C2666: '!=' : 2 overloads have similar
conversions
:snip
Error executing cl.exe.
winsound.exe - 1 error(s), 0 warning(s)
------

All I'm trying to do is recompile for Pentium Pro optimized executable with
no source changes.  This message shows when I simply bring the 3.50
WinSound.MSW into visual studio and hit "rebuild all", also.

----------------
Along another line, is there anything added or taken away when using the
Multi-Threaded libraries for this?


Sorry if this is a stupid question, just getting started here.  If this
and/or the answer is off-topic for Csound list, send private.


Thanks,
Ricardo MadGello
madgello@oz.net




-----Original Message-----
From: owner-csound-outgoing@maths.ex.ac.uk
[mailto:owner-csound-outgoing@maths.ex.ac.uk]On Behalf Of Michael Gogins
Sent: Sunday, January 17, 1999 7:03 PM
To: J P Fitch; Nicola Bernardini
Cc: Csound mailing list
Subject: Re: b (ignore first)


What is wrong with macros is:

:snip

For example, in C++, I tend to avoid operator overloading, use only simple
exception handling, and use regular "for" loops for iterators rather than
creating special iterator classes.

:snip