Meikaku · Docs

The Meikaku language guide

For compiler version 1.2.0 (MIT license). Every example below was run through the real compiler. The output you see is what it printed, and none of the syntax is invented.

Learning Meikaku: Meikaku’s syntax, Design by Contract model, inheritance, and Uniform Access follow Eiffel closely. You can learn the language fundamentals from theEiffel language documentation, then use this guide for Meikaku’s Zig compilation, libraries, and compiler-specific details (such as qualified parent calls instead of Precursor).

Getting started

Meikaku 1.2.0 is released under the MIT license for macOS (Apple silicon) and Linux (x86_64 and ARM64). Install with Homebrew — this also installs the required [email protected] toolchain automatically:

brew tap asanagi/tap https://git.asanasoft.com/asanagi/homebrew-tap.git
brew install asanagi/tap/meikaku

Or download a release tarball directly (requires Zig 0.16 on PATH; building native-window programs on Linux also requires GTK 3 and pkg-config):meikaku-v1.2.0-darwin-arm64.tar.gz (6.1 MB, signed & notarized),meikaku-v1.2.0-linux-x86_64.tar.gz (8.6 MB), ormeikaku-v1.2.0-linux-aarch64.tar.gz (8.7 MB).

A Meikaku program is a set of classes. The compiler, mkc, finds them, checks them, translates them to Zig, and the Zig toolchain builds the native program. In the examples on this page the program starts in the class APPLICATION, by running its creation procedure make. Verify your install by saving and running hello.mei:

hello.mei
class APPLICATION
create
    make
feature
    make is
        do
            std_print("Hello, Meikaku\n")
        end
end
Output
Hello, Meikaku

Run it with:

mkc hello.mei -r

These command-line options are the ones used for every example on this page:

OptionWhat it does
-rBuild, then run the program.
-A noneBuild without any contract checks (see Contracts).
-O2Build with optimization.
--build-lib, --libBuild and use precompiled libraries (see below).
--uses json,dbList packages for a single-file run that has no meikaku.json (see Packages and uses).
mkc install <path>, mkc listRegister a package for your user account, or list the packages the compiler knows.

You can also point mkc at a whole directory. It finds every class in it, and the folder layout becomes the namespaces: nissan/car.mei defines nissan.Car. Where to put the compiler's temporary files is set by MEIKAKU_TMPDIR.

Classes and files

  • A class is introduced with class NAME. Its creation procedures follow create, and its routines and attributes sit under feature.
  • A note clause before a class says in plain words what it is for. The standard library uses description: and author:.
  • Comments start with --. A routine body is do ... end, and is follows the signature.
  • There are no import statements. The compiler finds classes in your project's files and in the packages your meikaku.json lists under uses (see Packages and uses).
  • One class model: there is no separate interface or trait. A routine with no do body, marked deferred, is the contract a descendant must fill in.

Older spellings are rejected with a message that says what to use instead. Section keywords take no colons (create, not create:), comments are --, not //, and the keyword is inherit, not inherits.

Packages and uses

Since version 1.2, everything beyond the core comes in a package, and a project says which packages it uses. The standard library groups (json, db, net, ui and so on), your own libraries and native drivers are all packages. Only base, collections,io and time are always available.

meikaku.json
{
  "name": "app",
  "version": "0.1.0",
  "root": "APPLICATION.make",
  "uses": ["json"]
}

A class from a package you did not list is simply not found. There is no hint and no automatic loading, so the manifest is the whole truth about what a project depends on:

class APPLICATION
create
    make
feature
    make is
        local
            j: JSON_VALUE
        do
            std_print("hi\n")
        end
end
With no uses entry
Semantic error in module '': Unknown class/type 'JSON_VALUE'
Semantic Analysis failed: UnknownParentClass

Visibility is not transitive: if your project uses web and web itself usesjson, your own code still has to list json to name its classes. For a single file with no manifest, pass the packages on the command line:

mkc app.mei -r --uses json,db

Your own packages and native drivers

A package is a folder with a meikaku.json of its own. A source package holds .mei files; a native package holds a Zig bridge, as the AsanagiDB driver does. A project points at one underpackages and lists it under uses:

