Skip to content

Instantly share code, notes, and snippets.

@paniq
Last active April 27, 2019 15:13
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 paniq/8de9fde641e0e3380e48d0010921e08b to your computer and use it in GitHub Desktop.
Save paniq/8de9fde641e0e3380e48d0010921e08b to your computer and use it in GitHub Desktop.
# normal form
label success
let success? =
label skip
if (('typeof struct-fields) == Nothing)
merge skip
let field = ('getarg struct-fields i)
let field = (field as type)
let elem =
try ('@ field 'Default)
except (err)
merge skip
merge success elem
static-assert (success? == false)
# default initializer
let ET = (sc_type_element_at cls i)
try
sc_prove `(ET)
except (err)
error
.. "field " (repr ET) " has no default initializer"
# proposed new built-in support for readahead form
if (('typeof struct-fields) == Nothing)
# we use goto instead of merge for these
goto skip false
let field = ('getarg struct-fields i)
let field = (field as type)
let elem =
try ('@ field 'Default)
except (err)
goto skip false
goto success elem
# define label at exit point
: skip (success?)
static-assert (success? == false)
# default initializer
let ET = (sc_type_element_at cls i)
try
sc_prove `(ET)
except (err)
error
.. "field " (repr ET) " has no default initializer"
# define label at exit point - this is the form without arguments
: success
# third proposed new built-in support for readahead form
# forward declaration
:: success
:: skip
if (('typeof struct-fields) == Nothing)
merge skip false
let field = ('getarg struct-fields i)
let field = (field as type)
let elem =
try ('@ field 'Default)
except (err)
merge skip false
merge success elem
# define label at exit point
skip :: success?
static-assert (success? == false)
# default initializer
let ET = (sc_type_element_at cls i)
try
sc_prove `(ET)
except (err)
error
.. "field " (repr ET) " has no default initializer"
# define label at exit point - this is the form without arguments
success ::
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment