473,605 Members | 2,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Malcolm's new book

The webpages for my new book are now up and running.

The book, Basic Algorithms, describes many of the fundamental algorithms
used in practical programming, with a bias towards graphics. It includes
mathematical routines from the basics up, including floating point
arithmetic, compression techniques, including the GIF and JPEG file formats,
hashing, red black trees, 3D and 3D graphics, colour spaces, machine
learning with neural networks, hidden Markov models, and fuzzy logic,
clustering, fast memory allocators, and expression parsing.

(Follow the links)

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Jul 24 '07
263 9193
"Malcolm McLean" <re*******@btin ternet.comwrite s:
[...]
"Function" is the accepted mathematical term for a mapping of input to
output, which is what a calculation is, so I can use it. "Procedure"
isn't firmed up, largely because the word is used in so many different
ways. However it has the English meaning of a "series of
actions". Given that I'd decided not to coin my own words, procedure
seems the best choice for a subroutine that isn't only a
function. Procedures can call functions, but functions cannot call
procedures.
[...]

Not coining your own word is fine. Coining your own meaning for an
existing word, IMHO, only causes confusion.

--
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."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 26 '07 #31
"Malcolm McLean" <re*******@btin ternet.comwrite s:
[...]
The other factor, as someone else mentioned, is that I can make changes
quite easily. Unfortunately the tools are not quite there yet. For instance
the web pages were saved by Open Office, and it didn't make a very good job
of formatting the code. If I reformatted it all by hands inevitably you get
more typos. Then each change would ahve to be synchronised with two
versions. However I might go down that route, since the webpages are the
place most potential purchasers will probably land on first.
If I were going to write a book on C, I'd maintain all the C sources
separately, and import them into whatever word processing program I'd
use, so the question wouldn't arise. And I'd never include a code
sample in a published work unless I had actually compiled and executed
it. Logical errors happen, as do typos in English text, and they're
difficult to avoid. Most typos in actual code can be avoided.

If you're stuck with exporting your C source code from Open Office,
run it through "indent" or some similar tool rather than trying to
reformat it by hand.

--
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."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 26 '07 #32
Malcolm McLean wrote:
>
"Keith Thompson" <ks***@mib.orgw rote in message
news:ln******** ****@nuthaus.mi b.org...
>I don't have too much of a problem with a C book defining and using
terms like "procedure" and "pure function", as long as it (a) defines
them clearly, (b) defines them in ways that don't conflict too badly
with common usage, and (c) make it very clear that the terms are being
defined by the book, not by the C standard.

It could also be argued that a C book should just use the terminology
defined by the standard, but Malcolm's book isn't really *about* C;
it's primarily about algorithms, using C to present them. In that
context, distinguishing "procedures " and "pure functions" from other
functions is probably sensible.
The question is whether to use an existing word or coin a new one.
... or whether not to bother at all, since the distinction
between "method" and "section" is meaningless in C.
For my purposes

int foo(void)

and

void foo(int *ret)

don't have any really important differences. From a compiler writer's
point of view, of course, it is important that if(foo()) is legal whilst
if(foo(&x)) is not.
Not a special case, nor an essential difference between a
void-valued function and an other-valued one. For example,
consider that

struct bar baz(void);
if (baz()) ...