meikaku.json
{
  "name": "tool",
  "version": "0.1.0",
  "root": "APPLICATION.make",
  "uses": ["db", "asanagidb"],
  "packages": {
    "asanagidb": { "path": "../asanagidb-document", "kind": "native" }
  }
}

mkc install <folder> registers a package for your user account, in~/.meikaku/packages.json, so projects can list it without a path. mkc list shows what the compiler knows: the system packages that ship with it, then yours. The compiler looks for a package in the project first, then in your user list, then in the system list.

mkc list
Output
System packages:
  base (source, implicit) -> .../lib/base
  collections (source, implicit) -> .../lib/collections
  io (source, implicit) -> .../lib/io
  time (source, implicit) -> .../lib/time
  concurrency (source) -> .../lib/concurrency
  ...
User packages:
  (none)

Moving a project from 1.1

  • The libraries and drivers keys are rejected with a message that names the replacement. Move each entry into packages and add its name to uses.
  • Add every standard library group the project touches to uses. Compile; each missing one shows up as Unknown class/type.
  • Standard library groups no longer load on their own, so a project that never listed them must now do so.

Types and equality

  • INT or INTEGER is a 64-bit signed integer, REAL a 64-bit float, BOOLEAN a truth value, CHARACTER an 8-bit character, and STRING text.
  • STRING is an expanded class: it is a plain value, so = compares its content.
  • := assigns. = tests equality and /= tests inequality. Writing == as equality is rejected.
  • ~ and /~ compare objects by their contents, through is_equal, while = on two objects asks whether they are the very same one.
  • A function's result is the predefined name Result.
  • A reference that may be empty is declared detachable, and attached x as y checks it before use. The empty value is Void.
  • Strings join with .concat(...) or +, and numbers print with .to_string.

Contracts

Contracts are the heart of Meikaku. They are written in the language, tagged with names, and evaluated while the program runs.

KeywordMeaningIf it fails
requireWhat must be true when the routine is called.The caller is blamed (client blame).
ensureWhat is true when it returns. old x is the value of x on entry.The routine is blamed (supplier blame).
invariantWhat is true of every object of the class, at all times between calls.The routine is blamed (supplier blame).

A failure reports the class, the routine, the tag, and who is to blame. A precondition failure is raised in the caller's own code, so the caller can handle it. The routine's body never runs.

An invariant is checked when an object is created

class APPLICATION
create
    make
feature
    make is
        local
            acc: ACCOUNT
        do
            std_print("Attempting invalid creation procedure...\n")
            create acc.make(-100)
            std_print("Creation procedure completed\n")
        end
end

class ACCOUNT
create
    make
feature
    balance: INT

    make(initial_balance: INT) is
        do
            balance := initial_balance
            std_print("make body finished\n")
        end
invariant
    positive_balance: balance >= 0
end
Output
Attempting invalid creation procedure...
make body finished
panic: Contract violation: class 'ACCOUNT', feature 'class_invariant', tag 'positive_balance' [supplier blame]

Inside a class, calling one of its own routines directly does not re-check the invariant, so a multi-step algorithm may pass through states that are briefly inconsistent. Calls made through an object, such asother.deposit(5), do check it.

Contracts and inheritance

A descendant may accept more than its ancestor, never less. When it redefines a routine, a new precondition is written require else and is combined with the ancestor's by or. A new postcondition is written ensure then and is combined by and.

require else: the call fails only if no level accepts it
class BASE
feature
    process(x: INT) is
        require
            base_req: x = 1000
        do
            std_print("base process\n")
        end
end

class HEIR
inherit
    BASE
        redefine process end
feature
    process(x: INT) is
        require else
            r1: x > 10
            r2: x < 20
        do
            std_print("heir process\n")
        end
end
Calling process(5)
Calling process(5)...
panic: Contract violation: class 'HEIR', feature 'process', tag 'base_req, r1' [client blame]
ensure then: every level's promise must hold
class PARENT
feature
    compute(x: INT): INT is
        do
            Result := x
        ensure
            pos_res: Result > 0
        end
end

class HEIR
inherit
    PARENT
        redefine compute end
feature
    compute(x: INT): INT is
        do
            Result := x
        ensure then
            small_res: Result < 10
        end
