2. Agenda
What is the Continuation
Capture & Call
Holes in Calculation
Reset and the Shift Of Control Flow
Reset the value of expression
The type of reset and shift expression
@CPS & Convert CPS
Convert recursive function to @
Return IOC
Context switching overlap Control
3. What is the Continuation
익숙한 분기 , 루프 ,
함수 호출 , 예외 이외
의 제어 흐름 메커니
즘을 구현할수 있게
해주는 강력 한 구문
라이브러리 구현자들
을 위한 기능
4. Reset & the Shift & Control Flow
Shift
캡쳐시 사용하는 함수
Reset
Continuation 의 제한 범위
Calc
k 의 값을 구멍으로 생각해
계산
Control Flow
# 순서에 맞게 호출됨
결과는 //2,//3 중에 결
5. The type of reset
and shift expression
&
Reset the
value of expression
6. @CPS & Convert CPS
컨티뉴에이션이 런타임 스택의 스냅샷으로 구현 => JVM 은
스택 조작 허용 안함
CPS 를 통해 해결
( 컨티뉴에이션 - 패싱 - 스타일 ) * shift => ControlContext[+A,-B,+C]
*
Reset 블록 내에 @ 표시
변환된 코드는 스칼라 코드와 혼합 안됨 ..
따라서 반드시 변환된 메소드로 어노테이트 해야함
7. Convert recursive function to @
ProcessDirectory Call
Shift 블록에 진입
Reset 블록의 끝으로
점프
For 문을 통해 cont 함
수 실행
Shift 구멍으로 들어가
서 재귀를 실행
재귀 함수 실행
For 문 사용 X
=> while 사용