Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 3rd, 2006, 6:30 AM   #11
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Quote:
Originally Posted by grumpy
Incorrect. An assignment is an expression that yields the value assigned.
Isn't that what I said? It was what I meant. :o

Edit: Ah yeah stupid, '\0' will result in false too of course (as it is 0). Not just only the 'normal' 0.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates

Last edited by nnxion; Apr 3rd, 2006 at 7:00 AM.
nnxion is offline   Reply With Quote
Old Apr 3rd, 2006, 7:08 AM   #12
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
Actually C ran mostly on DEC PDP-8 systems at Bell Labs in the beginning. Those had
8K-32K of core.

Anything you could do to make a routine occupy less memory was a good idea.
void functions save two bytes on the stack frame because they don't return a value.
void strcpy(char *dest, char *src)
{
      while((*dest++=*src++) );
}
does it in the least possible amount of memory on a PDP. The implicit non-zero comparison also saves one more - a two byte opcode vs a three byte opcode.
jim mcnamara is offline   Reply With Quote
Old Apr 3rd, 2006, 8:00 AM   #13
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
I thought functions returned values by putting the return value in the eax register?
Polyphemus_ is offline   Reply With Quote
Old Apr 3rd, 2006, 8:40 AM   #14
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5 grumpy will become famous soon enough
Actually, Jim, very early C did not even have the void keyword. void return types (and void pointers) were originally introduced as an unofficial extension of K&R C by a number of vendors, including AT&T, and eventually found their way into ANSI/ISO C. The reason usually cited for the introduction of void return from functions, as you suggest, was to allow minimisation of memory used when calling/returning from a function.

Polyphemus_ : Placing a return value into the eax register is a convention used by some compilers on particular hardware and OS. It is certainly not universal. Not all machines have an eax register (heck, some machines don't even have registers).
grumpy is offline   Reply With Quote
Old Apr 3rd, 2006, 9:01 AM   #15
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Storage media didn't have a lot of capacity, either. The first floppies I used were 8-inch, 120K. Digitally recorded cassette tapes were in the 50K - 200K range. Recording density was low enough that one could, using Magnasee, observe individual flux transitions with a 10x loupe or even less.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Apr 3rd, 2006, 9:23 AM   #16
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Quote:
Originally Posted by DaWei
The first floppies I used were 8-inch, 120K. Digitally recorded cassette tapes were in the 50K - 200K range.
Man, I wish I could go back in time and sell my computer.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old Apr 3rd, 2006, 11:02 AM   #17
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
grumpy is correct - the "standard" version of C did not support void to start with.

However, Morristown sent out free Unix and C tapes (you had to return the tape).
By 1980 there were "mixed" versions floating around from umpteen different places like Berkley. We had System VII (yes, Grumpy that's correct) unix on a PDP in 1981(?) for a major parking violations project.

Several of us went to Morristown on a collaborative project, and along the way we picked up crabs. If grumpy was around back then he knows about crabs. It ain't what you think...
jim mcnamara is offline   Reply With Quote
Old Apr 4th, 2006, 6:16 AM   #18
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5 grumpy will become famous soon enough
May be a bit before my time, Jim. For some reason your post made me think of the Maryland Crab, from an article related to parallel computing I read some years back. My knowledge is definitely not first hand though.
grumpy is offline   Reply With Quote
Old Apr 5th, 2006, 2:01 AM   #19
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6 bl00dninja is on a distinguished road
lots of interesting replies...thanks!

i think this summer i will go through the k&r and stroustrup's book to get a better handle on things.
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:20 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC