GithubHelp home page GithubHelp logo

kray-g / kinx Goto Github PK

View Code? Open in Web Editor NEW
236.0 6.0 9.0 10.35 MB

Looks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers.

License: MIT License

C 89.17% C++ 3.90% Batchfile 0.04% Yacc 2.21% Makefile 1.03% TeX 0.51% Ruby 0.04% JSON 0.01% CMake 0.49% Shell 1.72% M4 0.08% HTML 0.49% NSIS 0.27% PowerShell 0.01% CSS 0.03%
scripting-language interpreter javascript object-oriented object-oriented-programming c script-language jit-compiler interpreted-programming-language programming-language

kinx's Introduction

Note: Now this Kinx is a little pending the development. A near future this could be freezed, but I am still sitting on the fence. As a successor, Kilite is available but it's under construction so far. You can see the new product of Kilite here, and check it out.

Looks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers.

Topics

  • Official Release 1.1.1 is now available! See Releases.
  • Now the Kinx is supporting the platform of x86-64 Windows and Linux only, because I have no environment.
    • If you are interested in other platforms, please check here.
  • See ChangeLog.md about the history of this project.

Introduction

Ruby is a major scripting language. Also Python is. However, either of these syntax is NOT familiar to C programmers. This Kinx is a script language for people who want C-like syntax.

The Concept

The concept is, "Looks like JavaScript, feels like Ruby, and it is a script language fitting in C programmers."

  • Looks like JavaScript ... It provides C family syntax.
  • Feels like Ruby ... Enjoy programming.
  • Fitting in C programmers ... It is easy to use for many programmers.

"C programmers" in this context means "almost all programmers." Because I think almost all programmers have used or known C language at least. And "Providing C Like Syntax" as well also means "friendly for almost all programmers."

Features

Basic Features

Mainly there are features below.

  • Dynamic typing and Object-Oriented programming.
  • Classes and inheritance, Higher order functions, Lexical scoping, Closures, Fiber, Garbage Collection, and so on.
  • Native function by JIT compiling supported with some limitations. Very fast.
  • Useful libraries are provided as All-In-One.
  • REPL is provided by default.
  • Debugger is available and embedded in Kinx. Use the option --debug and you can run a script with debugger.
  • Useful Testing System named as SpecTest. It is designed to not only for Kinx but also for any other products.
  • Package Manager has been officially supported since the version 1.1.0.

Standard Libraries

The script language is a platform as a glue between libraries. This means a language itself is not a main purpose, it should be just a backend or supporter due to use a library you want to use.

Therefore another design goal for this language is to be extendable, lightweight, and easy to use for user's own purpose. Kinx will be able to be the best platform for any libraries which you want to use or your own library.

Kinx is including useful libraries below in the standard package as All-In-One.

  • Zip ... Zip/Unzip with not only zip password but also AES password.
  • Xml ... Supporting XML as DOM structure.
  • libCurl ... Only HTTP has been already implemented.
  • SSH ... SSH login and you can execute commands.
  • Socket ... Supporting a simple TCP/UDP socket.
  • Iconv ... Converting between text encodings.
  • SQLite3 ... Database class as a usuful library wapping SQLite3.
  • Regular Expression ... Regular expression is of course supported.
  • Parser Combinator ... Exactly original implementation of Parser Combinator named as Parsek like Parsec.
  • PDF ... PDF core library based on HaruPDF.
  • JIT ... JIT library for various platforms by an abstracted assembler library.

Making libraries improvement and extension is one of the main purpose of this language.

Language Details

There is Quick Reference Guide. Please see Quick Reference Guide for your understanding.

For the detail of Kinx specification, see Kinx Specification. This document is also including Test Codes. I named this system as SpecTest. See SpecTest for detail.

And you can try it on the REPL. See REPL for detail.

Motivation

I guess almost all programmers want a lightweight scripting language with C style syntax because it is simple, easy, and familiar to them. C style syntax is the most fitting in the programmer's hand, I guess.

Any other languages are also all good solution, but for me...

  • Ruby is great. But it is too far from C style. Too many typing for end.
  • Python is also great. But it is too far from C style. Indentend style is a little cramped and too many typing for self.
  • JavaScript is very good for me, and it is a C like style. But node.js is too heavy.

What is C Style Syntax?

Sharing the definition of C Style Syntax, it is below.

  • Block is a scope between { and }
  • Mostly freedom style of indent.
  • Fallthrough in switch case. ... switch-when is now supported without fallthrough by default.
    • C programmers will feel it to continue to the next case when there is no break statement.
  • etc.

There are a lot of pros and cons about switch-case. Therefore now the followings are supported instead of switch-case. You can use it as it depends on your situation.

  • If you want to do it without break, you can use switch-when instead for that purpose.
  • You can also use case-when as an expression with a pattern matching syntax.

As C style Syntax family there are C, C++, Java, JavaScript, C#, and so on. If you agree, or if you don't agree, anyway push the star.

Getting Started

Supported Platforms

Currently this project supports x86-64 Windows and Linux only. I really want someone to support any other platforms if possible because I do not have any other platform environment. Please see detail here

How to Build

IMPORTANT
If you faced a crash of the kinx executable, please try make clean all to re-build everything. Sometimes changing a structure in common header will cause a crash because dependencies in Makefile are imcomplete.

Windows

On Windows, tested with Visual Studio 2017 Express Edition with x64. To build, see below.

