Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > malloc and functions

Reply
Thread Tools

malloc and functions

 
 
Old Wolf
Guest
Posts: n/a
 
      07-17-2007
On Jul 17, 12:14 pm, Keith Thompson <(E-Mail Removed)> wrote:
> If C had used '$' rather than 'sizeof', nobody would think it's a
> function -- but then there would have been problems in C's early
> years, when keyboards with no '$' character were widespread.


Also I've heard there are a lot of C programs
where '$' is used in identifiers, supported
by compiler extensions now of course.


 
Reply With Quote
 
 
 
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      07-17-2007
Keith Thompson <(E-Mail Removed)> wrote:

> If C had used '$' rather than 'sizeof', nobody would think it's a
> function -- but then there would have been problems in C's early
> years, when keyboards with no '$' character were widespread.


No more problems than there were for keyboards missing various other
characters replaceable by trigraphs. Of course, use of a trigraphed
'$' operator might have been an impediment to understanding what it
*was*, but I certainly think it would have nicely taken care of any
lingering doubts that might be a function

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
 
Reply With Quote
 
 
 
 
santosh
Guest
Posts: n/a
 
      07-17-2007

Ben Bacarisse wrote:
> raphfrk <(E-Mail Removed)> writes:
>
> > sizeof isn't a function ?

>
> No, and it is odd even for an operator:
>
> #include <stdio.h>
>
> int f(void) { return printf("In f()\n"); }
>
> int main(void)
> {
> printf("%zd\n", sizeof f());
> return 0;
> }


Shouldn't the format specifier be zu?

 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      07-17-2007
santosh <(E-Mail Removed)> writes:

> Ben Bacarisse wrote:
>> printf("%zd\n", sizeof f());


> Shouldn't the format specifier be zu?


Of course. Thank you.

--
Ben.
 
Reply With Quote
 
David Thompson
Guest
Posts: n/a
 
      08-26-2007
On Tue, 17 Jul 2007 03:37:52 +0000 (UTC), Christopher Benson-Manica
<(E-Mail Removed)> wrote:

> Keith Thompson <(E-Mail Removed)> wrote:
>
> > If C had used '$' rather than 'sizeof', nobody would think it's a
> > function -- but then there would have been problems in C's early
> > years, when keyboards with no '$' character were widespread.

>

In C's early years _in the US_ where it was developed, keyboards
without '$' were pretty rare. Much more common were ASCII-pre-68-or-so
without { | } ~ (and ` not relevant to C), and EBCDIC/3270 without { }
and ~ although that last was sometimes (often?) paired to 'hook-not'.

(At least keyboards on computer terminals; we're not concerned with
those on accounting machines, or Addressographs, or pianos.)

> No more problems than there were for keyboards missing various other
> characters replaceable by trigraphs. Of course, use of a trigraphed
> '$' operator might have been an impediment to understanding what it
> *was*, but I certainly think it would have nicely taken care of any
> lingering doubts that might be a function


And $ for sizeof in particular could have had the rather nice mnemonic
'cost', especially in the days when memory really was core and cost a
noticeable fraction of a penny per bit. (And discrete-logic registers
occupied ~~1sf boardspace and cost at least a few dollars per bit.)

- formerly david.thompson1 || achar(64) || worldnet.att.net
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
to malloc or not to malloc?? Johs32 C Programming 4 03-30-2006 10:03 AM
porting non-malloc code to malloc micromysore@gmail.com C Programming 3 02-19-2005 05:39 AM
Malloc/Free - freeing memory allocated by malloc Peter C Programming 34 10-22-2004 10:23 AM
free'ing malloc'd structure with malloc'd members John C Programming 13 08-02-2004 11:45 AM
Re: free'ing malloc'd structure with malloc'd members ravi C Programming 0 07-30-2004 12:42 PM



Advertisments