Skip to content

Instantly share code, notes, and snippets.

Jason Zaugg retronym

  • Lightbend
  • Brisbane, Australia
Block or report user

Report or block retronym

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View sealed-subclass-copier.scala
scala> object O {
| sealed abstract class Base;
| case class Foo(id: Int, b: String) extends Base
| case class Bar(id: Int, b: Boolean) extends Base
| }
defined module O
scala> import O._
import O._
@retronym
retronym / indylambda.md
Last active Aug 22, 2019
indylambda: Putting invokedynamic to work for Scala
View indylambda.md

indylambda: Putting invokedynamic to work for Scala

Java 8 introduced lambdas to the Java language. While the design choices differ in many regards from Scala's functions, the underlying mechanics used to represent Java lambdas is flexible enough to be used as a target for the Scala compiler.

Lambdas in Java

Java does not have canonical heirarchy of generic function types (ala scala.FunctionN), but instead allows a lambda to be used as a shorthand for an anonymous implementation of an Functional Interface

Here's an example of creating a predicate that closes over one value:

@retronym
retronym / type-bounds.scala
Created Dec 16, 2009
Tour of Scala Type Bounds
View type-bounds.scala
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
@retronym
retronym / lub2.scala
Created Mar 23, 2010
Calculate the Least Upper Bound of two types.
View lub2.scala
object test {
case class L[A, B]() {
def ToLub[AA >: A <: L, BB >: B <: L, L] = new { type LUB = L }
}
val intBoolLub = L[Int, Boolean].ToLub
(1: AnyVal) : intBoolLub.LUB
1: intBoolLub.LUB
View perfasm.md

Slow

[info] ....[Hottest Region 1]..............................................................................
[info] c2, level 4, bench.generated.ListsBenchmark_scalaListBufferPlusEq_212_jmhTest::scalaListBufferPlusEq_212_thrpt_jmhStub, version 616 (348 bytes)
[info]                                                                         ; - scala.collection.mutable.ListBuffer::&lt;init&gt;@1 (line 48)
[info]                                                                         ; - bench.ListsBenchmark::scalaListBufferPlusEq_212@4 (line 42)
[info]                                                                         ; - bench.generated.ListsBenchmark_scalaListBufferPlusEq_212_jmhTest::scalaListBufferPlusEq_212_thrpt_jmhStub@17 (line 119)
[info]                                                                         ; implicit exception: dispatches to 0x00007fd547e826ea
[info]               0x00007fd547e8233b: test   r11d,r11d
View result-.json
[
{
"jmhVersion" : "1.21",
"benchmark" : "bench.ListBufferBenchmark.intListCreation",
"mode" : "thrpt",
"threads" : 1,
"forks" : 2,
"jvm" : "/Users/jz/.jabba/jdk/adopt@1.8.212-04/Contents/Home/jre/bin/java",
"jvmArgs" : [
"-server",
View result-.json
[
{
"jmhVersion" : "1.21",
"benchmark" : "bench.ListBufferBenchmark.intListCreation",
"mode" : "thrpt",
"threads" : 1,
"forks" : 2,
"jvm" : "/Users/jz/.jabba/jdk/adopt@1.8.212-04/Contents/Home/jre/bin/java",
"jvmArgs" : [
"-server",
View result-.json
[
{
"jmhVersion" : "1.21",
"benchmark" : "bench.ListBufferBenchmark.intListCreation",
"mode" : "thrpt",
"threads" : 1,
"forks" : 2,
"jvm" : "/Users/jz/.jabba/jdk/adopt@1.8.212-04/Contents/Home/jre/bin/java",
"jvmArgs" : [
"-server",
View result-.json
[
{
"jmhVersion" : "1.21",
"benchmark" : "bench.ListBufferBenchmark.intListCreation",
"mode" : "thrpt",
"threads" : 1,
"forks" : 2,
"jvm" : "/Users/jz/.jabba/jdk/adopt@1.8.212-04/Contents/Home/jre/bin/java",
"jvmArgs" : [
"-server",
View result-.json
[
{
"jmhVersion" : "1.21",
"benchmark" : "bench.ListBufferBenchmark.intListCreation",
"mode" : "thrpt",
"threads" : 1,
"forks" : 2,
"jvm" : "/Users/jz/.jabba/jdk/adopt@1.8.212-04/Contents/Home/jre/bin/java",
"jvmArgs" : [
"-server",
You can’t perform that action at this time.