$ make.cmd

Note that on Windows, compiling ir_exec.c takes long time around 15 minutes, so please wait for it. It is no problem on Linux because it is around 2 or 3 minutes.

Linux

On Linux, tested with gcc 7.4.0 with x64. To build, see below.

$ make

How to Support a Platform

If anyone wants to support some other platform, the followings have to be done.

  1. Now utliity/kmyacc is prepared only for x86-64 Windows and Linux.
    • About this, I did commit directly the generated parser file by yacc. Use those files directly in Makefile.
  2. Kinx needs some dependent libraries. The libraries as a source code are directly managed under src/extlib, and the other libraries which is provided as a binary is managed on this repository. That repository is registered as a submodule under src/extlib.
    • Now there are 6 libraries provided as a binary.
      • libcurl, libharu, libssh2, libxml2, openssl, and zip(minizip).
    • How to add components you want to use.
      • For source code libraries, use Makefile suited to the platform that you want to use, and add it into the build mechanism.
      • For binary libraries, added components which you have built for the platform you want to support to this repository. And then, do pull request on that repository and update submodule's commit on this Kinx repository.

How to Install

Windows or Linux

You can download an installer from Releases page.

by Scoop (for Windows users)

Or you also can install by scoop. Type the below:

scoop bucket add kinx https://github.com/Kray-G/kinx # only needed the first time
scoop install kinx

How to Execute

Usage

# For Windows
$ kinx.exe [options] [<script-file>]

# For Linux
$ ./kinx [options] [<script-file>]

Options

Here is current available options.

Option Description
-h Display help.
-v, --version Display version number.
-d Dump compiled code.
-D Display AST.
-i Input source code from stdin.
-c Check the syntax only without any executions.
-q Do quiet mode without displaying warning & error, and exit code 0 means successful.
--debug Debugger mode and run with a debugger.
--dot Output the dump by .dot format.
--with-native Dump compiled code of a native function. Use with -d.
--native-call-max-depth Specify the max depth to call a native function. 1024 by default.
--case-threshold Specify the max interval between case's integer value. 16 by default.
--exec:repl Run the Repl.
--exec:spectest Run the SpecTest.

Examples

You will think it is like JavaScript.

Fibonacci

function fib(n) {
    if (n < 3) return n;
    return fib(n-2) + fib(n-1);
}

System.println("fib(34) = ", fib(34));

Factorial

function fact(n) {
    if (n < 1) return 1;
    return n * fact(n-1);
}

System.println(fact(5000));

Class

class Example(i) {
    public get() { return i; }
}

System.println(new Example(100).get());

Native

What is Native function?

Remember the fibonacci function above. That is a simple fibonacci function and execute it with time measurement like below.

$ time ./kinx examples/fib.kx
fib(34) = 9227465

real    0m0.718s
user    0m0.609s
sys     0m0.000s

Replace function to native. That's all.

native fib(n) {
    if (n < 3) return n;
    return fib(n-2) + fib(n-1);
}

System.println("fib(34) = ", fib(34));

Let's execute it and measure it!

$ time ./kinx examples/native_fib.kx
fib(34) = 9227465

real    0m0.167s
user    0m0.063s
sys     0m0.016s

How nice it is around 10x faster.

But you have to know the limitations with native function. See Native Functions for details.

REPL

You can use REPL (Read-Eval-Print-Loop) with the option of --exec:repl as below.

$ ./kinx --exec:repl

Here is a demo animation. REPL has an autocomplete by [TAB] key. See REPL for details.

Have fun with it!

Debugger

Debugger is now available. Run with the --debug option.

$ ./kinx --debug script.kx

Here is a sample screen shot. See Kinx Debugger for details.

License

This project is licensed under the MIT License. See the LICENSE file for details. About the licenses of internal used libraries, follow the licenses of each library. See docs/licenses folder for details.

kinx's People

Contributors

actions-user avatar htsign avatar kray-g avatar nishantc1527 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kinx's Issues

Fails a destructuring assignment when declaration with const.

Here is the code.

function test1(data) {
    var [a, b, ...c] = data.split(',');
}
function test2(data) {
    [a, b, ...c] = data.split(',');
}
function test3(data) {
    const [a, b, ...c] = data.split(',');
}

Only test3 is failed with raising an exception. The cause is that the bytecode is different from other 2 functions.
The bytecode is below.

test1: (unknown)(1 - 3)
  .L2997
    35a3:   enter                   21, vars(4), args(1)
    35a4:   pushs                   ","
    35a5:   pushvl0                 $0(0)
    35a6:   calls                   "split", 1
    35a7:   pushlv                  $0(1)
    35a8:   getaryv                 0
    35a9:   pushlv                  $0(2)
    35aa:   getaryv                 1
    35ab:   pushlv                  $0(3)
    35ac:   getarya                 2
    35ad:   pop
    35ae:   ret                     null
    35af:   halt

test2: (unknown)(4 - 6)
  .L2998
    35b0:   enter                   21, vars(4), args(1)
    35b1:   pushs                   ","
    35b2:   pushvl0                 $0(0)
    35b3:   calls                   "split", 1
    35b4:   pushlv                  $0(1)
    35b5:   getaryv                 0
    35b6:   pushlv                  $0(2)
    35b7:   getaryv                 1
    35b8:   pushlv                  $0(3)
    35b9:   getarya                 2
    35ba:   pop
    35bb:   ret                     null
    35bc:   halt

