Skip to content

Instantly share code, notes, and snippets.

@uucidl
Created February 20, 2019 10:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uucidl/83756cce8f2119cbee726eb7e9b285c9 to your computer and use it in GitHub Desktop.
Save uucidl/83756cce8f2119cbee726eb7e9b285c9 to your computer and use it in GitHub Desktop.
bitwise-notes.md

Bitwise Day 62: Indexed Arrays

Per worked 20h since Day 61.

How do we get a good story for dynamic arrays? What we called stretchy bufs (buf_... API)

Added many new intrinsics to gen_intrinsic:

  • apush, kadd, kdget, kdel
  • hget, hdel

Which perform some syntactic sugar, and better typechecking on top of existing bare ion code for these functions.

Notes that argument 2 checking for va_arg should be and is being done by the type checker now. (How? My signature uses void argument there, so I don't know how it's done. Maybe void* and finding the original type of the expression?)

New declaration note is @inline, which replaces c preprocessor macros, and allows straight inlining in the resulting code.

body of acat, which is @foreign is resolved and used to generate foreign code. it being intrinsic means it can use compiler support to check the arguments.

I.e. after entering the intrinsic space where type checking is done at the boundary, we're in a decayed, type-erased world where everything is done via void* and explicit sizes.

Call-By-Name adhoc done in intrinsic.

Another new feature are tuples. (like anonymous structs)

New feature:

offset based access to aggregates. I.e.

struct Foo { a: int; b: char; }

foo: Foo; foo[0] -> int foo[1] -> char

Maps

goals: no issues with polymorphism goals: no adhoc casting (for usage code)

Given polymorphic support for stretchy, dynamic arrays.

"What if the representation of an associative set (collection on which we can do lookups based on values) was a dynamic array" <=> from the perspective of iterations, you can iterate over the dynamic array. Mutation is done via special intrinsics. <=> I.e. the type of the associative set is "T*"

Guarantees:

  • "Insertion order"
  • "swap deletion"

a map is an array of {key, value}*

maps are like sets expect only a part is used to do the associative lookup Per uses tuples for it.

<=> Some prefix of bits are used for the lookup

Indexing is decoupled. One could use adaptative indexing.

Indexing over linear arrays

@timestamp: 1:04:00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment