Kalpana Kalpana (Editor)

Comparison of ALGOL 68 and C

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

C++ doesn't have:

Contents

  • PROC - first class nested functions (emulation due to local definitions of class-types, which then could be functors, also new C++11 has lambda functions),
  • OP and PRIO - definable operator symbols and priorities,
  • garbage collection (could be emulated with help of smart pointers),
  • use before define,
  • formatted transput using complex formatting declarations,
  • := - assignment operation symbol (to avoid confusion with equal sign),
  • array (and slice operations on them, but in layered libraries),
  • automatic UNIONs,
  • CASE expressions,
  • nonlocal GOTO
  • intuitive declaration syntax due to its origin from C.
  • ALGOL 68 doesn't have:

  • public/private struct member access protection,
  • overloaded procedures (in contrast to operators),
  • explicit memory deallocation,
  • forward declarations (use before definition is allowed)
  • textual preprocessing (e.g. macros),
  • distinct reference and pointer types,
  • comment lines (only bracketed comments),
  • struct inheritance, struct member functions, virtual functions.
  • destructors, exceptions, templates, namespaces, structured loop exits
  • Union declaration and use

    Assigning values into an A68 union variable is automatic, the type is "tagged" to the variable, but pulling the value back out is syntactically awkward as a conformity-clause is required.

    ALGOL 68 example:

    union(int, char) x:=666; printf(($3d l$, (x|(int i):i) ))

    C/C++ example:

    The net effect of "type-tagging" is that Algol68's strong typing "half" encroaches into the union.

    Mode declaration

    A new mode (type) may be declared using a mode declaration:

    int max=99; mode newtype = [0:9][0:max]struct ( long real a, b, c, short int i, j, k, ref real r );

    This has the similar effect as the following C++ code:

    Note that for ALGOL 68 only the newtype name appears to the left of the equality, and most notably the construction is made - and can be read - from left to right without regard to priorities.

    References

    Comparison of ALGOL 68 and C++ Wikipedia