3 ms·
It seems like these all are exclusive to dynamically/weakly typed languages. Anyone have examples of wats for languages with strong static typing?
by nv-vn 11y ago
It seems like these all are exclusive to dynamically/weakly typed languages. Anyone have examples of wats for languages with strong static typing?
- Macha 11y agoJava: * Reassigning interned integers via reflection * private fields work on a class level, not an instance level, i.e. Instances of a class can read private fields of other instances of the same class. * Arguably package-private fields as the docs like to avoid mentioning they exist. * ==, particularly in regards to boxed types. * List<String> x = new ArrayList<String>() {{ add("hello"); add("world"); }}; * The behaviour of .equals with the object you create above * Type Erasure
- dlwh 11y agoto add another: System.out.println(0.0 == -0.0); // true System.out.println(java.util.Arrays.equals(new double[] {0.0}, new double[] {-0.0})); // false (It's documented in the contract for Arrays.equals, but still kind of ridiculous.)
- tomsthumb 11y agoByte is signed. `Byte b = 127; b += 1; assert b != 128;`. That's not cool man.
- isbadawi 11y agoJava Puzzlers spring to mind. There's a book [0], and some fun talks available on youtube [1][2][3]. [0]: http://www.javapuzzlers.com/ http://www.javapuzzlers.com/ [1]: https://www.youtube.com/watch?v=wbp-3BJWsU8 https://www.youtube.com/watch?v=wbp-3BJWsU8 [2]: https://www.youtube.com/watch?v=yGFok5AJAyc https://www.youtube.com/watch?v=yGFok5AJAyc [3]: https://www.youtube.com/watch?v=Wnzyp1aitb8 https://www.youtube.com/watch?v=Wnzyp1aitb8
- Ao7bei3s 11y agoSure. Javas signed byte type comes to mind. Oh, and `null`, in any language ;-)
- Veedrac 11y agoSome guy made https://www.reddit.com/r/lolhaskell https://www.reddit.com/r/lolhaskell and put 3 posts there.
- oct 11y agoOCaml's parsing rules are pretty opaque sometimes. For example, if you have an "if" statement that's just performing effects (not returning a value), you may run into behavior like this: # let x = ref 0;; val x : int ref = {contents = 0} # let y = ref 0;; val y : int ref = {contents = 0} # if false then x := 1; y := 1; ;; - : unit = () # (!x, !y);; - : int * int = (0, 1) # y := 0;; - : unit = () # if false then let z = 1 in x := z; y := z; ;; - : unit = () # (!x, !y);; - : int * int = (0, 0)