그렇다면 암시에서 좋지 않은 부분은 무엇일까? 필드의 ‘가방’처럼, 동작은 거의 들어가지 않은
타입을 정의하고(때로 이런 타입을 빈약한
anemic
타입이라고 한다), 모든 동작을 타입 클래스를
사용해서 추가하지 않는 이유는 무엇일까?
암시를 정의하는 것과 관련된 코드를 프로그래머가 추가로 작업해야 하며, 컴파일러도 암시 처
리를 위해 더 많은 작업을 수행해야 한다. 따라서 암시를 많이 사용하는 프로젝트는 빌드에 오
랜 시간이 걸린다.
암시적 변환은 래퍼 타입으로 인한 간접 계층을 한 번 더 거쳐야 하기 때문에 실행 시점에 추가
비용이 든다. 일부 메서드를 컴파일러가 인라인할 수 있고,
JVM
이 추가 최적화를 한다는 것은
사실이다. 그럼에도 불구하고 정당화할 수 있는 경우에만 그런 추가 비용을 지불해야 한다.
14
장에서는 컴파일러가 실행 시점 부가 비용을 아예 없애주는 값 타입
value
type
에 대해 논의할 것
이다.
다른 스칼라 기능과 관련된 몇 가지 기술적 문제가 있다. 특히 서브타입의 경우가 그렇다(더 완
전한 논의를 보려면
scala
-
debate
전자우편 그룹의 글(
http
://
bit
.
ly
/
1wOrmce
)을 보라).
요점만 보여주는 간단한 예를 사용하자.
//
src
/
main
/
scala
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.
O’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
I wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
I’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
I'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.