옥시즌 (프로그래밍 언어)

공통 언어 기반의 프로그래밍 언어

옥시즌(Oxygene, 이전 이름: 크롬)은 렘오브젝트에서 개발한 공통 언어 기반프로그래밍 언어이다. 코드기어델파이닷넷과 비교하면, 옥시즌은 하위 호환성을 지니지 않는다.

옥시즌
개발자RemObjects Software
발표일2005년(19년 전)(2005)[1]
플랫폼공통 언어 기반, 자바, 코코아, CPU 네이티브, 윈도우 32/64비트, 리눅스 32/64비트, 웹어셈블리
라이선스트라이얼웨어
웹사이트elementscompiler.com/elements/oxygene/
영향을 받은 언어
델파이오브젝트 파스칼, C 샤프

특징 편집

  • 공통 언어 기반
  • 오브젝트 파스칼에 기반을 두었지만 많은 새로운 기능이 추가
  • 인라인 변수 선언
  • 익명 자료형, 익명 대리자
  • 비동기 메소드
  • 람다 연산
  • 닷넷 2.0
  • 반복자
  • 불완전 클래스
  • 확장 메소드
  • LINQ 지원
  • 형 추론
  • 인라인 변수 생성자
  • 완전한 비주얼스튜디오 지원

예제 편집

Hello World 편집

namespace HelloWorld;

interface

type
  HelloClass = class
  public
    class method Main;
  end;

implementation

class method HelloClass.Main;
begin
  System.Console.WriteLine('Hello World!');
end;

end.

제네릭 컨테이너(Generic container) 편집

namespace GenericContainer;

interface

type
  TestApp = class
  public
    class method Main;
  end;

  Person = class
  public
    property FirstName: String;
    property LastName: String;
  end;

implementation

uses
  System.Collections.Generic;

class method TestApp.Main;
begin
  var myList := new List<Person>; //type inference
  myList.Add(new Person(FirstName := 'John', LastName := 'Doe'));
  myList.Add(new Person(FirstName := 'Jane', LastName := 'Doe'));
  myList.Add(new Person(FirstName := 'James', LastName := 'Doe'));
  Console.WriteLine(myList[1].FirstName);  //No casting needed
  Console.ReadLine;
end;

end.

제네릭 메소드(Generic method) 편집

namespace GenericMethodTest;

interface

type
GenericMethodTest = static class
public
  class method Main;
private
  class method Swap<T>(var left, right : T);
  class method DoSwap<T>(left, right : T);
end;

implementation

class method GenericMethodTest.DoSwap<T>(left, right : T);
begin
  var a := left;
  var b := right;
  Console.WriteLine('Type: {0}', typeof(T));
  Console.WriteLine('-> a = {0}, b = {1}', a , b);
  Swap<T>(var a, var b);
  Console.WriteLine('-> a = {0}, b = {1}', a , b);
end;

class method GenericMethodTest.Main;
begin
  var a := 23;// type inference
  var b := 15;
  DoSwap<Integer>(a, b); // no downcasting to Object in this method.

  var aa := 'abc';// type inference
  var bb := 'def';
  DoSwap<String>(aa, bb); // no downcasting to Object in this method.

  DoSwap(1.1, 1.2); // type inference for generic parameters
  Console.ReadLine();
end;

class method GenericMethodTest.Swap<T>(var left, right : T);
begin
  var temp := left;
  left:= right;
  right := temp;
end;

end.
  • 출력
Type: System.Int32
-> a = 23, b = 15
-> a = 15, b = 23
Type: System{{Not a typo|.}}String
-> a = abc, b = def
-> a = def, b = abc
Type: System{{Not a typo|.}}Double
-> a = 1,1, b = 1,2
-> a = 1,2, b = 1,1

각주 편집

외부 링크 편집