1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Io言語をインストールしてHello Worldする

Last updated at Posted at 2019-11-05

はじめに

ビルドとインストールの方法も載せます。

単純にHello Worldしたら1行で終わってつまらないので、Hello World用のメソッドを持たせたオブジェクトのインスタンスを作って実行します。

インストール方法

ダウンロードする

--recursiveオプションを忘れずに。

$ git clone --recursive https://github.com/IoLanguage/io.git

ビルドする

$ cd io
$ mkdir build
$ cd build
$ cmake ..
$ make

インストールする

$ sudo make install

以下のコマンドが動けば成功です。

$ io --version
Io Programming Language, v. 20170906

Hello Worldする

  1. ioと入力してインタプリタを起動します。

$ io
Io 20170906
Io>


2. 空のオブジェクト、FirstObjectを作る

    ```io
Io> FirstObject := Object clone
==>  FirstObject_0x55eaf4b78e30:
  type             = "FirstObject"
  1. FirstObjectにHello World用のメソッド、firstMethodを持たせる

Io> FirstObject firstMethod := method("Hello, world!" println)
==> method(
"Hello, world!" println
)


4. FirstObjectのインスタンス、firstInstanceを作る

    ```io
Io> firstInstance := FirstObject clone
==>  FirstObject_0x55eaf4eb3d30:
  1. firstInstanceのfirstMethodを呼び出す

Io> firstInstance firstMethod
Hello, world!
==> Hello, world!


Hello Worldできました:hugging:!

# おまけ

名前を受け取って挨拶してくれるメソッド、secondMethodを作ってみます。

1. firstInstanceにsecondMethodを持たせる

    ```io
Io> firstInstance secondMethod := method(name, writeln("Hello, ", name))
==> method(name, 
    writeln("Hello, ", name)
)
firstMethodのときは元となるオブジェクトに持たせてインスタンスを生成しましたが、今回はインスタンスに直接持たせています。
  1. secondMethodを呼び出す

Io> firstInstance secondMethod("matoruru")
Hello, matoruru
==> nil


挨拶された:hugging:!

# まとめ

QiitaにIo言語の構文ハイライトがあることに驚きました...(PureScriptのも用意してください:smiling_imp:!)。

# 参考

- https://github.com/IoLanguage/io
- https://iolanguage.org/tutorial.html
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?