Objeck 2.0.3
Version of implementation Objeck of programming language ObjeckA version of Objeck compiler, released on August 23rd, 2011. Changes:
- Fixed a major bug that caused some programs to crash when compiled with method inlining. Method inlining became a default setting with version 2.0.x. Method inlining has been disabled a bug will be fixed in a forthcoming release.
- Opening a file in write or read/write mode will delete an existing file with the same name. All files are now opened in binary mode.
- Fixed the “Post” method in the HttpClient class
- Improved the String hashing algorithm.
Links:
Examples:
Hello, World! - Objeck (353):
bundle Default {
class Hello {
function : Main(args : String[]) ~ Nil {
"Hello, World!"->PrintLine();
}
}
}
Factorial - Objeck (354):
This example uses built-in Factorial()
function.
bundle Default {
class Factorial {
function : Main(args : String[]) ~ Nil {
for (i := 0; i <= 16; i += 1;) {
i->Print();
"! = "->Print();
i->Factorial()->PrintLine();
};
}
}
}
Fibonacci numbers - Objeck (355):
This example uses recursive definition of Fibonacci numbers.
bundle Default {
class Fib {
function : Fibonacci (n: Int) ~ Int {
if (n<=2) {
return 1;
};
return Fibonacci(n-1) + Fibonacci(n-2);
}
function : Main(args : String[]) ~ Nil {
for (i := 0; i <= 16; i += 1;) {
Fibonacci(i)->Print();
", "->Print();
};
"..."->PrintLine();
}
}
}
Quadratic equation - Objeck (356):
use IO;
bundle Default {
class Quadratic {
function : Main(args : String[]) ~ Nil {
A := Console->ReadString()->ToInt();
if (A=0) {
"Not a quadratic equation."->PrintLine();
return;
};
B := Console->ReadString()->ToInt();
C := Console->ReadString()->ToInt();
D := 1.0*(B*B-4*A*C);
if (D=0) {
"x = "->Print();
(0-B/2.0/A)->PrintLine();
};
if (D>0) {
"x1 = "->Print();
((0-B+(D->SquareRoot()))/2.0/A)->PrintLine();
"x2 = "->Print();
((0-B-(D->SquareRoot()))/2.0/A)->PrintLine();
};
if (D<0) {
out := "x1 = (";
out->Append(0-B/2.0/A);
out->Append(",");
out->Append(((D->Abs())->SquareRoot())/2/A);
out->Append(")");
out->PrintLine();
out := "x2 = (";
out->Append(0-B/2.0/A);
out->Append(",");
out->Append(0-((D->Abs())->SquareRoot())/2/A);
out->Append(")");
out->PrintLine();
};
}
}
}
Comments
]]>blog comments powered by Disqus
]]>