end
Calling compute(15)
Calling compute(15)...
panic: Contract violation: class 'HEIR', feature 'compute', tag 'small_res' [supplier blame]

Contracts are a build-time choice

Contracts must only look at state, never change it. That is what makes it safe to remove them. Building with-A none leaves no checks in the program, and a correct program does the same thing without them.

-- Built with:  mkc stripping.mei -r -A none -O2
class APPLICATION
create
    make
feature
    make is
        do
            test_contract(5)
        end

    test_contract(x: INT) is
        require
            must_be_greater_than_10: x > 10
        do
            std_print("Completed successfully without contract checks\n")
        end
end
Output
Completed successfully without contract checks

Inheritance

  • inherit names the parents. A class may have several.
  • redefine replaces an inherited routine. Doing it by accident, without saying so, is a compile error.
  • If two parents both supply the same routine, the heir must settle it with redefine or select. The compiler never resolves a clash silently.
  • There is no rename and no super. To reach a parent's version, call it by the parent's name, as in SHAPE.area.
  • Giving a body to a deferred routine does not need redefine.
  • A frozen class cannot be inherited from.
Two parents, viewed through each
class APPLICATION
create
    make
feature
    make is
        local
            w: WIDGET
            r: RENDERABLE
            e: EVENT_HANDLER
        do
            create w.make
            r := w
            e := w

            std_print("Call via RENDERABLE view:\n")
            r.render

            std_print("Call via EVENT_HANDLER view:\n")
            e.handle_event("click")

            std_print("Call via WIDGET direct:\n")
            w.render
        end
end

class RENDERABLE
feature
    render is
        do
            std_print("RENDERABLE.render\n")
        end
end

class EVENT_HANDLER
feature
    handle_event(evt: STRING) is
        do
            std_print("EVENT_HANDLER.handle_event: ".concat(evt).concat("\n"))
        end
end

class WIDGET
inherit
    RENDERABLE
        redefine render select render end
    EVENT_HANDLER
        redefine handle_event end
create
    make
feature
    make is do end

    render is
        do
            std_print("WIDGET.render\n")
        end

    handle_event(evt: STRING) is
        do
            std_print("WIDGET.handle_event: ".concat(evt).concat("\n"))
        end
end
Output
Call via RENDERABLE view:
WIDGET.render
Call via EVENT_HANDLER view:
WIDGET.handle_event: click
Call via WIDGET direct:
WIDGET.render
A deferred class, completed by a descendant
deferred class PAINTER
feature
    paint_cost: INT is deferred end

    total_cost(n: INT): INT is
        require
            positive: n > 0
        do
            Result := paint_cost * n
        ensure
            not_negative: Result >= 0
        end
end

class ROLLER
inherit
    PAINTER
feature
    paint_cost: INT is
        do
            Result := 7
        end
end

class APPLICATION
create
    make
feature
    make is
        local
            p: ROLLER
        do
            create p
            std_print("Cost for 3: ".concat(p.total_cost(3).to_string).concat("\n"))
        end
end
Output
Cost for 3: 21

Visibility and uniform access

A client cannot tell an attribute from a routine that computes the same thing: both are read the same way, ass.area or s.scale. In version 1.1.0 this rule became strict: a feature that takes no arguments is written with no parentheses.

A library class used below
class SHAPE
create
    make
 is
    feature
        make is
            do
                scale := 1
            end

        scale: INTEGER = 1

        area: INTEGER is
            do
                Result := base_area * scale
            end

        describe_twice: INTEGER is
            do
                Result := area + area
            end

        base_area: INTEGER is
            do
                Result := 10
            end

    feature { NONE }
        helper_bonus: INTEGER is
            do
                Result := 5
            end

        with_bonus: INTEGER is
            do
                Result := area + helper_bonus
            end
end
  • Attributes are read-only outside their class. A client reads s.scale but cannot assign to it.
  • A feature { NONE } section is private to the class.
Assigning to an attribute from a client
class MAIN
create
    make
 is
    feature
        make is
            local
                s: SHAPE
            do
                create s.make
                s.scale := 5
                std_print (s.scale.to_string)
            end
end
Compiler message
Semantic error in class 'MAIN': Cannot assign to attribute 'scale' of class 'SHAPE' from a client; attributes are read-only outside their class.
Writing parentheses on a zero-argument feature
        make is
            local
                s: SHAPE
            do
                create s.make
                std_print (s.area().to_string)
            end
