Constant strings

Discussion in 'C Programming' started by BartC, Apr 18, 2014.

  1. BartC

    Kaz Kylheku Guest

    A C-like dialect is C; it's just not ISO C.
     
    Kaz Kylheku, Apr 29, 2014
    1. Advertisements

  2. BartC

    Kaz Kylheku Guest

    Written by people who counted on their pensions to be statically allocated. :)
     
    Kaz Kylheku, Apr 29, 2014
    1. Advertisements

  3. 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.
     
    Kenny McCormack, Apr 29, 2014
  4. 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.
     
    Malcolm McLean, Apr 29, 2014
  5. (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.

    I think I remember some processors with a four entry return
    address stack.
    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.

    -- glen
     
    glen herrmannsfeldt, Apr 29, 2014
  6. BartC

    David Brown Guest

    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'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 !
    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.
     
    David Brown, Apr 30, 2014
  7. 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.
     
    David Thompson, May 25, 2014
  8. [...]

    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.
     
    Keith Thompson, May 25, 2014
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.