• New computation model and perspective of C/C++

    From wij@3:633/280.2 to All on Thu Feb 20 06:26:55 2025
    libwy-0.69.6 is released https://sourceforge.net/projects/cscall/
    The manpage document (description) for Spu is modifed a bit. -----------------------
    Wy.Sct.Spu(3wy) Wy.Sct.Spu(= 3wy)

    NAME
    Spu - Class of general purpose Soft-CPU

    SYNOPSIS
    Except POD types, C structures, all types are declared in namespace = Wy.

    #include <CSCall/Sct.h>

    Spu (Soft CPU) is a revised model of Turing Machine and a class = that
    acts like a general purpose CPU-based computing machine to provide =
    se=E2=80=90
    mantics for computing language and for remote program communication.

    The main differences of Spu and general purpose CPU (or TM) is that=
    Spu
    has no =C2=B4register=C2=B4 nor =C2=B4flag=C2=B4, Spu has only a tap=
    e. The tape is initially
    empty. Every object (referred to as tape variable) in the tape is a= llo=E2=80=90
    cated via instruction Alloc and identified by a continuous index num= ber.
    Tape variable can be any C++ type, including Spu.

    The instruction of Spu is application definable. Except necessary = few,
    about >30 instructions are defined for convenience, see man= page
    Wy.Sct(3wy).

    Documentation following omits the scope name Wy::Sct for each occurr= ence
    of Spu for clearity.

    PUBLIC MEMBERS
    class Reply
    typedef ssize_t IndexType
    Spu()
    ~Spu()

    InstrIdx next_instr
    Array<InstrIdx> istack
    Array<unsign char> tape
    PtrArray<InstrBase> program

    template<T> T& get_data(IndexType) const
    void set_instr_base()
    Errno run(InstrIdx)
    Errno step()
    void add_instr(InstrBase*)
    ----[cut]

    This post is to emphasize the theoretical function and capability of C/C++ language, which is equally important to their practical usage.
    Many might be surprised what the hell C/C++ has anything to do with the theoretical Turing Machine (altho many discussion/program of C/C++ are/were actually abstract, therefore theoretical) and might think they don't need s= uch a
    'trivial' thing. Probably, but likely naive: Turing Machine is the the mode=
    l of
    all general purpose computers. ALL things, including C++, are merely differ= ent
    aspects of TM. The real thing is actually even more, all deterministic form=
    al
    logic and mathemathics (if presented in a formal way) are less powerful tha=
    n TM.
    C++'s application needs not to be database, html, png...,etc.

    Ex1: "Object Oriented": Every function call can be viewed as a method of th=
    e
    object involved in the tape... (programing style involves the decompos= tion
    of the problem, important, but not changing the essence)

    Ex2: "Sequence point": The concept of 'sequence pint' is unnecessary in Spu
    program. In C/C++, 'sequence point' has to be invented. Even so, it mi= ght
    still not be the final term.

    Ex3: if((ch>=3D'a')&&(ch<=3D'z')) { /* ... */ };
    In Spu program, the C/C++ expression above would be like:

    Jb(ch,'a',lab1); // if ch<'a', goto lab1 (exact expression may be a = bit
    // different)
    Ja(ch,'z',lab1); // if ch>'z', goto lab1
    /* ... */
    lab1: ...

    No need to explain what the logical compound statement really mean (
    tradition logic has the similar prboem, just more subtler).

    Ex4: The Peano axiom:
    1. 1=E2=88=88=E2=84=95
    2. n=E2=88=88=E2=84=95 -> S(n)=E2=88=88=E2=84=95

    A problem of Peano axiom is: Is infinity a natural number?
    The basic answer is that, formal logic is inadequate for procedual fac=
    t.
    Basically, Peano axiom did not solve what the 'natural number' is, it = just
    goes in circle changing termonology like C++ does (useful, though, if = you
    do not dig deeper, and no deeper usage as well).

    Ex5: Multi-tasking in Spu is basically just multiple instances of class Spu=
    ..
    Or, you can make tape variables whose type is Spu...

    Ex6: Traditional TM is a simplest case of Spu. It is no sense to restrict
    operations to comparing symbols and only moving r/w head left or right=
    to
    be orthodoxical. And, the idea of Non-Deterministic TM (an obscure,
    obstructive now) can be dropped.

    ---------
    Beside the theoretical part. Class Spu is also useful as the back-end of al=
    l
    interpreting languages (sufificitate ones may be highly optimized).

    Also because the implement of Spu is short, the range of application is hug=
    e and
    foundamental. Clib may consider adding one such thing.


    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: A noiseless patient Spider (3:633/280.2@fidonet)