Compiler message
Semantic error in class 'MAIN': Feature 'area' takes no arguments; write 's.area', not 's.area()'.

Control flow and errors

Loops

A loop has an initialization, an exit test, and optionally an invariant that must hold on every pass and a variant, a number that shrinks on every pass, showing that the loop will end.

class APPLICATION
create
    make
feature
    make is
        local
            i: INT
        do
            from
                i := 0
            until
                i >= 3
            invariant
                non_negative: i >= 0
            variant
                3 - i
            loop
                std_print("i = ".concat(i.to_string).concat("\n"))
                i := i + 1
            end
        end
end
Output
i = 0
i = 1
i = 2

Once routines

A once routine runs its body on the first call and returns the same result every time after.

class APPLICATION
create
    make
feature
    make is
        local
            cfg1: CONFIG
            cfg2: CONFIG
        do
            cfg1 := global_config
            std_print("First access: host = ".concat(cfg1.host).concat(", port = ").concat(cfg1.port.to_string).concat("\n"))

            cfg2 := global_config
            std_print("Second access: host = ".concat(cfg2.host).concat(", port = ").concat(cfg2.port.to_string).concat("\n"))
        end

    global_config: CONFIG is
        once
            std_print("Initializing once CONFIG instance...\n")
            Result := create CONFIG.make("localhost", 8182)
        end
end

class CONFIG
create
    make
feature
    host: STRING
    port: INT

    make(a_host: STRING, a_port: INT) is
        do
            host := a_host
            port := a_port
        end
end
Output
Initializing once CONFIG instance...
First access: host = localhost, port = 8182
Second access: host = localhost, port = 8182

Rescue and retry

A rescue clause handles an exception raised in the routine. retry runs the routine again from the top. Exceptions are raised with the library, as{DEVELOPER_EXCEPTION}.raise(...), and the plain raise statement is rejected.

PORT_CLIENT, called as connect(&quot;127.0.0.1&quot;, 9999)
class PORT_CLIENT
create
    make
feature
    attempts: INT

    make is
        do
            attempts := 0
        end

    connect(host: STRING, port: INT): BOOLEAN is
        do
            attempts := attempts + 1
            std_print("Connecting to ".concat(host).concat(":").concat(port.to_string).concat(" (attempt ").concat(attempts.to_string).concat(")...\n"))
            if attempts < 3 then
                {DEVELOPER_EXCEPTION}.raise("Connection refused on port ".concat(port.to_string))
            end
            Result := true
        rescue
            std_print("Caught error in rescue block\n")
            if attempts < 3 then
                std_print("Retrying connection...\n")
                retry
            else
                std_print("Max attempts reached, returning false cleanly\n")
                Result := false
            end
        end
end
Output
Connecting to 127.0.0.1:9999 (attempt 1)...
Caught error in rescue block
Retrying connection...
Connecting to 127.0.0.1:9999 (attempt 2)...
Caught error in rescue block
Retrying connection...
Connecting to 127.0.0.1:9999 (attempt 3)...
Connection succeeded after retries

Generics

A class can take a type parameter, written in square brackets. The standard collections work the same way, for example ARRAYED_LIST[NODE] and HASH_TABLE[STRING, NODE].

class CELL[G]
create
    make
feature
    item: G

    make(initial: G) is
        do
            item := initial
        end
end

class APPLICATION
create
    make
feature
    make is
        local
            numbers: CELL[INT]
            words: CELL[STRING]
        do
            create numbers.make(42)
            create words.make("Meikaku")
            std_print("Number: ".concat(numbers.item.to_string).concat("\n"))
            std_print("Word: ".concat(words.item).concat("\n"))
        end
end
Output
Number: 42
Word: Meikaku

A class of your own with the same name as a library class, such as BOX, takes its place in your project. The core kernel classes (for example STRING and INTEGER) cannot be redefined: the compiler stops with Cannot redefine standard kernel class.

Zig and C interop

A routine can have a native body written in Zig. It keeps its contract, so the promise around the Zig code is still checked. In the current compiler the Zig code sets the variable result and then returns it.

class APPLICATION
create
    make
