malloc and functions

O

Old Wolf

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.
 
C

Christopher Benson-Manica

Keith Thompson said:
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 :)
 
S

santosh

Ben said:
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?
 
D

David Thompson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

malloc 33
malloc 40
Naive Custom Malloc Implementation 8
malloc rare error (malloc bug??) 18
malloc() and implicit cast 49
malloc and maximum size 56
Fibonacci 0
using my own malloc() 14

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top