test3: (unknown)(7 - 9)
  .L2999
    35bd:   enter                   21, vars(4), args(1)
    35be:   pushs                   ","
    35bf:   pushvl0                 $0(0)
    35c0:   calls                   "split", 1
    35c1:   dup
    35c2:   applyvi                 0
    35c3:   pushvl0                 $0(1)
    35c4:   eqeq
    35c5:   throwifz                NoMatchingPatternException
    35c6:   dup
    35c7:   applyvi                 1
    35c8:   pushvl0                 $0(2)
    35c9:   eqeq
    35ca:   throwifz                NoMatchingPatternException
    35cb:   pushlv                  $0(3)
    35cc:   getarya                 2
    35cd:   pop
    35ce:   ret                     null
    35cf:   halt

Printing Non-ASCII

Hi,

kinx repl doesn't print non-ascii chars (Turkish), try to execute System.println('çÇşŞiİğĞüÜıI'); with kinx repl.
I created a simple hello.knx file and it still doesn't print Turkish letters.

Thanks

最後にコールバックを受ける関数の糖衣

提案です。
本リポジトリに多くのKinxライブラリが実装されていくにつれ、最後の引数にコールバック関数を取る関数が多く見られます。
これらは「関数を取る場合はそれが最後になる」という点で一貫しているように思えます。

そこで、「関数を最後に取る関数を呼び出すとき、最後に渡す関数はパーレンの外側に出せる」という構文規則を増やせないものでしょうか。

function f(a, b, fn) {
    return fn(a, b);
}

# これを
const result1 = f(1, 2, &(a, b) => a + b);
System.println(result1); # 3

# こう書けるように
const result2 = f(1, 2) &(a, b) => a + b; # syntax error in current kinx
System.println(result2); # 3?

この考えは SwiftKotlin, Nim などからヒントを得ています。
Ruby は外側にしかブロックを置けなかった(はず)なので参考から除外しています。

// Swift
func f<T>(_ a: T, _ b: T, fn: (T, T) -> T) -> T {
    return fn(a, b)
}

let result1 = f(1, 2, fn: { $0 + $1 })
print(result1) // 3

// equivalent of above
let result2 = f(1, 2) { $0 + $1 }
print(result2) // 3
// Kotlin
fun <T> f(a: T, b: T, fn: (T, T) -> T) = fn(a, b)

fun main() {
    val result1 = f(1, 2, { a, b -> a + b })
    println(result1) // 3
    
    // equivalent of above
    val result2 = f(1, 2) { a, b -> a + b }
    println(result2) // 3
}

上手く適用できると、読む側にとって優しいコードになれる可能性があります。
パーサー書く側にとっては辛くなりそうですが…。

Repository size is too big and could be reduced with git-filter-repo

The first impression that one has when trying to clone/build this project i that it's too big in disk size terms for a scrimping language, then after looking around I found this project https://github.com/newren/git-filter-repo to help trim down this repository and did a crude first try by removing the following folders src/extlib, fonts, examples/typesetting and lib/katex with the command bellow with a reduction is size from 233MB to 18MB, but although the repository history seems to be ok the Makefile need to be fixed to build this project again (not done).

git-filter-repo \
    --replace-refs delete-no-add \
    --path-glob 'src/extlib/' \
    --path-glob 'fonts/' \
    --path-glob 'lib/katex/' \
    --path-glob 'examples/typesetting/' \
    --invert-paths --force

And got this result:

kinx-filtered$ du -h
28K	./bench
264K	./include
4,0K	./.git/logs/refs/remotes
4,0K	./.git/logs/refs/heads
12K	./.git/logs/refs
20K	./.git/logs
12K	./.git/info
768K	./.git/filter-repo/analysis
944K	./.git/filter-repo
4,0K	./.git/branches
52K	./.git/hooks
4,0K	./.git/refs/tags
4,0K	./.git/refs/remotes
4,0K	./.git/refs/heads
16K	./.git/refs
108K	./.git/objects/info
4,8M	./.git/objects/pack
4,9M	./.git/objects
6,1M	./.git
16K	./examples/c
44K	./examples/pdf
32K	./examples/esc
512K	./examples
8,0K	./bin
20K	./utility/src
316K	./utility
548K	./template/theme/standard
552K	./template/theme
576K	./template
44K	./docs/Reference/Object
8,0K	./docs/Reference/Exception
60K	./docs/Reference
1,6M	./docs/utility/images
1,7M	./docs/utility
12K	./docs/benchmark
12K	./docs/spec/others
32K	./docs/spec/definition/native
96K	./docs/spec/definition
8,0K	./docs/spec/lib/function
40K	./docs/spec/lib/primitive
116K	./docs/spec/lib/basic
168K	./docs/spec/lib
100K	./docs/spec/statement/expression
180K	./docs/spec/statement
8,0K	./docs/spec/command
16K	./docs/spec/spectest
52K	./docs/spec/algorithm
536K	./docs/spec
100K	./docs/licenses
2,7M	./docs
12K	./.vscode
28K	./src/optimizer
80K	./src/extlib/onig/test
340K	./src/extlib/onig/m4
56K	./src/extlib/onig/sample/.deps
144K	./src/extlib/onig/sample
1,6M	./src/extlib/onig/autom4te.cache
76K	./src/extlib/onig/src
3,5M	./src/extlib/onig
68K	./src/extlib/kc-json/dist
72K	./src/extlib/kc-json
3,6M	./src/extlib
200K	./src/exec/code
204K	./src/exec
32K	./src/disasm/common
32K	./src/disasm/arch/mips
76K	./src/disasm/arch/x86
40K	./src/disasm/arch/arm
152K	./src/disasm/arch
24K	./src/disasm/gen
12K	./src/disasm/spec
292K	./src/disasm
408K	./src/disasm-x64/libudis86
416K	./src/disasm-x64
1,2M	./src/jit
6,7M	./src
24K	./lib/std/net
228K	./lib/std
8,0K	./lib/exec/3rdparty
84K	./lib/exec
316K	./lib
24K	./.github/workflows
28K	./.github
8,0K	./bucket
18M	.

