Skip to content

Instantly share code, notes, and snippets.

@kik
Created January 11, 2015 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kik/ebaea54ac208af903094 to your computer and use it in GitHub Desktop.
Save kik/ebaea54ac208af903094 to your computer and use it in GitHub Desktop.
初めてのATS2。見たとおりのCのコードにコンパイルされた
#include "share/atspre_define.hats"
#include "share/atspre_staload.hats"
fn foo1(n : bool, dst : &int) : bool =
if n then (
dst := 42;
true
) else (
dst := 0;
false
)
implement main0 () =
let
var x : int = 0
val y1 = foo1(true, x)
val () = println!("x = ", x, ", y1 = ", y1)
val y2 = foo1(false, x)
val () = println!("x = ", x, ", y2 = ", y2)
in
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment