SlideShare a Scribd company logo
1 of 14
Download to read offline
Value Objects
Brendan Eich
<brendan@mozilla.org>
Sunday, July 28, 13
Use Cases
• symbol, arguably
• int64, uint64
• Int32x4, Int32x8 (SIMD)
• float32
• Float32x4, Float32x8 (SIMD)
• bignum
• decimal
• rational
• complex
Sunday, July 28, 13
Overloadable Operators
•| ^ &
•==
•< <=
•<< >> >>>
•+ -
•* / %
•~ boolean-test unary- unary+
Sunday, July 28, 13
Preserving Boolean Algebra
• != and ! are not overloadable to preserve
identities including
• X ? A : B <=> !X ? B : A
• !(X && Y) <=> !X || !Y
• !(X || Y) <=> !X && !Y
• X != Y <=> !(X == Y)
Sunday, July 28, 13
Preserving Relational Relations
• > and >= are derived from < and <= as
follows:
• A > B <=> B < A
• A >= B <=> B <= A
• We provide <= in addition to < rather than
derive A <= B from !(B < A) in order to
allow the <= overloading to match the same
value object’s == semantics -- and for special
cases, e.g., unordered values (NaNs)
Sunday, July 28, 13
Strict Equality Operators
• The strict equality operators, === and !==,
cannot be overloaded
• They work on frozen-by-definition value
objects via a structural recursive strict
equality test
• Same-object-reference remains a fast-path
optimization
Sunday, July 28, 13
Why Not Double Dispatch?
• Left-first asymmetry (v value, n number):
• v + n ==> v.add(n)
• n + v ==> v.radd(n)
• Anti-modular: exhaustive other-operand
type enumeration required in operator
method bodies
• Consequent loss of compositionality:
complex and rational cannot be
composed to make ratplex without
modifying source or wrapping in proxies
Sunday, July 28, 13
Cacheable Multimethods
• Proposed in 2009 by Christian Plesner Hansen
(Google) in es-discuss
• Avoids double-dispatch drawbacks from last
slide: binary operators implemented by 2-ary
functions for each pair of types
• Supports PIC optimizations (Christian was on
theV8 team)
• Background reading: [Chambers 1992]
Sunday, July 28, 13
Binary Operator Example
• For the expression v + u
• Let p = v.[[Get]](@@ADD)
• If p is not an Array, throw a TypeError
• Let q = u.[[Get]](@@ADD_R)
• If q is not an Array, throw a TypeError
• Let r = p intersect q
• If r.length != 1 throw a TypeError
• Let f = r[0]; if f is not a function, throw
• Evaluate f(v, u) and return the result
Sunday, July 28, 13
API Idea from CPH 2009
function addPointAndNumber(a, b) {
return Point(a.x + b, a.y + b);
}
Function.defineOperator('+', addPointAndNumber, Point, Number);
function addNumberAndPoint(a, b) {
return Point(a + b.x, a + b.y);
}
Function.defineOperator('+', addNumberAndPoint, Number, Point);
function addPoints(a, b) {
return Point(a.x + b.x, a.y + b.y);
}
Function.defineOperator('+', addPoints, Point, Point);
Sunday, July 28, 13
Literal Syntax
• int64(0) ==> 0L // as in C#
• uint64(0) ==> 0UL // as in C#
• float32(0) ==> 0f // as in C#
• bignum(0) ==> 0I // as in F#
• decimal(0) ==> 0m // or M, C/F#
• We want a syntax extension mechanism, but
declarative not runtime API
• This suggests declarative syntax for operator
definition -- and scoped usage too
Sunday, July 28, 13
To new or not to new?
• new connotes reference type semantics, heap
allocation, mutability by default (that’s JS!)
• Proposal: new int64(42) throws (for any
scalar or “non-aggregate” value object)
• Option: new Float32x4(a,b,c,d) makes a
mutable 4-vector, but calling Float32x4(...)
without new means observably immutable, so
even stack allocatable (important to enable)
• Alternative: always immutable, but then why
allow new instead of call to “create a value”
Sunday, July 28, 13
typeof travails and travesties
• Invariant -- these two imply each other in JS:
•typeof x == typeof y && x == y
•x === y
•0m == 0 && 0L == 0 means 0m == 0L
(transitivity), but 0m !== 0L (different precision
and radix) so typeof 0m != typeof 0L per
the invariant
• Usability favors typeof 0L == “int64” and
typeof 0m == “decimal” anyway
• Making typeof extensible requires a per-realm
registry with throw-on-conflict
Sunday, July 28, 13
25 July 2013 TC39 Resolutions
• Waldemar points out that NaN requires
separately overloadable <= and < [Slide 5]
• Intersection means function identity matters, so
multimethods can break cross-realm [Slide 9]
• Mark objects that I as bignum suffix conflicts
with complex [Slide 11]
• Always throw on new -- value objects are never
mutable and should not appear to be so, even if
aggregate [Slide 12]
• Need to work through any side channel hazard of
the typeof registry [Slide 13]
Sunday, July 28, 13

