review & preview

15
Review & Preview 재재재 재재 (recursion and iteration) 재재재 재재재재 (procedural abstraction) 재재재재 재재재재 (data abstraction) 재재재재재 재재재재재 (objects and imperative progra mming) 재재재재 재재재재재 (values and applicative program ming) 재재재 재재 재재재재재 (types and typeful programmin g) 재재재 재재재재재 재재재재 (modularity and hierarchy) 재재재재재 재재 (exceptions and advanced control) 재재 재재재재재재 재재재재 (program proof) Scheme ML

Upload: melanie-ashley

Post on 30-Dec-2015

59 views

Category:

Documents


2 download

DESCRIPTION

Review & Preview. 재귀와 반복 (recursion and iteration) 함수로 요약하기 (procedural abstraction) 데이터로 요약하기 (data abstraction) 물건중심의 프로그래밍 (objects and imperative programming) 값중심의 프로그래밍 (values and applicative programming) 타입을 갖춘 프로그래밍 (types and typeful programming) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Review & Preview

Review & Preview• 재귀와 반복 (recursion and iteration)• 함수로 요약하기 (procedural abstraction)• 데이터로 요약하기 (data abstraction)• 물건중심의 프로그래밍 (objects and imperative program

ming)• 값중심의 프로그래밍 (values and applicative programmin

g)• 타입을 갖춘 프로그래밍 (types and typeful programming)• 모듈과 계층구조로 요약하기 (modularity and hierarchy)• 실행흐름의 관리 (exceptions and advanced control)• 맞는 프로그램인지 확인하기 (program proof)

Scheme

ML

Page 2: Review & Preview

Typeful Programming

• 타입의 유용함 , 겪어보았지요 ?– 프로그램을 짤 때 머리속을 정리해 주는 .– 버그가 덜 생기게 해주는 .

• “type discipline” = 타입중심 + 타입어긋나지말자

• 신세계 = “type discipline” 을 강요하고 , 타입대로 잘 돌지 미리 자동으로 검증해 주는 시스템

Page 3: Review & Preview

Technology for typeful programming

• automatic check for type-safety.• the check is proven safe.• types are infered(“ 인공지능” ).

– no need for programmer’s comments about expression types

• polymorphic types– no need for separate copies of “same” functio

ns for different types– let fun f(x) = x in (f 1, f “a”) end

Page 4: Review & Preview

ML programmingapplicative programming

value-oriented, not machine-oriented

값만 생각하는 프로그래밍

복잡한 머리는 터트려버려라

Page 5: Review & Preview

F-22 Standard ML/NJ

Page 6: Review & Preview

Rafale Ocaml

Page 7: Review & Preview

대형 프로그래밍을 위한 기술들supports for programming-in-

the-large

• 모듈 = 정의들 + 박스포장 + 박스이름– “module”, “.c file”, “structure”, “package”

• 모듈 타입 = 박스안에 있는 정의들의 타입들– “interface”, “.h file”, “module type”, “signature”

• 일반화된 모듈 = 모듈을 인자로 받는 모듈– “generic package”, “class template”, “functor”, “param

eterized module” • 타입 시스템

– 모듈 정의대로 외부에서 사용하는 지 자동으로 첵크– 겉으로 드러내기로 한 내용만 사용하는 지 자동으로

첵크

Page 8: Review & Preview

Modules in ML

val x = …type t=A|B…

이 보따리 이름은 Box

module Box = struct val x = … type t = … end

Box.x … Box.A

module( 보따리 ) 는 정의한 ( 이름붙인 ) 것들을 하나로모아놓고 이름붙여 놓은 것 입니다 .

Page 9: Review & Preview

Modules in ML

그러한 보따리의 타입 :

val x: int -> inttype t

val x: int -> inttype t = A|B

val x: int -> int

module type S = sig … end

signature matching

module XX: S = struct … end

Page 10: Review & Preview

functor( 모듈함수 ) 는 모듈을 받아서 모듈을 만드는 함수 functor F(X,Y) = struct … end

function( 함수 ) 는 값을 받아서 값을 만드는 함수 fun f(x,y) = x+y

Modules in ML

module F (X: sig … end, Y: sig … end) = struct … end

module F (X: S1, Y: S2) = struct … end

Page 11: Review & Preview

module type Animal = sig val age: int val think: string -> bool val feel: string -> bool end

module Couple (Beauty: Animal, Beast: Animal) = struct

val age = Beauty.age + Beast.agelet think x = (Beauty.think x) || (Beast.think x)

let feel x = (Beauty.feel x) && (Beast.feel x)end

Page 12: Review & Preview

module type CAR = sig type speed type fuel val accelerator: int -> speed val break: int -> speed val fill_tank: int -> fuel end

module Porche = struct type speed = int type fuel = EMPTY | FULL of int let accelerator n = n**n let break n = n/10 let fill_tank n = FULL n end

Page 13: Review & Preview

module TicoDriver = DriverSchool(Tico)module PorcheDriver = DriverSchool(Porche)

module DriverSchool(Car: CAR) = struct let speed_up n = Car.accelerator n let slow_down n = Car.break n let get_ready n = Car.fill_tank n end

module type CAR = sig type speed type fuel val accelerator: int -> speed val break: int -> speed val fill_tank: int -> fuel end

Page 14: Review & Preview

module type STACK = sig type atom type ‘a stack val empty_stack: atom stack val push: atom * atom stack -> atom stackend

module MakeStack(S: sig type t end) = struct type atom = S.t type ‘a stack = ‘a list let empty_stack = [] let push (x, stk) = x::stk end

Page 15: Review & Preview

structure IntStk = MakeStack(struct type t = int end)

structure StrStk = MakeStack(struct type t = string end)

structure PairStk = MakeStack(struct type t = int * string end)