And this is with the original repository:

du -h
28K	./bench
264K	./include
16K	./.git/logs/refs/remotes/origin
20K	./.git/logs/refs/remotes
8,0K	./.git/logs/refs/heads
32K	./.git/logs/refs
40K	./.git/logs
8,0K	./.git/info
768K	./.git/filter-repo/analysis
772K	./.git/filter-repo
4,0K	./.git/branches
52K	./.git/hooks
8,0K	./.git/refs/tags
16K	./.git/refs/remotes/origin
20K	./.git/refs/remotes
8,0K	./.git/refs/heads
40K	./.git/refs
4,0K	./.git/objects/info
146M	./.git/objects/pack
146M	./.git/objects
147M	./.git
16K	./examples/c
44K	./examples/pdf
32K	./examples/esc
512K	./examples
8,0K	./bin
20K	./utility/src
316K	./utility
548K	./template/theme/standard
552K	./template/theme
576K	./template
44K	./docs/Reference/Object
8,0K	./docs/Reference/Exception
60K	./docs/Reference
1,6M	./docs/utility/images
1,7M	./docs/utility
12K	./docs/benchmark
12K	./docs/spec/others
32K	./docs/spec/definition/native
96K	./docs/spec/definition
8,0K	./docs/spec/lib/function
40K	./docs/spec/lib/primitive
116K	./docs/spec/lib/basic
168K	./docs/spec/lib
100K	./docs/spec/statement/expression
180K	./docs/spec/statement
8,0K	./docs/spec/command
16K	./docs/spec/spectest
52K	./docs/spec/algorithm
536K	./docs/spec
100K	./docs/licenses
2,7M	./docs
12K	./.vscode
28K	./src/optimizer
100K	./src/extlib/libssh2/include
2,0M	./src/extlib/libssh2/x64/gcc
344K	./src/extlib/libssh2/x64/vs2017
2,3M	./src/extlib/libssh2/x64
2,4M	./src/extlib/libssh2
32K	./src/extlib/ansicolor
528K	./src/extlib/libxml2/include/libxml2/libxml
532K	./src/extlib/libxml2/include/libxml2
536K	./src/extlib/libxml2/include
9,9M	./src/extlib/libxml2/x64/gcc
12M	./src/extlib/libxml2/x64/vs2017
22M	./src/extlib/libxml2/x64
22M	./src/extlib/libxml2
1,8M	./src/extlib/openssl/include/openssl
1,8M	./src/extlib/openssl/include
14M	./src/extlib/openssl/x64/gcc
7,2M	./src/extlib/openssl/x64/vs2017
21M	./src/extlib/openssl/x64
23M	./src/extlib/openssl
32K	./src/extlib/onig/windows
8,0K	./src/extlib/onig/cmake
252K	./src/extlib/onig/test
340K	./src/extlib/onig/m4
56K	./src/extlib/onig/sample/.deps
220K	./src/extlib/onig/sample
1,6M	./src/extlib/onig/autom4te.cache
2,4M	./src/extlib/onig/src
224K	./src/extlib/onig/doc
48K	./src/extlib/onig/harnesses
6,7M	./src/extlib/onig
264K	./src/extlib/libharu/include
2,7M	./src/extlib/libharu/x64/gcc
2,7M	./src/extlib/libharu/x64/vs2017
5,3M	./src/extlib/libharu/x64
5,6M	./src/extlib/libharu
8,9M	./src/extlib/sqlite
224K	./src/extlib/libcurl/include/curl
228K	./src/extlib/libcurl/include
1,6M	./src/extlib/libcurl/x64/gcc
1,8M	./src/extlib/libcurl/x64/vs2017
3,3M	./src/extlib/libcurl/x64
3,6M	./src/extlib/libcurl
68K	./src/extlib/kc-json/dist
36K	./src/extlib/kc-json/util
16K	./src/extlib/kc-json/sample
56K	./src/extlib/kc-json/src
248K	./src/extlib/kc-json
120K	./src/extlib/zip/include
884K	./src/extlib/zip/x64/gcc
748K	./src/extlib/zip/x64/vs2017
1,6M	./src/extlib/zip/x64
1,8M	./src/extlib/zip
68K	./src/extlib/winiconv
3,7M	./src/extlib/duktape
78M	./src/extlib
200K	./src/exec/code
204K	./src/exec
32K	./src/disasm/common
32K	./src/disasm/arch/mips
76K	./src/disasm/arch/x86
40K	./src/disasm/arch/arm
152K	./src/disasm/arch
24K	./src/disasm/gen
12K	./src/disasm/spec
292K	./src/disasm
408K	./src/disasm-x64/libudis86
416K	./src/disasm-x64
1,2M	./src/jit
81M	./src
24K	./lib/std/net
228K	./lib/std
8,0K	./lib/exec/3rdparty
84K	./lib/exec
316K	./lib
24K	./.github/workflows
28K	./.github
8,0K	./bucket
233M	.

