[ News ] [ Docs ] [ Downloads ] [ Team ] [Eng] [Rus]

The Report on Programming Language Kernfach
(Draft, 2005 January)

Copyright (c) 2005 Denis Lagno.  All rights reserved.
Copyright (c) 2005 The METAFACH Group.  All rights reserved.

Dedicated to M.M.


0.   Design spirit.

Design of Kernfach was driven by following intentions:

it should provide ways to express as much as possible opportunities
for optimization of generated compiled code as far we can
stay machine independent.  Some of those opportunities can
be provided by certain high level abstractions.

it should be simple and elegant.  Occam's razor to the rescue.

it should serve as a machine independent assembler,
universal core programming language.

it may sacrifice simplicity for a human if it can help
to achieve other goals.  If some features can be implemented
at a preprocessor level, they should be.  In other words:
convenience for human is no excuse for bloat and quirks in design.


1.   Source character set, words and kernfach source.

Regular characters are:
the 26 uppercase characters of Latin alphabet:
    A B C D E F G H I J K L M
    N O P Q R S T U V W X Y Z
the 26 lowercase characters of Latin alphabet:
    a b c d e f g h i j k l m
    n o p q r s t u v w x y z
the 10 decimal digits:
    0 1 2 3 4 5 6 7 8 9
the following 25 graphic characters:
    ! ? @ # - _ ; : " , / + = * % ^ & < > { } [ ] \

Special characters are:
the following 3 graphic characters:
    . $ '

Control characters are:
the parentheses:
    ( )
the whitespace.


Source Character Set (SCS) is the set of all regular, special
and control characters.

Word is a (finite) sequence of regular and special characters.

Kernfach Source File (KSF) is a finite sequence of SCS characters
having left and right parentheses balanced.

There shall be an implementation defined mapping from
SCS into integer values.


2.   Core values, lists and entities.

Core value is a value belonging to one (and only one) of following classes:
    symbol
    execution primitive (EP)
    function
    integer value
    floating point value (FPV)
    memory pointer
    frame
    memory area
    channel

They will be described in detail further on.

Entity is either core value, or list.
Every kernfach entity may be annotated with
predicate that should hold true for that entity.
Annotations will be explained in detail further on.

List is a (potentially infinite) sequence of entities.


3.   Evaluation.

Every kernfach entity may be evaluated.  Evaluation is mapping
from set of entities into itself.

Core values evaluate to themselves.

List evaluates following way -- it is viewed as a finite sequence
of entities, then first entitity in the list is evaluated,
it shall be an EP.  Following entities in the list are called
arguments -- first argument, second argument and so on.
Then some action is executed depending on the EP, yielding
the result of evaluation of this list.


4.   Symbols and mangle/demangle mappings.

There is one-to-one mapping called mangling from lists into symbols.
The inverse mapping is called demangling.


5.   Literals.

Words of kernfach source code containing special characters 
represent literals.  Literals designate core values.


5.1. Integer literals.

Word starting with special character $ represents an integer value.

        sign-qualifier:
                 +
                  -
         digit:
                 0
                  1
                  2
                  3
                  4
                  5
                  6
                  7
                  8
                  9
        digit-seq:
                 digit
                 digit-seq digit
        integer-literal:
                 $ sign-qualifieropt digit-seq

5.2. Execution literals.

Word starting with special character . represents an EP.
List of possible execution literals follows:

    .QU .AN .FM .ML .DM .PK .EL .SL .DF .RD .WR .CL

Whether other execution literal exist is implementation defined.


5.3. Symbol literals.

Word of kernfach source code containing only regular characters
represents a symbol.  This symbol can be obtained via mangling
mapping from a list of integer values corresponding to regular
characters being constituents of the word.


6. Execution primitive .QU.

.QU -- quote.

Quote takes one argument and passes it as a result verbatim
without any evaluation.  It is distinct from all other EP
in this regard, because they all evaluate their arguments.


6. Other execution primitives.

All execution primitives (except .QU) evaluate their arguments independently
as a first stage of evaluation.  Following is description of
second stage of evaluation for bunch of EP:

.AN -- annotation.

Annotation takes two arguments and yields first argument annotated
with second argument as a result.

.FM -- frame.

Frame takes three arguments.  First argument shall be a symbol
designating that frame, second argument shall be a list,
and third argument shall be a list of initial priorities.
Then FM evaluates all entities of its second argument (list)
independently, with respect to the list of initial priorities and
results in a list of evaluated entities.

.ML -- mangle.

Mangle takes one argument, it shall be a list.  Then mangle returns
symbol corresponding to that list.

.DM -- demangle.

Demangle takes one argument, it shall be a symbol.  Then demangle
converts this symbol into a list and yields it as a result.

.PK -- pick.

Pick takes two arguments.  First argument shall be a non-negative integer
value, second argument shall be a list.   Pick yilds element of a list
with ordinal position equal to first argument, or undefined value
if an element at this position does not exist.

.EL -- lambda.

..........

.SL -- select.

Select takes two arguments.  First argument shall be a list and second 
argument shall be a predicate.  Select returns the list
containing elements of its first argument matching predicate
in indeterministic order.

.DF -- define.

Define takes three arguments.  First argument shall be a symbol,
second argument shall be a predicate.  Then it evaluates its third
argument with new variable added to the context of evaluation
and yields it as a result.

.RD -- read.

Read takes one argument, it shall be a symbol.
Then it returns value of that symbol as a result.

.WR -- write.

Write takes three arguments.  First argument shall be a symbol.
Then it evaluates its third argument with variable
assigned with a second argument and yields it as a result.

.CL - call.

............


SourceForge.net Logo