Closure Impl. in Java

두 정수의 합 구하기 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. }  

    흐미..

Posted by 웅쓰

2008/04/01 14:42 2008/04/01 14:42
Response
No Trackback , No Comment
RSS :
http://comefeel.com/tt/comefeel/rss/response/386

Trackback URL : http://comefeel.com/tt/comefeel/trackback/386

« Previous : 1 : ... 43 : 44 : 45 : 46 : 47 : 48 : 49 : 50 : 51 : ... 358 : Next »

블로그 이미지

웅자의 상상플러스

- 웅쓰

Archives

Authors

  1. 웅쓰

Recent Trackbacks

Calendar

«   2012/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    

Site Stats

Total hits:
317187
Today:
100
Yesterday:
199