Skip to content

Release 0.6.0

らいパン粉 edited this page Dec 29, 2018 · 9 revisions

Release 0.6.0

構造体の実装

構造体名はアッパーキャメルケース

裏側ではタプルに変換される

構造体宣言

通常の構造体
struct Point{x:Int32 , y:Int32};
//タプル構造体
struct Point(Int32 , Int32);

構造体生成

struct Point{x:Int32 , y:Int32};
//生成
Point 1 2;
//キー名がある場合はこのようにして生成もできる
Point {y=2,x=1};//これはPoint 1 2 に糖衣される。

内部実装

struct Point{x:Int32,y:Int32};

これをコンパイラが見つけると、Pointを生成する関数Pointを生成する。

Point x y = (x,y);//実体はただのタプル

タプルのプロパティアクセスの実装

タプルは.添え字で要素にアクセスできる

main=(4,5).1; // return 5

構造体のプロパティアクセスの実装

struct Point{x:Int32,y:Int32};
main = Point{x=4,y=5}.0 //return 4  
main = Point{x=4,y=5}.1 //return 5  
main = Point{x=4,y=5}.x //これは Point{x=4,y=5}.0に置き換わる

main関数が無いとコンパイルエラーにする

main関数が無いと……。

compile error!

position:
line:1 column:1

message:
not found main function!

となるように

出力されるファイルの名前を指定できるように

cargo run -- -build input.rsc output

でoutput.exe またはoutput.outが出力されるようになる。

Clone this wiki locally