1. 程式人生 > >[Erlang 0121] 當我們談論Erlang Maps時,我們談論什麼 Part 3

[Erlang 0121] 當我們談論Erlang Maps時,我們談論什麼 Part 3

Erlang/OTP 17.0 has been released    Erlang/OTP 17.0釋出了,不過Maps相關的設計還沒有塵埃落定,目前:
             With Maps you may for instance:

              -- M0 = #{ a => 1, b => 2}, % create associations

              -- M1 = M0#{ a := 10 }, % update values

              -- M2 = M1#{ "hi" => "hello"}, % add new associations

              -- #{ "hi" := V1, a := V2, b := V3} = M2. % match keys with

              values

              For information on how to use Maps please see the Reference
              Manual.

              The current implementation is without the following features:

              -- No variable keys

              -- No single value access

              -- No map comprehensions


              Note that Maps is experimental during OTP 17.0. 另外有一個不相容的情況: OTP-11782  == erts ==  The external format for Maps has changed in a way that is not  compatible with the format used in OTP 17.0-rc1 and OTP  17.0-rc2. 在這裡檢視詳情: Change the subtag used for maps from 0xB to 0xF Maps 模組對應的文件位置 佔坑,後續變動將在此更新.
Learn You Some Erlang 對Maps內容的增補章節   順便補幾張圖: 上面的圖看不懂?可以參考下面這篇論文,其中簡要介紹了Erlang的Tag-Scheme,或者可以去看下本文的第一篇 http://www.cnblogs.com/me-sa/p/when_we_talk_about_erlang_maps_1.html On Preserving Term Sharing in the Erlang Virtual Machine 摘要:In this paper we describe our experiences and argue through examples why flattening terms during copying is not a good idea for a language like Erlang. More importantly, we propose a sharing preserving copying mechanism for Erlang/OTP and describe a pub-
licly available complete implementation of this mechanism.