RSS구독하기:SUBSCRIBE TO RSS FEED
즐겨찾기추가:ADD FAVORITE
글쓰기:POST
관리자:ADMINISTRATOR

두 정수의 합 구하기 Closure Literal.

  1.  
  2. {int x, int y => x+y}  

두 정수의 합 구하기 Closure를 지역 변수 plus에 할당하기

  1.  
  2. {int,int=>int} plus = {int x, int y => x+y};  

내부적으로는 위와 같은 literal들이 translation 됩니다. 예를들어,

  1.  
  2. {int,String=>Number throws IOException} xyzzy;  

와 같은 변수 선언은

  1.  
  2. interface Closure1<R,A2,throws E> { // system-generated  
  3.     R invoke(int x1, A2 x2) throws E;  
  4. }  
  5. Closure1<? extends Number,? super String,null> xyzzy;  

와 같이 변환됩니다.

Control Invocation Syntax의 예

  1.  
  2. withLock(lock) {  
  3.     System.out.println("hello");  
  4. }  

file 처리의 예

  1.  
  2. with(FileReader in : makeReader()) with(FileWriter out : makeWriter()) {  
  3.     // code using in and out  
  4. }  

    흐미..
2008/04/01 14:42 2008/04/01 14:42
이 글에는 트랙백을 보낼 수 없습니다
웅쓰:웅자의 상상플러스
웅자의 상상플러스
전체 (379)
게임 (5)
영화 (2)
기타 (23)
맛집 (5)
영어 (2)
대수학 (3)
형태소 (5)
Hacking (9)
Linux (112)
HTML (48)
Application_developing (48)
Web_developing (102)
Window (11)
«   2024/05   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
  1. 2016/01 (1)
  2. 2015/12 (3)
  3. 2015/10 (3)
  4. 2015/03 (2)
  5. 2015/01 (4)