Last active
December 18, 2015 11:38
Revisions
-
soc revised this gist
Jun 14, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -173,6 +173,7 @@ The Union Type Quiz ( ) No, because: ______________________________ ( ) Maybe? 19. Describe how null will work with union types: ________________________________________________________________________________ ________________________________________________________________________________ -
soc revised this gist
Jun 14, 2013 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -166,14 +166,18 @@ The Union Type Quiz ( ) Other: ______________________________ 18. Will your design break existing, valid code? ( ) Yes ( ) Yes, but it doesn't matter because: ______________________________ ( ) No, because: ______________________________ ( ) Maybe? 19. Describe how null will work with union types: ________________________________________________________________________________ ________________________________________________________________________________ 20. Will your design make a difference whether a type has been inferred and has been specified explicitly? ________________________________________________________________________________ ________________________________________________________________________________ -
soc revised this gist
Jun 14, 2013 . 1 changed file with 27 additions and 28 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,24 @@ The Union Type Quiz =================== 0. Please give your typing approach an intuitive name: __________________________________________________ 1. Please describe the guiding principle of your typing approach in one sentence: ________________________________________________________________________________ ________________________________________________________________________________ 2. Should there be predefined implicit widening conversions between numbers? ( ) Yes, even if they are lossy ( ) Yes, but only non-lossy ones ( ) No ( ) Other: ______________________________ 3. What should be the inferred type of the expression List(1, 1.0)? ( ) List[Double] @@ -18,15 +27,15 @@ The Union Type Quiz ( ) Other: ______________________________ 4. What should be the inferred type of the expression List(1: java.lang.Integer, 1.0: java.lang.Double)? ( ) List[Number with Comparable[_ >: Double with Integer <: Number with Comparable[_ >: Double with Integer <: Number ...]]] ( ) List[java.lang.Integer|java.lang.Double] ( ) Other: ______________________________ 5. Do you prefer a union type A|B to Either[A, B]? ( ) Always ( ) Never @@ -38,7 +47,7 @@ The Union Type Quiz __________________________________________________ 6. Do prefer a nullable type T? to e. g. Option[T]? ( ) Always ( ) Never @@ -50,13 +59,13 @@ The Union Type Quiz __________________________________________________ 7. Explain why your answer to A|B vs. Either[A, B] is consistent and intuitive with your answer to T? vs. Option[T]: ________________________________________________________________________________ ________________________________________________________________________________ ________________________________________________________________________________ 8. Given the following declarations ... trait T object A extends T @@ -70,7 +79,7 @@ The Union Type Quiz ( ) Other: ______________________________ 9. Does your answer change if - trait T is sealed? ( ) Yes, because: __________________________________________________ ( ) No, because: __________________________________________________ @@ -82,39 +91,39 @@ The Union Type Quiz ( ) No, because: __________________________________________________ 10. What should be the inferred type of if (true) Some(1) else None? ( ) Option[Int] ( ) Some[Int]|None ( ) Other: ______________________________ 11. What should be the inferred type of if (true) Nil else List(1).asInstanceOf[::[Int]]? ( ) List[Int] ( ) Nil|::[Int] ( ) Other: ______________________________ 12. When should a nominal type be preferred to a more precise union type? ( ) Always ( ) Never ( ) Only if the element types enumerate all subclasses/subobjects of a sealed supertype ( ) Other: ______________________________ 13. When should a more precise structural type be preferred to a union type? ( ) Always ( ) Never ( ) Only if the structural type is specified explicitly ( ) Other: ______________________________ 14. Given the following declarations ... trait T { def foo: Int } class A extends T { def foo: Int = ???; def bar: Int = ??? } @@ -128,12 +137,12 @@ The Union Type Quiz [ ] aOrB.bippy 15. How will inference of union types interact with structural types? __________________________________________________ __________________________________________________ 16. Given the following definitions ... val x: AnyRef { def foo: Int } = null val y: AnyRef { def foo: Int } = null @@ -145,7 +154,7 @@ The Union Type Quiz ( ) Other: ______________________________ 17. Given the following definitions ... val x = new AnyRef { def foo: Int = 23} val y = new AnyRef { def foo: Int = 42} @@ -157,24 +166,14 @@ The Union Type Quiz ( ) Other: ______________________________ 18. Will your choice from above break existing, valid code? ( ) Yes ( ) Yes, but it doesn't matter because: ______________________________ ( ) No, because: ______________________________ ( ) Maybe? 19. Will your design make a difference whether a type has been inferred and has been specified explicitly? ________________________________________________________________________________ ________________________________________________________________________________ -
soc revised this gist
Jun 14, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -87,7 +87,7 @@ The Union Type Quiz ( ) Option[Int] ( ) Some[Int]|None ( ) Other: ______________________________ 10. What should be the inferred type of -
soc revised this gist
Jun 14, 2013 . 1 changed file with 113 additions and 113 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,180 +1,180 @@ The Union Type Quiz =================== 1. Should there be predefined implicit widening conversions between numbers? ( ) Yes, even if they are lossy ( ) Yes, but only non-lossy ones ( ) No ( ) Other: ______________________________ 2. What should be the inferred type of the expression List(1, 1.0)? ( ) List[Double] ( ) List[AnyVal] ( ) List[Int|Double] ( ) Other: ______________________________ 3. What should be the inferred type of the expression List(1: java.lang.Integer, 1.0: java.lang.Double)? ( ) List[Number with Comparable[_ >: Double with Integer <: Number with Comparable[_ >: Double with Integer <: Number ...]]] ( ) List[java.lang.Integer|java.lang.Double] ( ) Other: ______________________________ 4. Do you prefer a union type A|B to Either[A, B]? ( ) Always ( ) Never ( ) Sometimes: ______________________________ ( ) Other: ______________________________ Why? __________________________________________________ __________________________________________________ 5. Do prefer a nullable type T? to e. g. Option[T]? ( ) Always ( ) Never ( ) Sometimes: ______________________________ ( ) Other: ______________________________ Why? __________________________________________________ __________________________________________________ 6. Explain why your answer to A|B vs. Either[A, B] is consistent and intuitive with your answer to T? vs. Option[T]: ________________________________________________________________________________ ________________________________________________________________________________ ________________________________________________________________________________ 7. Given the following declarations ... trait T object A extends T object B extends T ... what should be the inferred type of if (true) A else B ( ) T ( ) A|B ( ) Other: ______________________________ 8. Does your answer change if - trait T is sealed? ( ) Yes, because: __________________________________________________ ( ) No, because: __________________________________________________ - A and/or B are classes? ( ) Yes, because: __________________________________________________ ( ) No, because: __________________________________________________ - A/B/T are type constructors? ( ) Yes, because: __________________________________________________ ( ) No, because: __________________________________________________ 9. What should be the inferred type of if (true) Some(1) else None? ( ) Option[Int] ( ) Some[Int]|None ( ) Other: ______________________________ 10. What should be the inferred type of if (true) Nil else List(1).asInstanceOf[::[Int]]? ( ) List[Int] ( ) Nil|::[Int] ( ) Other: ______________________________ 11. When should a nominal type be preferred to a more precise union type? ( ) Always ( ) Never ( ) Only if the element types enumerate all subclasses/subobjects of a sealed supertype ( ) Other: ______________________________ 12. When should a more precise structural type be preferred to a union type? ( ) Always ( ) Never ( ) Only if the structural type is specified explicitly ( ) Other: ______________________________ 13. Given the following declarations ... trait T { def foo: Int } class A extends T { def foo: Int = ???; def bar: Int = ??? } class B extends T { def foo: Int = ???; def bar: Int = ???; def bippy: Int = ??? } ... which members are allowed to be called on an instance aOrB of type A|B? [ ] aOrB.toString [ ] aOrB.foo [ ] aOrB.bar [ ] aOrB.bippy 14. How will inference of union types interact with structural types? __________________________________________________ __________________________________________________ 15. Given the following definitions ... val x: AnyRef { def foo: Int } = null val y: AnyRef { def foo: Int } = null ... should it be allowed to call xOrY.foo? ( ) Yes ( ) No ( ) Other: ______________________________ 16. Given the following definitions ... val x = new AnyRef { def foo: Int = 23} val y = new AnyRef { def foo: Int = 42} ... should it be allowed to call xOrY.foo? ( ) Yes ( ) No ( ) Other: ______________________________ 17. Will your choice from above break existing, valid code? ( ) Yes ( ) Yes, but it doesn't matter because: ______________________________ ( ) No, because: ______________________________ ( ) Maybe? 18. Will your design make a difference whether a type has been inferred and has been specified explicitly? ________________________________________________________________________________ ________________________________________________________________________________ 19. Please give your typing approach an intuitive name: __________________________________________________ 20. Please describe the guiding principle of your typing approach in one sentence: ________________________________________________________________________________ ________________________________________________________________________________ -
soc renamed this gist
Jun 14, 2013 . 1 changed file with 66 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ The Union Type Quiz =================== Should there be predefined implicit widening conversions between numbers? @@ -26,6 +26,36 @@ What should be the inferred type of the expression ( ) Other: ______________________________ Do you prefer a union type A|B to Either[A, B]? ( ) Always ( ) Never ( ) Sometimes: ______________________________ ( ) Other: ______________________________ Why? __________________________________________________ __________________________________________________ Do prefer a nullable type T? to e. g. Option[T]? ( ) Always ( ) Never ( ) Sometimes: ______________________________ ( ) Other: ______________________________ Why? __________________________________________________ __________________________________________________ Explain why your answer to A|B vs. Either[A, B] is consistent and intuitive with your answer to T? vs. Option[T]: ________________________________________________________________________________ ________________________________________________________________________________ ________________________________________________________________________________ Given the following declarations ... trait T @@ -68,15 +98,15 @@ What should be the inferred type of ( ) Other: ______________________________ When, if ever, should a nominal type be preferred to a more precise union type? ( ) Always ( ) Never ( ) Only if the element types enumerate all subclasses/subobjects of a sealed supertype ( ) Other: ______________________________ When, if ever, should a more precise structural type be preferred to a union type? ( ) Always ( ) Never @@ -98,6 +128,35 @@ Given the following declarations ... [ ] aOrB.bippy How will inference of union types interact with structural types? __________________________________________________ __________________________________________________ Given the following definitions ... val x: AnyRef { def foo: Int } = null val y: AnyRef { def foo: Int } = null ... should it be allowed to call xOrY.foo? ( ) Yes ( ) No ( ) Other: ______________________________ Given the following definitions ... val x = new AnyRef { def foo: Int = 23} val y = new AnyRef { def foo: Int = 42} ... should it be allowed to call xOrY.foo? ( ) Yes ( ) No ( ) Other: ______________________________ Will your choice from above break existing, valid code? ( ) Yes @@ -106,9 +165,9 @@ Will your choice from above break existing, valid code? ( ) Maybe? Will your design make a difference whether a type has been inferred and has been specified explicitly? ________________________________________________________________________________ ________________________________________________________________________________ Please give your typing approach an intuitive name: -
soc revised this gist
Jun 13, 2013 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -83,6 +83,7 @@ When, if ever, should a more precise structural type be prefered to a union type ( ) Only if the structural type is specified explicitly ( ) Other: ______________________________ Given the following declarations ... trait T { def foo: Int } @@ -109,9 +110,11 @@ How will inference interact with structural types? __________________________________________________ __________________________________________________ Please give your typing approach an intuitive name: __________________________________________________ Please describe the guiding principle of your typing approach in one sentence: ________________________________________________________________________________ ________________________________________________________________________________ -
soc created this gist
Jun 13, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,118 @@ Union type quiz =============== Should there be predefined implicit widening conversions between numbers? ( ) Yes, even if they are lossy ( ) Yes, but only non-lossy ones ( ) No ( ) Other: ______________________________ What should be the inferred type of the expression List(1, 1.0)? ( ) List[Double] ( ) List[AnyVal] ( ) List[Int|Double] ( ) Other: ______________________________ What should be the inferred type of the expression List(1: java.lang.Integer, 1.0: java.lang.Double)? ( ) List[Number with Comparable[_ >: Double with Integer <: Number with Comparable[_ >: Double with Integer <: Number ...]]] ( ) List[java.lang.Integer|java.lang.Double] ( ) Other: ______________________________ Given the following declarations ... trait T object A extends T object B extends T ... what should be the inferred type of if (true) A else B ( ) T ( ) A|B ( ) Other: ______________________________ Does your answer change if - trait T is sealed? ( ) Yes, because: __________________________________________________ ( ) No, because: __________________________________________________ - A and/or B are classes? ( ) Yes, because: __________________________________________________ ( ) No, because: __________________________________________________ - A/B/T are type constructors? ( ) Yes, because: __________________________________________________ ( ) No, because: __________________________________________________ What should be the inferred type of if (true) Some(1) else None? ( ) Option[Int] ( ) Some[Int]|None ( ) Other: ______________________________ What should be the inferred type of if (true) Nil else List(1).asInstanceOf[::[Int]]? ( ) List[Int] ( ) Nil|::[Int] ( ) Other: ______________________________ When, if ever, should a nominal type be prefered to a more precise union type? ( ) Always ( ) Never ( ) Only if the element types enumerate all subclasses/subobjects of a sealed supertype ( ) Other: ______________________________ When, if ever, should a more precise structural type be prefered to a union type? ( ) Always ( ) Never ( ) Only if the structural type is specified explicitly ( ) Other: ______________________________ Given the following declarations ... trait T { def foo: Int } class A extends T { def foo: Int = ???; def bar: Int = ??? } class B extends T { def foo: Int = ???; def bar: Int = ???; def bippy: Int = ??? } ... which members are allowed to be called on an instance aOrB of type A|B? [ ] aOrB.toString [ ] aOrB.foo [ ] aOrB.bar [ ] aOrB.bippy Will your choice from above break existing, valid code? ( ) Yes ( ) Yes, but it doesn't matter because: ______________________________ ( ) No, because: ______________________________ ( ) Maybe? How will inference interact with structural types? __________________________________________________ __________________________________________________ Please give your typing approach an intuitive name: __________________________________________________ Please describe the guiding principle of your typing approach in one sentence: ________________________________________________________________________________ ________________________________________________________________________________