Skip to content

Instantly share code, notes, and snippets.

View fowlmouth's full-sized avatar
🦃

Tim E fowlmouth

🦃
  • United States of America
View GitHub Profile
#include <typeinfo>
#include <cxxabi.h>
#include <string>
template<typename T>
std::string demangled_name()
{
int status;
const char* name = typeid(T).name();
char* res = abi::__cxa_demangle(name, nullptr, nullptr, &status);
@fowlmouth
fowlmouth / pmc.cpp
Last active May 24, 2016 07:45
polymorphic method cache example implementation
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <cstdint>
#include <cassert>
struct selector
{
# run some assembly code like
code = <<-eof
# stack
push 1 # [1]
push 2 # [1, 2]
add # [3]
print # []
push 2 # [2]
cond:
#pragma once
namespace glossolalia
{
struct input_state
{
std::string input;
std::size_t pos;
input_state (const std::string& src): input(src), pos(0)
import macros
var ct {.compileTime.} = 0
proc nextID* : int {.compileTime.} =
result = ct
ct += 1
macro decl (n): stmt =
var id = nextID()
#!/bin/sh
svg-objects-export.py --xpath "//svg:g[@inkscape:groupmode='layer']" --extra '--export-area-page --export-id-only' $1
# https://github.com/berteh/svg-objects-export
import strutils,times
import unsigned
type
UIDT* = uint64
UID* = distinct UIDT
proc sh (s: UID|UIDT|uint8): string =
"0x"&

what is an object

object is a unit of state and behaviors. if you think about a class hierarchy then an objects state is its instance variables and its behaviors are all the methods defined on the classes it inherits from. an object without knowledge of the objects that describe it is useless.

where is an object

in a local running simulation you know that all the data of your program lives in your computers memory. this is fine for local objects but can we describe an object that lives on a network node, where accessing data is costly or limited? if the network is represented by a local data object, and already objects are made of other objects, then an object who's data lives far far away can be referred to with a handle. a handle is two parts of data with a space and location, similar to a street address or a URL. 123 Mayweather the space is mayweather street where the number 123 refers to one house in particular. file:///bin the space is the filesystem where "/bin" has meaning, http://porn.xx

# new object format is
# (space,data)
# space is a pointer to an object that handles its identity
# space is another object so it has components and its own space
# needed to interpret itself (? maybe)
#
# some spaces can use the 4 or 8 byte int as raw data if its unique
# (native-int space, native-float space)
# AggregateType component can be used to fulfil a local data object