Incorrect message is displayed when `File.open` failed.

For example, when you specify the file which doesn't exist.

File.open("no-file", File.READ) {};

The exception which is different from what we have expected occurs.

Uncaught exception: No one catch the exception.
SystemException: Method missing
Stack Trace Information:
        at <main-block>((unknown):1)

What we expect is like this.

Uncaught exception: No one catch the exception.
FileException: File open failed: No such file or directory
Stack Trace Information:
        at <main-block>((unknown):1)

Here Document

about "Here Document" in readme.md.

I think it is a literal of a string, not a here document.

Almost 'Here Document' is separated of the code line, like as follows.

var a = %{HEREDOC}.trim();
This is here documen.
New line is available in this area.
HEREDOC

And I don't think 'Here Document' is necessary...

`print`, `println` の出力をオーバーライドする方法

試しにこのようなコードを書いていました。
よくある Option(Maybe) の簡易実装です。

class Option { }

class Some(value) : Option {
    var NotFuncErr = RuntimeException("'fn' must be function type.");

    public map(fn) {
        throw NotFuncErr if (!fn.isFunction);

        var next = fn(value);
        return next.isUndefined ? Option.none : Option.some(next);
    }
    public filter(fn) {
        throw NotFuncErr if (!fn.isFunction);

        return fn(value).isUndefined ? Option.none : this;
    }
    public flatMap(fn) {
        throw NotFuncErr if (!fn.isFunction);

        var next = fn(value);
        throw 'type mismatch' if (!next.instanceOf(Option));

        return next;
    }
    public toString() {
        return 'Some(%{value})';
    }
    public count() {
        return 1;
    }
    public isSome() {
        return true;
    }
    public isNone() {
        return false;
    }
}
class None : Option {
    public map(_) {
        return this;
    }
    public filter(_) {
        return this;
    }
    public flatMap(_) {
        return this;
    }
    public toString() {
        return 'None';
    }
    public count() {
        return 0;
    }
    public isSome() {
        return false;
    }
    public isNone() {
        return true;
    }
}

Option.of = &(value) => value.isUndefined ? new None() : new Some(value);
Option.some = &(value) => new Some(value);
Option.none = new None();

その上で、

var opt = Option.of(3);

System.println(opt);
System.println(opt.toString());

としたとき、出力は

[...]
Some(3)

でした。

ここで、オブジェクトの文字列化について内部実装を拝見したところ、 kx_format という関数を呼んでいるところまでは分かったのですが、勉強不足ゆえそれ以後の処理を追いきれませんでした。
objval->type != KX_OBJ_T を満たしたら [...] になりそう、というのはなんとなく分かりました。

というのを踏まえた上で、クラスなどの独自オブジェクトについて文字列化を行うときの規則を制御する方法はあるのでしょうか。

Support to change directory.

The Feature

We would like to use it like this.

Directory.change("dirname") {
    // do something under the directory of "dirname".
};

FYI, This can be also written below as JavaScript-like in Kinx.
The meaning is exactly same.

Directory.change("dirname", function() {
    // do something under the directory of "dirname".
});

Additional Comment

This is a very basic functionality.
So I will port it back also to v1.0.x.

Could be a good idea to mention that this is only for x86_64 ?

When I tried to compile this project on an ARM64 I noticed that it depends on executing the binary in utility/kmyacc that is only x86_64 for linux and windows.

So no other operating systems like OSX, ANDROID, FREEBSD, AIX, ...

If this is a limitation of this project I think that is a good idea to specify it clearly on the README.

Shrink this repository size.

Is your feature request related to a problem? Please describe.
This repository is too big. I want to shrink it.

Describe the solution you'd like
Move files under src/extlib/ to another repository.

Describe alternatives you've considered
No idea.

Additional context
The purpose is to shrink this repository, so I think this should be done for all branches.
And this request is related to #180.

Is there a way to define struct or record?

I am looking for some language like this, thank you for making it opensource! It looks awesome!

As so far I have read, it seems the documentation has not mentioned how to define structure, anyway to do it?

Also is there a way to interact with C libraries or headers? And, does it have a pointer type?

Package Manager

Package Manager is important for ecosystem of development.

  • Version control.
  • Package management such as installation, uninstallation.

The following items are postponed to V1.2.0.
See #338 for details.

  • Dependency control
  • Update to the latest version based on a dependency.

The remaining tasks to release V1.1.0 are as follows.

  • Support all functionalities.
    • Installation.
    • Uninstallation.
    • Listing packages & versions.
  • Misc
    • Update README.md
    • Update ChangeLog.md and ChangeLog_v1.1.x.md

Stack overflow by the operator of `=~` or `!~`.

When using the operator of =~ or !~, the stack is not used cleanly.
It causes a stack overflow after a lot of operations by those operator like in a loop.

This should be also applied to v1.0.2 as a back port.

Things we can do with kinx?

I found this project in the explore section and found it to be way too interesting. So the question here is, what can i do with kinx as it is not mentioned in the documentation?

