Skip to content

Instantly share code, notes, and snippets.

@lsparrish
Created June 18, 2011 14:11
Show Gist options
  • Save lsparrish/1033126 to your computer and use it in GitHub Desktop.
Save lsparrish/1033126 to your computer and use it in GitHub Desktop.
chain: struct'
: { ( -n ) 0 ;
: field ( nn"-n ) over ` : .data ` + ` ; + ;
: } ( n"- ) ` : .data ` here ` swap ` allot ` constant ` ; ;
: clone ( a-a ) here swap 3 + @ allot ;
;chain
with struct'
{
2 field .bar
1 field .baz
} foo
&foo 3 + @ putn
here putn
foo test
here putn
@crcx
Copy link

crcx commented Jun 18, 2011

chain: struct'
  : {     (    -n ) 0 ;
  : field ( nn"-n ) over ` : .data  ` + ` ; + ;
  : }     (  n"-  ) [ here swap allot constant ] curry constant &.word reclass ;
  : clone ( a-a   ) here swap 1+ @ allot ;
;chain

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