Monomorphization

Monomorphization

프로그래밍 언어에서 다형성 기능 많은 단일형의 기능에 의해 각각의 고유한 인스턴스 생성을 대체하는 것이다, monomorphization은 컴파일 타임 과정이다.[1]그 후 출력 중간 표현(IR)과 더 잘 최적화할 수 있는 구체적인 형식을 가지고 있을 것이다 이러한 변환, 바람직한 일이다.게다가, 대부분의 IRs 낮은 수준의 질 필요가 있고 다형성을 지원하지 않도록 설계되어 있다.코드는 일반적으로 빠르게 박스형보다 더 느리게 하고 더 많은 공간은 함수 본문을 복제할 예정을 컴파일할 것 이런 식으로 만들어 냈어요.[2][3][4][5][6][7]

예를 들어 녹의 일반적인 정체성 기능의 사용, 이것이 이 한 예이다.

2id<.T>(x:T)->&Tfn main(){, 문자열)id("일부 텍스트") 해 주세요;int=id(10) println{반환 x;}!("{0}일 경우,{1}", int, 문자열);}

monomorphization한 후에, 이번이 될 것이다.

Fnid_i32(x:i32)->, i32{반환 x;}2id_str(x:&str)->,&년간{반환 x;}fn main(){, 문자열)자 id_str("일부 텍스트")int=id_i32(10) 해 주세요;println!("{0}일 경우,{1}", int, 문자열);}

「 」를 참조해 주세요.

레퍼런스

  1. ^ "Generic Data Types - The Rust Programming Language". Retrieved 27 May 2021.
  2. ^ Hume, Tristan. "Models of Generics and Metaprogramming: Go, Rust, Swift, D and More". Retrieved 27 May 2021.
  3. ^ Tanaka, Akira; Affeldt, Reynald; Garrigue, Jacques (2018). "Safe Low-level Code Generation in Coq Using Monomorphization and Monadification". Journal of Information Processing. 26: 54–72. doi:10.2197/ipsjjip.26.54.
  4. ^ "Extending Smt-Lib v2 with λ-Terms and Polymorphism". citeseerx.ist.psu.edu. CiteSeerX 10.1.1.663.6849. Retrieved 2021-07-06.
  5. ^ Cai, Yufei; Giarrusso, Paolo G.; Ostermann, Klaus (2016-01-11). "System f-omega with equirecursive types for datatype-generic programming". Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. POPL '16. St. Petersburg, FL, USA: Association for Computing Machinery: 30–43. doi:10.1145/2837614.2837660. ISBN 978-1-4503-3549-2. S2CID 17566568.
  6. ^ Klabnik, Steve; Nichols, Carol (2019-08-06). The Rust Programming Language (Covers Rust 2018). No Starch Press. ISBN 978-1-7185-0044-0.
  7. ^ Felty, Amy P.; Middeldorp, Aart (2015-07-30). Automated Deduction - CADE-25: 25th International Conference on Automated Deduction, Berlin, Germany, August 1-7, 2015, Proceedings. Springer. ISBN 978-3-319-21401-6.