mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 05:39:17 +02:00
Keep track of notes for a potential future guide
This commit is contained in:
parent
86136a7185
commit
f7607e47d6
1 changed files with 14 additions and 0 deletions
14
docs/C-Interface-Notes.md
Normal file
14
docs/C-Interface-Notes.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
This file is the attempted start of a best practices guide for the C interface... not much more than notes at this point, though.
|
||||||
|
|
||||||
|
# Use built-in macros to create objects
|
||||||
|
|
||||||
|
It is best for application code to avoid assigning to internal structures (such as hdr) if we can help it, just in case any of that were to change in the future. For example, hdr.immutable is a recent addition. Also, the C code is compiled with optimizations so most likely the generated assembly will avoid a double-assignment:
|
||||||
|
|
||||||
|
alloca_pair(pl, ps, NULL);
|
||||||
|
// object pl = alloca(sizeof(pair_type));
|
||||||
|
// ((list) pl)->hdr.mark = gc_color_red;
|
||||||
|
// ((list) pl)->hdr.grayed = 0;
|
||||||
|
// ((list) pl)->hdr.immutable = 0;
|
||||||
|
// ((list) pl)->tag = pair_tag;
|
||||||
|
// ((list) pl)->pair_car = ps;
|
||||||
|
|
Loading…
Add table
Reference in a new issue