Constant strings

K

Kaz Kylheku

(snip)


More specifically, many Fortran 66 and 77 compilers allocated
all variables statically. Some used static storage for the
return address.

Written by people who counted on their pensions to be statically allocated. :)
 
K

Kenny McCormack

A C-like dialect is C; it's just not ISO C.

Not in *this* newsgroup, buddy!

--
Given Bush and his insanely expensive wars (*), that we will be paying for
for generations to come, the only possible response a sensible person need
ever give, when a GOPer/TeaBagger says anything about "deficits", is a
polite snicker.

(*) Obvious money transfers between the taxpayers and Bush's moneyed
interests. Someday, we'll actually figure out a way to have a war where the
money just gets moved around and nobody (on either side) gets injured or
killed. That will be an accomplishment of which we will be justly proud.
 
M

Malcolm McLean

Not in *this* newsgroup, buddy!
A duck that says "who's a pretty boy then?" instead of quacking is still a duck.
So is one that doesn't like to swim, or eats fruit instead of worms and bits of
bread.

But there comes a point when we have to say it's not a duck at all, it's a parrot.
 
G

glen herrmannsfeldt

(snip, someone wrote)
On the compilers I have seen of this sort, they don't normally use
stacks and recursion is avoided when possible - but is not disallowed
completely. Stacks on chips like the 8051 are extremely inefficient for
data, so the compiler usually aims to use fixed memory addresses for
parameter passing and local data (the hardware stack is fine for return
addresses).

If you declare all data static, it won't need to go on the stack.
If you pass arguments in file scope or external variables, instead of
function arguments, they won't go on a stack.

I think I remember some processors with a four entry return
address stack.
On some such compilers, you need special pragmas or extra
keywords to allow a function to be recursive or re-entrant - then it is
not standard C since you need extra compiler-specific lines to get
standard re-entrant behaviour. On other compilers, the compiler can
figure out if a function is used recursively (or re-entrantly from
interrupts) and generate the software stack code only when strictly
needed. My guess is that such compilers are then standard C on that
particular point.

Also, the standard allows for differences in non-hosted systems.
Typically such compilers stray from standard C on other issues, such as
lack of double-precision floating point (sometimes lack of
single-precision floats too), and perhaps lack of 32-bit integer types,
etc. They are, as you say, a C-like dialect.

They might have a name with a C in it, but still not claim to be
C compilers.

-- glen
 
D

David Brown

(snip, someone wrote)



If you declare all data static, it won't need to go on the stack.
If you pass arguments in file scope or external variables, instead of
function arguments, they won't go on a stack.

The idea with such compilers is that you /don't/ declare the data static
(unless you would normally do so, of course) - you declare your local
variables and function parameters normally. The compiler then
translates these into sort-of static data. Because the compiler knows
the lifetimes of these sort-of-static variables, it can share them among
functions in a way that would be impossible for real static data - these
chips don't have much ram either, so such sharing is essential.
I think I remember some processors with a four entry return
address stack.

I've worked with one with a three entry return stack (and no ram at all
- just 32 8-bit registers). I programmed it with gcc - but it was a
small program, and didn't use /all/ the features of C !
Also, the standard allows for differences in non-hosted systems.


They might have a name with a C in it, but still not claim to be
C compilers.

Some claim to be C even though they fail to implement sizeable parts of
the language and standards, others claim to be "standard C" but don't
specify a standard, some call themselves "C" without mentioning
standards even though they follow them very closely - there is a wide
variation. But I don't think I've ever seen an embedded compiler that
honestly called itself a "C-like" compiler.
 
D

David Thompson

I've seen languages that differentiate procedures and functions,
but I've always thought that subroutines are a general term referring
to reusable program units, including procedures and functions and
even any portion of a BASIC program, without a clear block structure,
that can be called by GOSUB <line number>.

Terminology varies.

FORTRAN got there first and had SUBROUTINE (no value) and FUNCTION
(value), which together are called program-unit (although I'm not sure
they were from the beginning). Pascal changed this to PROCEDURE and
FUNCTION, and Ada followed that example.

algol 60 had PROC with or without return (value) type; algol 68 the
same keyword but described them as 'routine', and used explicit 'void'
for no value. PL/I had PROCEDURE or abbreviated PROC with or without
RETURNS(type). C did not use any keyword, but called them 'function'
and allowed value type (defaulting to int until C99) or void.

COBOL originally had only program-unit with no value, but I believe
functions (and OO!) have been added since I parted ways.

Classic BASIC had only GOSUB as you say, but the many variant and
'enhanced' XX-BASIC's have been over much of the map.

LISP strictly speaking had lambda forms and some other special forms,
but they were commonly referred to as functions, and always returned a
value unless aborted, but a special value (identified as) NIL was
variously used for null, empty, unknown, inapplicable, and false.
 
K

Keith Thompson

David Thompson said:
algol 60 had PROC with or without return (value) type; algol 68 the
same keyword but described them as 'routine', and used explicit 'void'
for no value. PL/I had PROCEDURE or abbreviated PROC with or without
RETURNS(type). C did not use any keyword, but called them 'function'
and allowed value type (defaulting to int until C99) or void.
[...]

And prior to the 1989 ANSI C standard, which introduced the void
keyword, all C functions returned a value, at least implicitly.
The equivalent of a valueless function was usually written by
omitting any return statement (or writing "return;") and by having
the caller ignore any returned value.
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top