feature
    make is
        do
            std_print("sqrt(16.0) = ".concat(root_of(16.0).to_string).concat("\n"))
        end

    root_of(val: REAL): REAL is
        require
            non_negative: val >= 0.0
        native
            const res = std.math.sqrt(val);
            result = res;
            return res;
        ensure
            non_negative_result: Result >= 0.0
        end
end
Output
sqrt(16.0) = 4.0000

The standard library uses the same door to reach C libraries. For example, LIBUI is a direct binding to the libui-ng C API, and SQLITE_DB is built on C interop.

Solutions and libraries

Meikaku ships with a batteries-included standard library for building services, CLI tools, data pipelines, and native desktop or terminal apps—and compiles to Zig so you can wrap existing C and Zig libraries behind checked contracts.

Web & Networking

Build HTTP/HTTPS clients, status APIs, web apps with routing and sessions, raw TCP/TLS sockets, and TLS certificate probes.

Databases & Storage

Talk directly to AsanagiDB (Compository documents + Gremlin), SQLite, PostgreSQL, and Redis.

Desktop & Terminal UIs

Ship native macOS/Linux windows via libui-ng, ANSI terminal apps, and 2D graph layouts with contract-checked widget lifecycles.

Systems, Concurrency & Security

Channels, mutexes, worker pools, filesystem and subprocess APIs, plus AES-256-GCM and SHA/HMAC primitives.

Leveraging external C, Zig, and precompiled libraries

  • External C libraries: Because mkc compiles through Zig, any C library with headers can be called from a native routine via Zig’s C interop (@cImport) and wrapped in a Meikaku class whose require, ensure, and invariantclauses guard every boundary. This is how the standard library itself wraps libui-ng,sqlite3, and OpenSSL (see Zig and C interop).
  • Direct Zig code: Drop into a native block whenever you need low-level systems access, OS APIs, or hot-loop tuning while keeping Meikaku’s contract checks around the routine.
  • Reusable Meikaku bundles (.meilib): Compile a cluster of Meikaku classes once into a precompiled library and link it into other programs with contracts and cross-library inheritance intact (see Precompiled libraries).

Standard library

Each group below is a package. Only base, collections, io and timeare always available; list any other group under uses (see Packages and uses). The descriptions below come from each class's own note clause. A check mark means the compiler's conformance suite has cases that use the class. A dash means the class is part of the library but has no conformance case of its own yet.

Basics

ClassWhat it isTested
INTEGERExpanded 64-bit signed integer.—
REALExpanded 64-bit floating-point number.—
BOOLEANExpanded truth value.—
CHARACTERExpanded 8-bit character.—
STRINGExpanded text class.—
MATHMathematical functions and constants.✓
BASE64Base64 encoder and decoder.✓
EXCEPTIONAncestor of all exception types.—
DEVELOPER_EXCEPTIONUser and developer raised exceptions.—
PROCEDURE, FUNCTIONAgents: a procedure, or a function returning a value.—

Collections

ClassWhat it isTested
ARRAY, ARRAYED_LIST, LIST, SORTED_LIST, HASH_MAP, HASH_TABLE, SET, STACK, QUEUEGeneric containers. ARRAYED_LIST and HASH_TABLE are used in the conformance suite’s generics case.—

Concurrency

ClassWhat it isTested
CHANNELSynchronized FIFO message channel for tasks to talk to each other.—
MUTEXLow-level mutual exclusion lock.—
WORKER_POOLMulti-threaded worker pool for parallel tasks.—

Data

ClassWhat it isTested
DATA_FRAME, SERIESIn-memory two-dimensional tabular data engine.—

JSON

ClassWhat it isTested
JSON_VALUEA JSON value: null, boolean, number, string, array or object (RFC 8259).✓
JSON_PARSER, JSON_PARSE_RESULTParser producing a JSON_VALUE tree, and the outcome of a parse.✓
JSONOlder formatting and extraction helper, kept for compatibility.✓

Files and system

ClassWhat it isTested
FILE, DIRECTORY, PATHOn-disk files, directories and paths.—
ENVIRONMENTEnvironment variables, system paths and command-line arguments.✓
PROCESSRun system processes and control exit.—
TIMETime, clock and delay utilities.✓

