Skip to content

Instantly share code, notes, and snippets.

@andrewchambers
andrewchambers / errors.md
Created August 28, 2018 22:49
Error values feedback

In my own code, I use my own error package. My observation is that a root cause of an error is special, most values in the error chain are useless except to preserve line information. Users and debuggers usually only care about the first error and the last error in the chain.

A typical formatting of an error is "Unable to ${TOP_ACTION}: ${ROOT_CAUSE}"

A typical usage of my package is:

@andrewchambers
andrewchambers / notes.txt
Last active April 12, 2018 13:01
Notes on a new interpreted language
I have been thinking recently about a set of features that might be
interesting for an interpreted language. Largely I am uninterested in the
syntax for now, just the properties of the language and implementation.
1. Actor model similar to erlang with total isolation of actors except
via message passing. Crashing one actor does not affect other actors
unless they want to be affected.
2. Mutability within an actor, but only immutable objects can be passed
use sys
use std
// XXX move to stdlib
const rename = {from, to
var ret = sys.rename(from, to)
-> ret == 0
}
use std
const runcmd = {cmd : byte[:][:]
var output, status
match std.spork(cmd)
| `std.Ok (pid, stdin, stdout):
match std.fslurp(stdout)
| `std.Ok out: output = out
while true
do
cat ~/fifo | (
while read rev ref
do
tarfile=$rev.tar.gz
(cd ~/gittest/server/ && git archive --format=tar $rev) | gzip > $tarfile
for cfg in `ls configs/`
do
package main
import (
"time"
"github.com/gopherjs/gopherjs/js"
)
func main() {
c := make(chan string)
//Three concurrent infinite loops generating events