More Related Content

What's hot

整数列圧縮
整数列圧縮整数列圧縮
整数列圧縮
JAVA DM
 
オブジェクト指向できていますか?
オブジェクト指向できていますか?オブジェクト指向できていますか?
オブジェクト指向できていますか?
Moriharu Ohzu
 
Rによるデータサイエンス13「樹木モデル」
Rによるデータサイエンス13「樹木モデル」Rによるデータサイエンス13「樹木モデル」
Rによるデータサイエンス13「樹木モデル」
Takeshi Mikami
 
ブラウザにやさしいHTML/CSS
ブラウザにやさしいHTML/CSSブラウザにやさしいHTML/CSS
ブラウザにやさしいHTML/CSS
Takeharu Igari
 

What's hot (20)

Map
MapMap
Map
 
整数列圧縮
整数列圧縮整数列圧縮
整数列圧縮
 
最近のRのランダムフォレストパッケージ -ranger/Rborist-
最近のRのランダムフォレストパッケージ -ranger/Rborist-最近のRのランダムフォレストパッケージ -ranger/Rborist-
最近のRのランダムフォレストパッケージ -ranger/Rborist-
 
R実践 機械学習による異常検知 01
R実践 機械学習による異常検知 01R実践 機械学習による異常検知 01
R実践 機械学習による異常検知 01
 
SSE4.2の文字列処理命令の紹介
SSE4.2の文字列処理命令の紹介SSE4.2の文字列処理命令の紹介
SSE4.2の文字列処理命令の紹介
 
認知行動療法に活かす動機づけテクニック(動機づけ面接、共有意思決定、言語行動)
認知行動療法に活かす動機づけテクニック(動機づけ面接、共有意思決定、言語行動)認知行動療法に活かす動機づけテクニック(動機づけ面接、共有意思決定、言語行動)
認知行動療法に活かす動機づけテクニック(動機づけ面接、共有意思決定、言語行動)
 
特徴選択のためのLasso解列挙
特徴選択のためのLasso解列挙特徴選択のためのLasso解列挙
特徴選択のためのLasso解列挙
 
オブジェクト指向できていますか?
オブジェクト指向できていますか?オブジェクト指向できていますか?
オブジェクト指向できていますか?
 
思考停止しないアーキテクチャ設計 ➖ JJUG CCC 2018 Fall
思考停止しないアーキテクチャ設計 ➖ JJUG CCC 2018 Fall思考停止しないアーキテクチャ設計 ➖ JJUG CCC 2018 Fall
思考停止しないアーキテクチャ設計 ➖ JJUG CCC 2018 Fall
 
ゆるふわ強化学習入門
ゆるふわ強化学習入門ゆるふわ強化学習入門
ゆるふわ強化学習入門
 
Elasticsearchのサジェスト機能を使った話
Elasticsearchのサジェスト機能を使った話Elasticsearchのサジェスト機能を使った話
Elasticsearchのサジェスト機能を使った話
 
Rによるデータサイエンス13「樹木モデル」
Rによるデータサイエンス13「樹木モデル」Rによるデータサイエンス13「樹木モデル」
Rによるデータサイエンス13「樹木モデル」
 
動的輪郭モデル
動的輪郭モデル動的輪郭モデル
動的輪郭モデル
 
ブラウザにやさしいHTML/CSS
ブラウザにやさしいHTML/CSSブラウザにやさしいHTML/CSS
ブラウザにやさしいHTML/CSS
 
Gui自動テストツール基本
Gui自動テストツール基本Gui自動テストツール基本
Gui自動テストツール基本
 
プログラムの処方箋~健康なコードと病んだコード
プログラムの処方箋~健康なコードと病んだコードプログラムの処方箋~健康なコードと病んだコード
プログラムの処方箋~健康なコードと病んだコード
 
不明熱
不明熱不明熱
不明熱
 
カーネル法:正定値カーネルの理論
カーネル法:正定値カーネルの理論カーネル法:正定値カーネルの理論
カーネル法:正定値カーネルの理論
 
VRM-VCIが広げるVR世界間ポータビリティ
VRM-VCIが広げるVR世界間ポータビリティVRM-VCIが広げるVR世界間ポータビリティ
VRM-VCIが広げるVR世界間ポータビリティ
 
認証の標準的な方法は分かった。では認可はどう管理するんだい? #cmdevio
認証の標準的な方法は分かった。では認可はどう管理するんだい? #cmdevio認証の標準的な方法は分かった。では認可はどう管理するんだい? #cmdevio
認証の標準的な方法は分かった。では認可はどう管理するんだい? #cmdevio
 

Viewers also liked

Viewers also liked (20)

Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)Value Objects, Full Throttle (to be updated for spring TC39 meetings)
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
 
Extensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScriptExtensible Operators and Literals for JavaScript
Extensible Operators and Literals for JavaScript
 
Mozilla Research Party Talk
Mozilla Research Party TalkMozilla Research Party Talk
Mozilla Research Party Talk
 
Containers in a File
Containers in a FileContainers in a File
Containers in a File
 
PFcache - LinuxCon 2015
PFcache - LinuxCon 2015PFcache - LinuxCon 2015
PFcache - LinuxCon 2015
 
Values
ValuesValues
Values
 
Value Objects
Value ObjectsValue Objects
Value Objects
 
Paren free
Paren freeParen free
Paren free
 
Web futures
Web futuresWeb futures
Web futures
 
JSLOL
JSLOLJSLOL
JSLOL
 
Capitol js
Capitol jsCapitol js
Capitol js
 
Fluent15
Fluent15Fluent15
Fluent15
 
My dotJS Talk
My dotJS TalkMy dotJS Talk
My dotJS Talk
 
JS Responsibilities
JS ResponsibilitiesJS Responsibilities
JS Responsibilities
 
Mozilla's NodeConf talk
Mozilla's NodeConf talkMozilla's NodeConf talk
Mozilla's NodeConf talk
 
Fluent14
Fluent14Fluent14
Fluent14
 
Taysom seminar
Taysom seminarTaysom seminar
Taysom seminar
 
dotJS 2015
dotJS 2015dotJS 2015
dotJS 2015
 
Always bet on JS - Finjs.io NYC 2016
Always bet on JS - Finjs.io NYC 2016Always bet on JS - Finjs.io NYC 2016
Always bet on JS - Finjs.io NYC 2016
 
Serializing Value Objects-Ara Hacopian
Serializing Value Objects-Ara HacopianSerializing Value Objects-Ara Hacopian
Serializing Value Objects-Ara Hacopian
 

Similar to Value objects in JS - an ES7 work in progress

Building Single-Page Web Appplications in dart - Devoxx France 2013
Building Single-Page Web Appplications in dart - Devoxx France 2013Building Single-Page Web Appplications in dart - Devoxx France 2013
Building Single-Page Web Appplications in dart - Devoxx France 2013
yohanbeschi
 

Similar to Value objects in JS - an ES7 work in progress (20)

