Skip to content

Instantly share code, notes, and snippets.

View apmckinlay's full-sized avatar

Andrew McKinlay apmckinlay

View GitHub Profile

Role: Expert Suneido Software Engineer.

Context: Use Suneido MCP to search, read, check, and execute code, read documentation, query the database.

Workflow: Explore -> Plan -> Write -> Verify

Suneido is an integrated system including language, database, and UI.

Explore via MCP before making suggestions. Do not hallucinate library or builtin functions.

You are an expert Suneido programmer. You write correct, idiomatic Suneido code. You never mix in syntax from other languages.

=== SUNEIDO LANGUAGE REFERENCE ===

Suneido is a dynamically typed, object-oriented language with C-like syntax and Smalltalk-style blocks. It compiles to bytecode and uses garbage collection.

CRITICAL SYNTAX RULES — violations make code invalid:

  1. STRING CONCATENATION: Use the $ operator. NEVER use + for strings. "hello" $ " world" → "hello world"
func TestPriorityQueue(t *testing.T) {
pq := NewPriorityQueue()
val := &struct{}{}
var wg sync.WaitGroup
const nthreads = 32
for range nthreads {
wg.Add(1)
go func() {
for range 100_000 {
pq.Put(1, 1, val)
@apmckinlay
apmckinlay / killer.go
Last active September 20, 2023 19:13
for {
time.Sleep(interval)
if ws.killClock.Add(1) > createDelay && nworkers.Load() > minWorkers {
ws.ch <- task{} // send poison pill to one worker
}
}
@apmckinlay
apmckinlay / worker.go
Last active September 20, 2023 17:43
timer := time.NewTimer(timeout)
for {
select {
case task = <-ws.ch:
if !timer.Stop() {
<-timer.C
}
timer.Reset(timeout)
run(task)
case <-timer.C:
@apmckinlay
apmckinlay / hmap.go
Last active February 13, 2023 17:56
type Hmap[K any, V any, H helper[K]] struct {
help H
// ...
}
type helper[K any] interface {
Hash(k K) uint64
Equal(x, y K) bool
}
@apmckinlay
apmckinlay / small_test.go
Created March 6, 2019 17:09
testing Go small structs and interfaces
package runtime
import "testing"
type intfc interface {
f() intfc
}
type byval struct {
x int
@apmckinlay
apmckinlay / htbl.h
Created January 7, 2018 23:03
hash table implementation
#pragma once
/*
* Hmap and Hset are hash based maps and sets
* implemented with: prime table sizes, open addressing, linear probing,
* robin hood hashing, and resize on probe limit.
* Htbl is the common code, it is not intended for external use.
* To avoid padding it uses an array of blocks each with BN (4) entries.
* But we still treat it as a single flat array.
* Within blocks keys, values, and distances are separate arrays to avoid padding.
* Uses uint16 for size so limited to 64k slots or about 48k elements.
@apmckinlay
apmckinlay / Bind
Last active November 23, 2017 18:37
Suneido Bind function
class
{
CallClass(@args)
{
ai = 0
fi = 1
mixed = args[1..].Map({ it is Bind ? 'a' $ ai++ : '.f' $ fi++ }).Join(',')
c = (.binder)(mixed)
return c(@args.Remove(Bind))
}
@apmckinlay
apmckinlay / Curry
Last active November 23, 2017 18:38
Suneido Curry function
function (@args)
{
helper = class
{
New(.args)
{ }
Call(@args2)
{
args = .args
if not args2.Empty?()