Networking

ClassWhat it isTested
HTTP_CLIENTHTTP and HTTPS client with redirects, timeouts, and dual-stack IPv4 and IPv6.✓
HTTP_OPTIONS, HTTP_RESPONSERequest options, and the captured status, headers and body.✓
HTTP_SERVERNative HTTP server for web applications and status APIs.✓
TCP_SOCKET, TLS_SOCKETTCP sockets, and TLS over them using OpenSSL.—
TLS_PROBE, TLS_CERT_INFOInspect a peer’s TLS certificate and its expiry.✓
WEB_APP, WEB_ROUTER, WEB_REQUEST, WEB_RESPONSE, WEB_SESSIONA small web framework: routes with parameters (/users/:id), middleware, cookies and sessions.—

Databases

ClassWhat it isTested
ASANAGI_DB, ASANAGI_DB_TCP, ASANAGI_DB_WSAsanagiDB clients: document-style CRUD and Gremlin traversals, over JSON-line TCP or the binary ASNA protocol.✓
VERTEX_INFO, EDGE_INFODecoded vertex and edge data from AsanagiDB.✓
SQLITE_DB, SQLITE_QUERYNative SQLite client and a fluent query builder.—
PG_ROWPostgreSQL client and query result driver.—
REDIS_CLIENTRedis key-value and publish/subscribe client.—

Security

ClassWhat it isTested
AES_CIPHERAES-256-GCM encryption and decryption.—
CRYPTO_HASHSHA-256, SHA-512, MD5 and HMAC-SHA256.—

Graph layout

ClassWhat it isTested
GRAPH_NODE, GRAPH_EDGENodes and edges of a 2D graph layout.—
RADIAL_LAYOUTSelected vertex in the centre, direct neighbours on a circle.✓
GRAPH_HIT_TESTHit-testing for node selection on a canvas.✓
NAV_HISTORYBack and Forward over selected vertices.✓
RESULT_CAPPERResult capping and pagination, with contract checks.✓

Native UI (libui-ng)

ClassWhat it isTested
WINDOW, BOX, GRID, TAB, LABEL, BUTTON, ENTRY, MULTILINE_ENTRY, COMBOBOX, LIST_WIDGET, CANVAS, CANVAS_PAINTER, MENUNative windows and controls. The base class CONTROL carries contracts against use-after-destroy and against giving a control two parents.✓

Terminal UI

ClassWhat it isTested
TUI_APP, TUI_WIDGETTerminal application engine with ANSI rendering, and a base widget.—

Two small examples

BASE64
class APPLICATION
create
    make
feature
    make is
        local
            b64: BASE64
            original: STRING
            encoded: STRING
            decoded: STRING
        do
            create b64
            original := "Hello Meikaku"
            encoded := b64.encode(original)
            decoded := b64.decode(encoded)

            std_print("Encoded base64: ".concat(encoded).concat("\n"))
            std_print("Decoded base64: ".concat(decoded).concat("\n"))
            std_print("Roundtrip match: ".concat((original = decoded).to_string).concat("\n"))
        end
end
Output
Encoded base64: SGVsbG8gTWVpa2FrdQ==
Decoded base64: Hello Meikaku
Roundtrip match: true
JSON: build, serialize, parse and read back
-- excerpt: the body of make, with its local declarations omitted
create json_obj.make_object
json_obj.put_string("service", "watchtower")
json_obj.put_integer("port", 9090)
json_obj.put_boolean("enabled", true)
json_obj.put_null("optional")

create arr.make_array
arr.add_string("alpha")
arr.add_string("beta")
arr.add_integer(42)
json_obj.put("tags", arr)

ser := json_obj.to_json
std_print("Serialized: " + ser + "\n")

create parser.make
res := parser.parse(ser)
std_print("Parse valid: " + res.is_valid.to_string + "\n")
if res.is_valid and then attached res.value as v then
    std_print("Service: " + v.get_string("service", "") + "\n")
    std_print("Port: " + v.get_integer("port", 0).to_string + "\n")
end
Output
Serialized: {"service":"watchtower","port":9090,"enabled":true,"optional":null,"tags":["alpha","beta",42]}
Parse valid: true
Service: watchtower
Port: 9090

Precompiled libraries