Scalable JavaScript
Scalable JavaScriptScalable JavaScript
Scalable JavaScript
 
The Present and Future of the Web Platform
The Present and Future of the Web PlatformThe Present and Future of the Web Platform
The Present and Future of the Web Platform
 
Monads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy DyagilevMonads and Monoids by Oleksiy Dyagilev
Monads and Monoids by Oleksiy Dyagilev
 
[COSCUP 2023] 我的Julia軟體架構演進之旅
[COSCUP 2023] 我的Julia軟體架構演進之旅[COSCUP 2023] 我的Julia軟體架構演進之旅
[COSCUP 2023] 我的Julia軟體架構演進之旅
 
Lenguaje python en I+D. Numpy, Sympy y Pandas
Lenguaje python en I+D. Numpy, Sympy y PandasLenguaje python en I+D. Numpy, Sympy y Pandas
Lenguaje python en I+D. Numpy, Sympy y Pandas
 
Object Oriented Programming using C++ - Part 4
Object Oriented Programming using C++ - Part 4Object Oriented Programming using C++ - Part 4
Object Oriented Programming using C++ - Part 4
 
Getting Started with C++ (TCF 2014)
Getting Started with C++ (TCF 2014)Getting Started with C++ (TCF 2014)
Getting Started with C++ (TCF 2014)
 
Introduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicoxIntroduction to web programming for java and c# programmers by @drpicox
Introduction to web programming for java and c# programmers by @drpicox
 
Using R in remote computer clusters
Using R in remote computer clustersUsing R in remote computer clusters
Using R in remote computer clusters
 
Building Single-Page Web Appplications in dart - Devoxx France 2013
Building Single-Page Web Appplications in dart - Devoxx France 2013Building Single-Page Web Appplications in dart - Devoxx France 2013
Building Single-Page Web Appplications in dart - Devoxx France 2013
 
P1
P1P1
P1
 
C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)C++ Advanced Features (TCF 2014)
C++ Advanced Features (TCF 2014)
 
Int64
Int64Int64
Int64
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
 
C++ Advanced Features
C++ Advanced FeaturesC++ Advanced Features
C++ Advanced Features
 
Return of c++
Return of c++Return of c++
Return of c++
 
C++ Advanced Features
C++ Advanced FeaturesC++ Advanced Features
C++ Advanced Features
 
Introduction to Ruby Programming Language
Introduction to Ruby Programming LanguageIntroduction to Ruby Programming Language
Introduction to Ruby Programming Language
 
James Coplien: Trygve - Oct 17, 2016
James Coplien: Trygve - Oct 17, 2016James Coplien: Trygve - Oct 17, 2016
James Coplien: Trygve - Oct 17, 2016
 

More from Brendan Eich (7)

The Same-Origin Saga
The Same-Origin SagaThe Same-Origin Saga
The Same-Origin Saga
 
Splash
SplashSplash
Splash
 
Txjs talk
Txjs talkTxjs talk
Txjs talk
 
ES.next
ES.nextES.next
ES.next
 
MSR Talk
MSR TalkMSR Talk
MSR Talk
 
Future Tense
Future TenseFuture Tense
Future Tense
 