Support REPL.

REPL support.

Here is the list of items to realize it.

  • For the functionality of the language.
    • Calculates expressions.
    • Defines a function.
    • Defines a native function.
    • Defines a class.
    • Defines a module.
    • Executes some statements and blocks.
    • Loads the code from outer files.
  • For the editor.
    • Up/Down arrow keys to access the history.
    • Left/Right arrow keys to move cursor in the line.
    • Ctrl-Left/Right arrow keys to move cursor by word.
    • Tab key to support the input.
    • Executes the line selected by the history number like !10.
    • Supports some commands as below.
      • .quit to quit the editor.
      • .vars to show the current held variables and its values.
      • .history to show the history.
      • .showdef name to show the defined function/class/module body.
      • .help to display a small help.
      • .fullcode to input a full code like -i option.
      • .time to measure the elapsed time.
      • .run to run the code in .fullcode mode.

native function での除算

#16 で返信をする際に改めて native function を触っておりましたが、どうも native function 内で浮動小数の除算が行われると結果が不定になるようです。

以下、全て同じ実行環境で確認しています。

OS CPU Kinx
Windows 10 (2004) x64 AMD Rizen 1600 v0.8.1
function half(n) {
  return n / 2;
}
native<int> nativeIntHalf(n: int) {
  return n / 2;
}
native<dbl> nativeDblHalf(n: dbl) {
  return n / 2;
}

System.println(half(4.5));          // 2.25
System.println(nativeIntHalf(4));   // 2
System.println(nativeDblHalf(4.5)); // 9.88131e-324  (?)

行を切り貼りして function call の順番を変えると 0 を出力したりします。
剰余算でも確認しました。加算・減算・乗算では特に問題が見受けられませんでした。


なお、別件となりますが native function 内で小数のリテラルを書くとエラーになります。
書くだけでエラーになります。呼び出す必要はありません。

native f() {
  return 1.0;  // Assertion failed at d:\a\kinx\kinx\src\jit/sljitLir.c:1411
}

これも別件になりますが通常関数に型宣言を書いてもエラーになりません。
(これは別に実害がないのでどうでもいいかもしれません)

// approved!
function addOne(n: int) {
  const ONE: int = 1;
  return n + ONE;
}
System.println(addOne(42)); // 43

test has failed

2b559da のテストから失敗しています

実はこのエラー、fork した方の私のリポジトリでも(Kray-G/kinx/masterhtsign/kinx/master に差異がないにも関わらず)再現したことがありました。
その際には _functionfunction に変えてスタックトレースを追ってみるとかいろいろやったのですが、知識不足もあり結局原因が分からず、リポジトリを一旦削除して作り直しています。

re-run jobs すると結果が変わることがあり(ジョブをキックする本来ユーザーから見えない .sh がコケていたりした) GitHub 側の問題も疑ってみましたが、今改めて私の方で git pull --rebase upstream master && git push してみたところ、いきなり同じエラーでコケていたので、もしかしたら本当に kxstartup.kx に問題があるのかもしれません。
もしくは私の yaml の書き方が悪く、ジョブ毎のタイミングが悪かったりしているのかも…。

SAT solver's SpecTest.

There is no document about SAT solver as a new introduced feature.
SpecTest is needed.

Pin operator doesn't work correctly in declation & function arguments.

Here is the code.

var a = 10;
var { x: ^a, y } = { x: 100, y: 100 };
System.println(y);

Here is a version of function arguments.

var a = 10;
function test({ x: ^a, y }) {
    return y;
}
System.println(test({ x: 10, y: 100 }));
System.println(test({ x: 100, y: 100 }));

It is okay when it's an assignment statement.

Object item is removed by `flatten()`.

Here is the problem.

var a = [{a:1},{b:1}];
System.println(a);
System.println(a.flatten());

The result is as follows.

[{"a":1}, {"b":1}]
{}

Expectation is below.

[{"a":1}, {"b":1}]
[{"a":1}, {"b":1}]

Segfault by getenv.

The following code causes a problem of a segmentation fault on Linux.

var t = $env.NO_ENVVAR;

There is no problem on Windows.

Static Linking

Hi,

Is it possible to link kinx as a static library and executable?

Thanks

doc comment について

Kinx でプログラムを組むにあたり、ドキュメントコメントはどういった方針がよいのでしょう?
特に型については是非ともコメントに書いておきたい、という気持ちがあります。
(まずそもそもドキュメントコメントを言語仕様に含めるのかどうかという疑問もあります)

/**
 * ブロックコメントを使うスタイル (JS, Java など)
 * @param {Array<Integer>} xs - values
 * @returns {Integer} sum
 */
function sum(xs) {
    return xs.reduce(&(acc, x) => acc + x, 0);
}
%{
docstring (Python など)

Parameters
----------
xs : Array<Integer>
    values

Returns
-------
sumValue : Integer
    sum
}
function sum(xs) {
    return xs.reduce(&(acc, x) => acc + x, 0);
}
# コードに埋めこむスタイル
/* Integer */ function sum(/* Array<Integer> */ xs) {
    return xs.reduce(&(acc, x) => acc + x, 0);
}

またはその他。


便宜上配列の型を Array<T> で表記しましたが、これも Array[A] (Scala, Nim など) とか [T] (Swift, Haskell など) とか 'a array (OCaml など) とか T[] (TypeScript での別表記) とかいろいろあります。

