Skip to content

Instantly share code, notes, and snippets.

Brief comments on https://eev.ee/blog/2016/12/01/lets-stop-copying-c/ for Odin
A - Agree with eev.ee
D - Disagree with eev.ee
S - Have it for sanity reasons
O - Other reason
[A] Textual Inclusion
[A] Optional block delimiters
[A] Bitwise operator precedence
@gingerBill
gingerBill / stb_image.odin
Last active November 4, 2017 11:39
stb_image in Odin
when ODIN_OS == "windows" do foreign import stbi "stb_image.lib"
//
// load image by filename, open file, or memory buffer
//
Io_Callbacks :: struct #ordered {
read: proc "c" (user: rawptr, data: ^u8, size: i32) -> i32, // fill 'data' with 'size' u8s. return number of u8s actually read
skip: proc "c" (user: rawptr, n: i32), // skip the next 'n' u8s, or 'unget' the last -n u8s if negative
eof: proc "c" (user: rawptr) -> i32, // returns nonzero if we are at end of file/data
}
@gingerBill
gingerBill / plugin_system_idea.md
Last active April 16, 2017 10:56
Plug-in System for a Compiler (Idea for Odin)

One of the original goals in Odin was metaprogramming. However, as development progressed, it has come clear that this is such a broad term which could mean anything.

The kinds of metaprogramming originally conceived are compile time execution, AST modification, and "semantic macros".

Here is the new idea: allow the user to "plug-in" their own metaprogramming functionality as a stage in the compiler. With the specific stages being:

  • File loading (get text into memory)
  • Tokenizing/Lexing
  • Parsing
  • Type checking
@gingerBill
gingerBill / gist:5b620b50a02930f4961075e3b4fd3e17
Last active June 26, 2017 14:55
Jai-like Syntax Solution for Foreign Procedures
I'm using `proc` as a prefix to remove ambiguity in the syntax. The current syntax is ambiguous.
(int) // Is this a procedure that takes an int or is it just an int?
Current Jai Syntax:
name :: proc(); // type
name :: proc() {}; // declaration
name :: proc() #foreign lib; // foreign declaration
This syntax fails if you want have foreign variables too. Foreign variables would not have a consistent syntax.
@gingerBill
gingerBill / priority_queue.cpp
Created August 20, 2017 17:28
Priority Queue
template <typename T>
struct PriorityQueue {
Array<T> queue;
int (* cmp) (T *q, isize i, isize j);
void (* swap)(T *q, isize i, isize j);
};
template <typename T>
bool priority_queue_shift_down(PriorityQueue<T> *pq, isize i0, isize n) {
@gingerBill
gingerBill / cel.odin
Last active November 20, 2017 22:49
CEL 2017-11-20
import "core:fmt.odin"
import "core:strconv.odin"
import "core:os.odin"
import "token.odin"
Token :: #alias token.Token;
Tokenizer :: #alias token.Tokenizer;
Array :: []Value;
@gingerBill
gingerBill / cel.odin
Last active November 22, 2017 08:10
CEL 2017-11-21
import "core:fmt.odin"
import "core:strconv.odin"
import "core:os.odin"
import "core:raw.odin"
import "token.odin"
Token :: #alias token.Token;
Tokenizer :: #alias token.Tokenizer;
@gingerBill
gingerBill / cel.odin
Created November 26, 2017 21:09
CEL 2017-11-26
import "core:fmt.odin"
import "core:strconv.odin"
import "core:os.odin"
import "core:raw.odin"
import "token.odin"
sample := `
x = 123;
y = 321.456;
z = x * (y - 1) / 2;
@gingerBill
gingerBill / the_library_problem.md
Last active July 14, 2025 07:19
The Library Problem

The Library Problem

General overview of the library problem.

Note: The terms library, module, and package are used interchangeably. Note: This document is subject to extension and modification

Implicit Assumptions:

  • It must be in keeping with the general language's design and philosophy
@gingerBill
gingerBill / odin-checklist.txt
Created February 11, 2019 12:08
Odin Checklist
Programming Language Checklist
by Colin McMillen, Jason Reed, and Elly Jones.
Odin language
[x] - yes
[~] - maybe
[?] - unknown
[text] specific answer