Proxies are Awesome!
Proxies are Awesome!Proxies are Awesome!
Proxies are Awesome!
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Value objects in JS - an ES7 work in progress

  • 2. Use Cases • symbol, arguably • int64, uint64 • Int32x4, Int32x8 (SIMD) • float32 • Float32x4, Float32x8 (SIMD) • bignum • decimal • rational • complex Sunday, July 28, 13
  • 3. Overloadable Operators •| ^ & •== •< <= •<< >> >>> •+ - •* / % •~ boolean-test unary- unary+ Sunday, July 28, 13
  • 4. Preserving Boolean Algebra • != and ! are not overloadable to preserve identities including • X ? A : B <=> !X ? B : A • !(X && Y) <=> !X || !Y • !(X || Y) <=> !X && !Y • X != Y <=> !(X == Y) Sunday, July 28, 13
  • 5. Preserving Relational Relations • > and >= are derived from < and <= as follows: • A > B <=> B < A • A >= B <=> B <= A • We provide <= in addition to < rather than derive A <= B from !(B < A) in order to allow the <= overloading to match the same value object’s == semantics -- and for special cases, e.g., unordered values (NaNs) Sunday, July 28, 13
  • 6. Strict Equality Operators • The strict equality operators, === and !==, cannot be overloaded • They work on frozen-by-definition value objects via a structural recursive strict equality test • Same-object-reference remains a fast-path optimization Sunday, July 28, 13
  • 7. Why Not Double Dispatch? • Left-first asymmetry (v value, n number): • v + n ==> v.add(n) • n + v ==> v.radd(n) • Anti-modular: exhaustive other-operand type enumeration required in operator method bodies • Consequent loss of compositionality: complex and rational cannot be composed to make ratplex without modifying source or wrapping in proxies Sunday, July 28, 13
  • 8. Cacheable Multimethods • Proposed in 2009 by Christian Plesner Hansen (Google) in es-discuss • Avoids double-dispatch drawbacks from last slide: binary operators implemented by 2-ary functions for each pair of types • Supports PIC optimizations (Christian was on theV8 team) • Background reading: [Chambers 1992] Sunday, July 28, 13
  • 9. Binary Operator Example • For the expression v + u • Let p = v.[[Get]](@@ADD) • If p is not an Array, throw a TypeError • Let q = u.[[Get]](@@ADD_R) • If q is not an Array, throw a TypeError • Let r = p intersect q • If r.length != 1 throw a TypeError • Let f = r[0]; if f is not a function, throw • Evaluate f(v, u) and return the result Sunday, July 28, 13
  • 10. API Idea from CPH 2009 function addPointAndNumber(a, b) { return Point(a.x + b, a.y + b); } Function.defineOperator('+', addPointAndNumber, Point, Number); function addNumberAndPoint(a, b) { return Point(a + b.x, a + b.y); } Function.defineOperator('+', addNumberAndPoint, Number, Point); function addPoints(a, b) { return Point(a.x + b.x, a.y + b.y); } Function.defineOperator('+', addPoints, Point, Point); Sunday, July 28, 13
  • 11. Literal Syntax • int64(0) ==> 0L // as in C# • uint64(0) ==> 0UL // as in C# • float32(0) ==> 0f // as in C# • bignum(0) ==> 0I // as in F# • decimal(0) ==> 0m // or M, C/F# • We want a syntax extension mechanism, but declarative not runtime API • This suggests declarative syntax for operator definition -- and scoped usage too Sunday, July 28, 13
  • 12. To new or not to new? • new connotes reference type semantics, heap allocation, mutability by default (that’s JS!) • Proposal: new int64(42) throws (for any scalar or “non-aggregate” value object) • Option: new Float32x4(a,b,c,d) makes a mutable 4-vector, but calling Float32x4(...) without new means observably immutable, so even stack allocatable (important to enable) • Alternative: always immutable, but then why allow new instead of call to “create a value” Sunday, July 28, 13
  • 13. typeof travails and travesties • Invariant -- these two imply each other in JS: •typeof x == typeof y && x == y •x === y •0m == 0 && 0L == 0 means 0m == 0L (transitivity), but 0m !== 0L (different precision and radix) so typeof 0m != typeof 0L per the invariant • Usability favors typeof 0L == “int64” and typeof 0m == “decimal” anyway • Making typeof extensible requires a per-realm registry with throw-on-conflict Sunday, July 28, 13
  • 14. 25 July 2013 TC39 Resolutions • Waldemar points out that NaN requires separately overloadable <= and < [Slide 5] • Intersection means function identity matters, so multimethods can break cross-realm [Slide 9] • Mark objects that I as bignum suffix conflicts with complex [Slide 11] • Always throw on new -- value objects are never mutable and should not appear to be so, even if aggregate [Slide 12] • Need to work through any side channel hazard of the typeof registry [Slide 13] Sunday, July 28, 13