Skip to content

Instantly share code, notes, and snippets.

Avatar

Stephan Brandauer kaeluka

View GitHub Profile
View moving_unique_ptr.cpp
class A {};
// Proof of concept.
//
// A class that wraps a unique_ptr and creates a copy constructor that
// allows you to copy it without the explicit move constructor.
// The move constructor will be implied. This violates the expectation
// that copying a value is free of side effects and you should therefore
// probably not use this class.
template <class T> struct moving_unique_ptr {
View stack.c
#include "stack.h"
#include <stdlib.h>
#include <assert.h>
typedef struct frame frame;
struct stack
{
frame *top;
int size;
View packages.md
  • yasnippets
  • multiple-cursors
  • ace-jump-mode
  • keyboard macros (built in)

Run M-x list-packagesRET to see a list of installable packages.

To see more packages, add the following lines at the beginning of your ~/.emacs:

@kaeluka
kaeluka / future.erl
Last active Aug 29, 2015
Futures in erlang
View future.erl
-module(future).
-export([async/1, fulfill/2, block/1, test/0]).
async(Fun) ->
F = mk(),
spawn(fun() ->
fulfill(F, Fun()) end),
F.
@kaeluka
kaeluka / horr.erl
Last active Jul 2, 2019
Global mutable state in erlang.
View horr.erl
-module(horr).
-export([malloc/0, free/1, read/1, write/2, test/0]).
% You can use `malloc` to get a globally sharable, mutable cell of memory.
% A difference to C's `malloc` is that such a cell doesn't have a certain size (you can't overflow)
% Memory is initialised with the atom `null`.
malloc() ->
spawn(fun() -> mem(null) end).
% As processes are not garbage collected, you have to call `free` when you're done with your memory:
View gist:9531bb772aa11a48d0c8
trait Foo {
fn foo();
}
impl Foo for &int {
fn foo() {
println!("&int")
}
}
View gist:11190403
{-# LANGUAGE ExistentialQuantification #-}
-- interface Foo {
-- void doFoo();
-- }
import Data.Char
-- A 'method' gets a this-ref, some args and a return type.
View gist:8844111
  1. arsoitenarosit arsteoin
  2. arsitenaristn arsten