PreviousUpNext

1.4  Flexible.

Because Mythryl compiles optimized native code, and because it has an extraordinarily expressive syntax, facilities which must be hardwired in other languages can be — and are — simple library functions in Mythryl.

This means that when you need them to do something different for a given project, you can easily write a replacement, and when you need something entirely new under the sun, you can easily implement that also.

Example: In languages ranging from APL to Perl, the operator generating a list or vector of sequential integers is hardwired into the compiler parser and code generator. The Mythryl version is the double-dot operator:

    linux$ my

    eval: 0..9
    [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]

And here is its implementation:

    # Given 1 .. 10,
    # return   [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
    #
    fun i .. j
        =
        make_arithmetic_sequence (i, j, [])
        where
            fun make_arithmetic_sequence (i, j, result_so_far)
                =
                i > j   ??   result_so_far
                        ::   make_arithmetic_sequence (i,   j - 1,   j ! result_so_far);
        end;

Example: Mythryl supports programmer-defined infix, prefix, postfix and circumfix operators. This allows more natural notation for a variety of programming constructs. For example absolute value may be written |x|. Here is a definition of factorial taken directly from the Mythryl standard library:

    fun 0! =>  1;
        n! =>  n * (n - 1)! ;
    end;

Comments and suggestions to: bugs@mythryl.org

PreviousUpNext