New in 1.1.0. A set of classes can be compiled once into a library bundle and used by other programs without its source. Contracts travel with it, and a program can inherit from, and redefine routines of, a library class.

# Build the SHAPE library once...
mkc --build-lib shapes/ -o shapes.meilib

# ...then compile a program against it.
mkc app.mei -r --lib shapes=shapes.meilib

In this example the library holds the SHAPE class shown above. A consumer redefinesarea and reaches the library's own version with SHAPE.area. Library code that callsarea picks up the redefinition: describe_twice is the library's, and it returns twice the new value.

A program using the library
class APP is
    feature
        run is
            local
                s: PLUS_SHAPE
            do
                create s.make
                std_print(s.area.to_string)
                std_print(s.describe_twice.to_string)
            end
end

class PLUS_SHAPE
create
    make
inherit
    SHAPE
        redefine area end
 is
    feature
        area: INTEGER is
            do
                Result := SHAPE.area + 1
            end
end
area, then describe_twice (11 and 22)
1122

The rules that apply across the library boundary are the same ones that apply inside one program: attributes are read-only, private features stay private, and a frozen class in a library cannot be inherited from.

Tooling

  • mkc-lsp is a language server, shipped with the compiler.
  • Editor support for Sublime Text, VS Code and Zed is kept in the compiler's repository.
  • The compiler has a doc command that generates reference pages for classes.

Differences from Eiffel

Meikaku is deliberately a subset of Eiffel in spirit: a Meikaku class should look familiar to an Eiffel programmer, but a valid Eiffel class is not always a valid Meikaku class. If you are learning fromEiffel: The Language or the Eiffel documentation, this table lists where Meikaku does something different. Each row was checked against the 1.2.0 compiler. Anything not listed here has not been checked, so treat the Eiffel book as a guide and let the compiler have the final say.

TopicIn EiffelIn Meikaku
Boolean literalsTrue, Falsetrue, false in lower case. True is rejected.
and, orEvaluate both sides. and then and or else stop early.All four stop early. a and b means the same as a and then b, so the right side is skipped when the left side decides the answer.
Division/ is real division, // is integer division, \\ is the remainder./ divides: two integers give an integer result, and reals give a real result. // and \\ are not operators; // is reported as a comment error.
String equalitySTRING is a reference type, so s1 = s2 compares identity. Use ~ for content.STRING is an expanded class (a plain value), so s1 = s2 compares content. ~ also works.
Renamingrename in an inherit clause.No rename. redefine and select are supported, and feature names stay the same through the hierarchy.
Calling the parent versionPrecursorNo Precursor and no super. Call the parent's version by the parent's name, as in SHAPE.area.
Zero-argument callsNo parentheses.No parentheses, and the compiler enforces it. This is a change from versions before 1.2. Inside native … end blocks the text is raw Zig, so Zig's parentheses are required there.
Rejected C-style formsNot part of the language.!= (use /=), == (use =), // comments (use --), inherits (use inherit), and a colon after section headers such as create and feature all produce a clear error.
Projects and librariesAn ECF configuration file with clusters and libraries.A meikaku.json manifest with uses and packages. See Packages and uses.
Foreign codeExternal routines in C and C++.Raw Zig in native … end blocks, and C or Zig through native packages. See Zig and C interop.

The parts that match Eiffel: := for assignment, = and /= for equality,~ and /~ for object equality, Result as the function result, contracts (require, ensure, invariant), create procedures, deferred and expanded classes, and generics.

Known limits

  • Release packages target macOS on Apple silicon and Linux on x86_64 and ARM64 (aarch64). There is no Intel Mac or Windows package yet.
  • Building programs with a native window on Linux needs GTK 3 and pkg-config.
  • Syntax changed in version 1.0 to match Eiffel. Code written for older versions needs updating. Version 1.2 also removed the libraries and drivers keys: see Packages and uses for the migration.
  • A class that inherits from a deferred class cannot be passed straight as an argument to a parameter of the deferred type, and ARRAYED_LIST of a deferred class does not compile. Assign to a variable of the deferred type first, or use a concrete wrapper class.
  • Some standard library classes have no conformance case yet; they are marked in the tables above.

Questions, or something you would like to build? Write to[email protected].