I hereby claim:
- I am densh on github.
- I am den_sh (https://keybase.io/den_sh) on keybase.
- I have a public key whose fingerprint is A7EB 371C E36F C968 528A 912E 4464 3DC9 4CC7 8F40
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
All things considered, our experience in Scala Native has shown that resource management in Scala is way harder than it should be. This gist presents a simple design pattern that makes it resource management absolutely hassle-free: scoped implicit lifetimes.
The main idea behind it is to encode resource lifetimes through a concept of an implicit scope. Scopes are necessary to acquire resources. They are responsible for disposal of the resources once the evaluation exits the
| import scalanative.native._ | |
| import SDL._ | |
| import SDLExtra._ | |
| @extern | |
| @link("SDL2") | |
| object SDL { | |
| type Window = CStruct0 | |
| type Renderer = CStruct0 |
| import scalanative.native._ | |
| import SDL._ | |
| import SDLExtra._ | |
| @extern | |
| @link("SDL2") | |
| object SDL { | |
| type Window = CStruct0 | |
| type Renderer = CStruct0 |
| # ab -n 10000 "http://127.0.0.1:7000/" | |
| This is ApacheBench, Version 2.3 <$Revision: 1807734 $> | |
| Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
| Licensed to The Apache Software Foundation, http://www.apache.org/ | |
| Benchmarking 127.0.0.1 (be patient) | |
| Completed 1000 requests | |
| Completed 2000 requests | |
| Completed 3000 requests | |
| Completed 4000 requests |
| # cat main.cpp | |
| #include <stdio.h> | |
| int main() { | |
| printf("hello, world!"); | |
| return 0; | |
| } | |
| # clang++ -c -Os main.cpp |
| # cat src/main/scala/Hello.scala | |
| object Foo { | |
| val a: Int = a | |
| val b: Boolean = b | |
| val c: Char = c | |
| val d: String = d | |
| } | |
| object Test extends App { | |
| println(Foo.a) |