.... is also invalid, even though baz returns a value. It is
not the void-ness or void-not of a function that determines
whether its returned value can be used in an `if' (or assigned
to a variable, or whatever), but the type of the returned value.
A void-valued function is illegal in some contexts; a struct-
valued function is illegal in some contexts; an int-valued
function is illegal in some contexts. It's the type that makes
the difference, not the void-ness.
Similalry from an algorithms point of view we are not too interested in
whether a function receives its parameters as arguements or in globals.
Under the bonnet a lot of compilers implement globals with a pointer
that is in scope for every function, anyway.
I've never encountered one that does so, no, not even once --
but I've encountered somewhat fewer than all compilers. No doubt
you're right, and the world is full of "a lot" of weird compilers.
(It would go some way towards explaining your ideas about C.)
So the important difference is between code which calculates something,
and code which does something. You could stretch the point by saying
that flow control is a third class of code, but that can probably be
ignored.
Why is this difference "important? " Why is it even "the least
bit important?" It's a pointless digression in the book, that's
all. You should consider removing it from the second printing.
"Function" is the accepted mathematical term for a mapping of input to
output, which is what a calculation is, so I can use it. "Procedure"
isn't firmed up, largely because the word is used in so many different
ways. However it has the English meaning of a "series of actions". Given
that I'd decided not to coin my own words, procedure seems the best
choice for a subroutine that isn't only a function. Procedures can call
functions, but functions cannot call procedures.
Since "procedure isn't firmed up," you can say whatever you
like about it without advancing the discussion.

(Your text offers strlen() as an example of a "function," but
by your definition it isn't one, or at any rate needn't be one.)
>But I've never heard of the term "procedure" being defined in terms of
I/O. Normally a "procedure" would be what C calls a function
returning void. A lot of C functions also have a primary purpose of
causing side effects, but return a result that indicates whether it
succeeded or not; some other languages might, for example, use a
procedure that raises an exception on failure. (qsort() is a good
example.)
That's my use. An "action" is IO, if you think about it. Everything else
is just shuffling bits about in memory.
http://en.wikipedia.org/wiki/Begging_the_question

--
Eric Sosman
es*****@ieee-dot-org.invalid
Jul 27 '07 #33
Christopher Benson-Manica wrote:
regis <re************ **@free.frwrote :
>I did not cite these libraries as places to look for
good style or modern C.
>My point is: typedef'ing structs is a wide practice.

If the practice is both widespread and stylistically questionable
(which you seem to be agreeing with), the statement in the book would
have been better phrased "It is common practice to typedef structs,
but it is not considered good style."
Who died and made you Pope? ;-)

Personally, I typedef structs and unions, don't typedef data
pointers, and sometimes typedef function pointers. I'm not
promoting my style as a model for others to follow: make up your
own mind. But neither am I apologizing for it: who died and made
you Pope? Nor am I condemning people whose styles are different:
who died and made *me* Pope?

Consider for a moment that a professional programmer spends
far more time reading code written by other people than writing
original code of his own. (That is, after all, the fundamental
promise of "code re-use.") It follows that if you are convinced
you know the One Right Way to do things, your programming career
will be short and inglorious.

--
Eric Sosman
es*****@ieee-dot-org.invalid
Jul 27 '07 #34
>>>>"CBM" == Christopher Benson-Manica <at***@otaku.fr eeshell.orgwrit es:

CBMI do hope you will take the time to acknowledge those
CBMpositive contributions.

And either fix the errors at once or withdraw the book until they can
be fixed. There's no excuse for spreading incorrect information.

Charlton
--
Charlton Wilbur
cw*****@chromat ico.net
Jul 27 '07 #35
Keith Thompson wrote:
But I've never heard of the term "procedure" being defined in terms of
I/O. Normally a "procedure" would be what C calls a function
returning void. A lot of C functions also have a primary purpose of
causing side effects, but return a result that indicates whether it
succeeded or not; some other languages might, for example, use a
procedure that raises an exception on failure. (qsort() is a good
example.)
qsort is a good example of what?

--
pete
Jul 27 '07 #36
Malcolm McLean wrote:
But I've never heard of the term "procedure"
being defined in terms of I/O.
Normally a "procedure" would be what C calls a function
returning void. A lot of C functions also have a primary purpose of
causing side effects, but return a result that indicates whether it
succeeded or not; some other languages might, for example, use a
procedure that raises an exception on failure. (qsort() is a good
example.)
That's my use. An "action" is IO, if you think about it.
Everything else is
just shuffling bits about in memory.
I don't understand what you mean by either IO or "action".

All that qsort does, is to shuffle bits about in memory.

--
pete
Jul 27 '07 #37
pete <pf*****@mindsp ring.comwrites:
Keith Thompson wrote:
>But I've never heard of the term "procedure" being defined in terms of
I/O. Normally a "procedure" would be what C calls a function
returning void. A lot of C functions also have a primary purpose of
causing side effects, but return a result that indicates whether it
succeeded or not; some other languages might, for example, use a
procedure that raises an exception on failure. (qsort() is a good
example.)

qsort is a good example of what?
Of me not paying sufficient attention before posting. (I had assumed
qsort returns a status result; in fact, it returns void. Any failure,
such as an inconsistent comparison function, invokes undefined
behavior.)

system() is a better example of what I was talking about.

--
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."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 27 '07 #38
Eric Sosman <es*****@ieee-dot-org.invalidwrot e:
Christopher Benson-Manica wrote:
If the practice is both widespread and stylistically questionable
(which you seem to be agreeing with), the statement in the book would
have been better phrased "It is common practice to typedef structs,
but it is not considered good style."
Who died and made you Pope? ;-)
Clearly my *post* could have been better phrased; fortunately the text
will not be included in any book :-)

(I'm glad it's Friday.)

--
C. Benson Manica | I appreciate all corrections, polite or otherwise.
cbmanica(at)gma il.com |
----------------------| I do not currently read any posts posted through
sdf.lonestar.or g | Google groups, due to rampant unchecked spam.
Jul 27 '07 #39
Keith Thompson <ks***@mib.orgw rote:
Not coining your own word is fine. Coining your own meaning for an
existing word, IMHO, only causes confusion.
Perhaps Malcolm would consider including the glossary in the free
preview for the benefit of future (p)reviewers?

--
C. Benson Manica | I appreciate all corrections, polite or otherwise.
cbmanica(at)gma il.com |
----------------------| I do not currently read any posts posted through
sdf.lonestar.or g | Google groups, due to rampant unchecked spam.
Jul 27 '07 #40

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

Similar topics

9
2422
by: anonymous | last post by:
Hi CLCers, I want to know your opinion about the book: Expert C programming-Deep C secrets by Peter Van Der Linden. Thanks in advance. Sha
12
2104
by: Guido Mureddu | last post by:
Hello, I'm a student in electronic engineering. I do know you've seen and answered this sort of topic/request countless times, but I haven't found past threads as helpful as I had hoped, and even though I have read them all and many reviews, I prefer to ask directly to people who know the subject better than anyone else. First of all, I'm not new to programming, and I have already had an introductory course on C. I have an...
16
8489
by: Robert Zurer | last post by:
Can anyone suggest the best book or part of a book on this subject. I'm looking for an in-depth treatment with examples in C# TIA Robert Zurer robert@zurer.com
8
2186
by: Dgates | last post by:
Has anyone typed up an index for the O'Reilly book "C# and VB.NET Conversion?" I'm just learning C#, and often using this little book to see which VB.NET terms translate directly to some term in C#. However, it's a real hassle that the book has no index, just a table of contents. For example, as early as page 8, the book teaches that C#'s "using" statement is the equivalent of VB.NET's "imports" statement. However, that concept...
11
1919
by: www.douglassdavis.com | last post by:
I'm looking for advice here, and I would really appreciate it if you could help. Is there a VB 2005 book that you like and would recommend (and why)? Would you consider it good for beginners to programming, intermediate, or advanced level?
6
1982
by: Hello | last post by:
Hello every body Please can any body tells me a good book that can teach me "visual basic 2005" (as beginner). Thank you all =========================================
1
3580
by: jrw133 | last post by:
i got this program the other day and ive just started it and i am getting some errors that i cant figure out. requirements: 1)create a clas called Book. a Book has three data members: m_title, m_id and m_flag to tell whether the book is in or checked out. 2)Write a constructor for Book. write a constructor that takes 3 parameters: Book(char * title, int id, bool flag) and initializes the 3 data members accordingly. in addition print out a...
76
4021
by: lorlarz | last post by:
Crockford's JavaScript, The Good Parts (a book review). This shall perhaps be the world's shortest book review (for one of the world's shortests books). I like Douglas Crockford (because I am a crabby old man too; plus he _is_ smart and good).. But, how can he write a book on the good parts of JavaScript and not mention functions that address CSS & DOM? Weird. It's like
0
8001
marktang
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...
0
7934
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,...
0
8415
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 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...
1
8069
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,...
0
8286
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 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...
1
5886
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2438
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
1
1537
muto222
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.