There is a case that the bytecode does not be outputted.

Problem

In the following conditions, the bytecode does not be outputted unfortunately.

  • It is const declaration
  • It has an initializer which is not constant.
  • By a constant folding after analyzing AST, it has been fold to constant such as integer.

Then, the code generator will remove the code because it is a constant and it assumed to be propagated.

Cause

A constant folding is done first before analyzing AST.
After that, analyzing AST will propagate a constant to variables referencing it.
The problem is that a constant folding is done again after analyzing AST.

If the const variable becomes a constant value in the 2nd constant folding phase, the code generator will omit to generate a code even though it has not been propagated.

Code To Reproduce

In the following code, N can be removed because a variable which references it will use directly 3 as a constant. On the other hand, R will be removed but it is a problem because the number 9 has not been correctly propagated yet.

const X = 10;
const Y = X + X;
System.println(Y);

It displays nothing.

Workaround

  1. Replace const by var, or
  2. Write const Y = 20; directly, or
  3. Write it like var YY = X + X; const Y = YY;, if you want Y to be const and to calculate Y by X.

Problems reported by valgrind

Adding -g to CFLAGS, building kinx and running it under valgrind we get this output:

valgrind --track-origins=yes ../kinx fib.kx 
==2199== Memcheck, a memory error detector
==2199== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==2199== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==2199== Command: /home/mingo/dev/c/A_programming-languages/kinx/kinx fib.kx
==2199== 
==2199== Conditional jump or move depends on uninitialised value(s)
==2199==    at 0x4C3571F: __strncpy_sse2_unaligned (vg_replace_strmem.c:553)
==2199==    by 0x108FBA: strncpy (string_fortified.h:106)
==2199==    by 0x108FBA: get_kinx_path (fileutil.c:297)
==2199==    by 0x108CBB: load_kinx_dll (libkinx.h:134)
==2199==    by 0x108CBB: kinx_call_main (libkinx.h:185)
==2199==    by 0x108CBB: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x108F3A: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Conditional jump or move depends on uninitialised value(s)
==2199==    at 0x4C3571F: __strncpy_sse2_unaligned (vg_replace_strmem.c:553)
==2199==    by 0x593E5BA: strncpy (string_fortified.h:106)
==2199==    by 0x593E5BA: get_kinx_path (fileutil.c:297)
==2199==    by 0x593E978: kxlib_file_exists_no_current (loadlib.c:112)
==2199==    by 0x593DEBF: load_using_module (lexer.c:100)
==2199==    by 0x593BB5A: process_using (lexer.c:145)
==2199==    by 0x593BB5A: get_keyword_token (lexer.c:250)
==2199==    by 0x593BB5A: kx_yylex (lexer.c:987)
==2199==    by 0x5941243: kx_yyparse (kmyacc.c.parser:330)
==2199==    by 0x58F0190: eval (ir_util.c:401)
==2199==    by 0x58F4BFF: eval_file (ir_util.c:482)
==2199==    by 0x594024E: do_main (mainlib.c:306)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x593E53A: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Conditional jump or move depends on uninitialised value(s)
==2199==    at 0x4C3571F: __strncpy_sse2_unaligned (vg_replace_strmem.c:553)
==2199==    by 0x834E73A: strncpy (string_fortified.h:106)
==2199==    by 0x834E73A: get_actual_exe_path (fileutil.c:314)
==2199==    by 0x833D765: System_exepath (kxsystem.c:1626)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E6C1: get_actual_exe_path (fileutil.c:307)
==2199== 
==2199== Conditional jump or move depends on uninitialised value(s)
==2199==    at 0x4C3571F: __strncpy_sse2_unaligned (vg_replace_strmem.c:553)
==2199==    by 0x834E42A: strncpy (string_fortified.h:106)
==2199==    by 0x834E42A: get_kinx_path (fileutil.c:297)
==2199==    by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Conditional jump or move depends on uninitialised value(s)
==2199==    at 0x4C3571F: __strncpy_sse2_unaligned (vg_replace_strmem.c:553)
==2199==    by 0x834E442: strncpy (string_fortified.h:106)
==2199==    by 0x834E442: setup_actual_exe_path (fileutil.c:51)
==2199==    by 0x834E442: get_kinx_path (fileutil.c:298)
==2199==    by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Conditional jump or move depends on uninitialised value(s)
==2199==    at 0x4C34C38: rindex (vg_replace_strmem.c:200)
==2199==    by 0x834E453: setup_actual_exe_path (fileutil.c:59)
==2199==    by 0x834E453: get_kinx_path (fileutil.c:298)
==2199==    by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Conditional jump or move depends on uninitialised value(s)
==2199==    at 0x834E457: setup_actual_exe_path (fileutil.c:60)
==2199==    by 0x834E457: get_kinx_path (fileutil.c:298)
==2199==    by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Use of uninitialised value of size 8
==2199==    at 0x834E459: setup_actual_exe_path (fileutil.c:60)
==2199==    by 0x834E459: get_kinx_path (fileutil.c:298)
==2199==    by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Conditional jump or move depends on uninitialised value(s)
==2199==    at 0x834E47E: setup_actual_exe_path (fileutil.c:61)
==2199==    by 0x834E47E: get_kinx_path (fileutil.c:298)
==2199==    by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Use of uninitialised value of size 8
==2199==    at 0x834E4B5: strcpy (string_fortified.h:90)
==2199==    by 0x834E4B5: setup_actual_exe_path (fileutil.c:62)
==2199==    by 0x834E4B5: get_kinx_path (fileutil.c:298)
==2199==    by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Syscall param stat(file_name) points to uninitialised byte(s)
==2199==    at 0x5151845: _xstat (xstat.c:35)
==2199==    by 0x834E329: stat (stat.h:451)
==2199==    by 0x834E329: file_exists (fileutil.c:277)
==2199==    by 0x834E4C3: setup_actual_exe_path (fileutil.c:63)
==2199==    by 0x834E4C3: get_kinx_path (fileutil.c:298)
==2199==    by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Address 0x85aead3 is 51 bytes inside data symbol "exe_full_path.4920"
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Use of uninitialised value of size 8
==2199==    at 0x834E690: strcpy (string_fortified.h:90)
==2199==    by 0x834E690: setup_actual_exe_path (fileutil.c:64)
==2199==    by 0x834E690: get_kinx_path (fileutil.c:298)
==2199==    by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Syscall param stat(file_name) points to uninitialised byte(s)
==2199==    at 0x5151845: _xstat (xstat.c:35)
==2199==    by 0x834E329: stat (stat.h:451)
==2199==    by 0x834E329: file_exists (fileutil.c:277)
==2199==    by 0x834E4D7: setup_actual_exe_path (fileutil.c:67)
==2199==    by 0x834E4D7: get_kinx_path (fileutil.c:298)
==2199==    by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Address 0x85aead3 is 51 bytes inside data symbol "exe_full_path.4920"
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Conditional jump or move depends on uninitialised value(s)
==2199==    at 0x4C34C38: rindex (vg_replace_strmem.c:200)
==2199==    by 0x834E4EC: get_kinx_path (fileutil.c:299)
==2199==    by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Conditional jump or move depends on uninitialised value(s)
==2199==    at 0x834E4F0: get_kinx_path (fileutil.c:300)
==2199==    by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Use of uninitialised value of size 8
==2199==    at 0x834E4F6: get_kinx_path (fileutil.c:300)
==2199==    by 0x833D685: System_kinxpath (kxsystem.c:1614)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Conditional jump or move depends on uninitialised value(s)
==2199==    at 0x4C35108: strlen (vg_replace_strmem.c:459)
==2199==    by 0x8351214: ks_append (kstr.c:187)
==2199==    by 0x833D690: System_kinxpath (kxsystem.c:1615)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
==2199== Conditional jump or move depends on uninitialised value(s)
==2199==    at 0x4C34FD8: strncat (vg_replace_strmem.c:349)
==2199==    by 0x83511C4: strncat (string_fortified.h:136)
==2199==    by 0x83511C4: ks_append_n (kstr.c:208)
==2199==    by 0x83511C4: ks_append_n (kstr.c:195)
==2199==    by 0x833D690: System_kinxpath (kxsystem.c:1615)
==2199==    by 0x58E7F43: ir_exec_impl (ir_exec.inl:27)
==2199==    by 0x58EF976: ir_exec (ir_exec.inl:284)
==2199==    by 0x594043A: do_main (mainlib.c:379)
==2199==    by 0x108C9D: kinx_call_main (libkinx.h:198)
==2199==    by 0x108C9D: main (main.c:18)
==2199==  Uninitialised value was created by a stack allocation
==2199==    at 0x834E3AA: get_kinx_path (fileutil.c:290)
==2199== 
fib(34) = 9227465
==2199== 
==2199== HEAP SUMMARY:
==2199==     in use at exit: 498,201 bytes in 2,970 blocks
==2199==   total heap usage: 37,100 allocs, 34,130 frees, 37,060,116 bytes allocated
==2199== 
==2199== LEAK SUMMARY:
==2199==    definitely lost: 493,216 bytes in 2,956 blocks
==2199==    indirectly lost: 0 bytes in 0 blocks
==2199==      possibly lost: 0 bytes in 0 blocks
==2199==    still reachable: 4,985 bytes in 14 blocks
==2199==         suppressed: 0 bytes in 0 blocks
==2199== Rerun with --leak-check=full to see details of leaked memory
==2199== 
==2199== For lists of detected and suppressed errors, rerun with: -s
==2199== ERROR SUMMARY: 301 errors from 18 contexts (suppressed: 0 from 0)

Comparing between variables having a string is failed.

Here is an example to be failed.

function gt(a, b)  { return a > b; }
function lt(a, b)  { return a < b; }
function ge(a, b)  { return a >= b; }
function le(a, b)  { return a <= b; }
function lge(a, b) { return a <=> b; } // will be successful.
try { gt("a", "b");  } catch (e) { System.println(e.what()); }
try { lt("a", "b");  } catch (e) { System.println(e.what()); }
try { ge("a", "b");  } catch (e) { System.println(e.what()); }
try { le("a", "b");  } catch (e) { System.println(e.what()); }
try { lge("a", "b"); } catch (e) { System.println(e.what()); } // nothing's displayed.

It is okay when comparing two strings directly.

System.println("a" > "b");

Support `$pwd` for a current directory path.

The Feature

We would like to use a current directory path easily.

System.println($pwd);

Workaround

In the version 1.0.0, you can use System.cwd() for this.

System.println(System.cwd());

Additional Comment

This is a very basic functionality.
So I will port it back also to v1.0.x.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.