Skip to content

Instantly share code, notes, and snippets.

View Swatinem's full-sized avatar

Arpad Borsos Swatinem

View GitHub Profile
@Swatinem
Swatinem / gist:5585263
Created May 15, 2013 16:25
The Java way of doing control flow
// the java way of doing control flow
try {
init;
for (;;) {
try {
if (!condition)
throw new ConditionNotMetExpection();
if (foo)
throw new ContinueExpection();
if (bar)
@Swatinem
Swatinem / codegen_advanced.md
Last active August 29, 2015 14:23
yavd ideas

The DOM is stupid. It has appendChild and insertBefore, but no prependChild and insertAfter.

So we should just walk the DOM back to front.

We will deal with fragments. A Fragment can contain a variable number of nodes, 0 or more.

  • seq() creates a fragment with 0 or more nodes
  • match() creates a fragment with 0 or 1 node
  • children creates a fragment with 0 or more nodes
@Swatinem
Swatinem / ast.md
Last active August 29, 2015 14:23
yavd ideas 3

this follows the estree format

interface Fragment <: Node {
  type: "Fragment";
  body: [
    Component | Tag | Block | Conditional | Iteration |
    Expression // Any JS  Expression
 ]
}
@Swatinem
Swatinem / api.js
Last active September 21, 2015 22:58
yet some more dom ideas
// The data structure of your favorite data structure libary.
// Might just be a plain JS Object. Keys are guaranteed to be Strings
DataMap = Any
// The library should be agnostic to what kind of data library is used,
// therefore every kind of data access should go through this interface
Data = {
// Creates a new Map, optionally with an initial JS object provided
create: (Object?) => DataMap,
// Used to retrieve a key, for example from the `Context`.
#![feature(alloc)]
#![feature(heap_api)]
extern crate alloc;
use alloc::heap::{usable_size};
use std::mem::{align_of, size_of};
use std::str::{from_utf8};
fn print_vec_sizes<T>(v: &Vec<T>) {