Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Leonard Ritter
@lritter@mastodon.gamedev.place  ·  activity timestamp 5 days ago

here's a first design. i picked ?= intuitively but then found that it is close in meaning to the Nullish coalescing assignment operator ??= in javascript.

#devlog

draw_rect = macro
    # parameter name with default value: x ?= ...
        * empty right hand side evaluates to undefined
        * parameter order is order of declaration
    dep ?=
    x0 ?= 50.0
    # hidden temporaries are prefixed with `_`, otherwise public
    _x0 = ftos x0 4
    y0 ?= 50.0
    _y0 = ftos y0 4
    x1 ?= 100.0
    _x1 = ftos x1 4
    y1 ?= 100.0
    _y1 = ftos y1 4
    dep -> do
        draw_line _x0 _y0 _x1 _y0
        draw_line _x1 _y0 _x1 _y1
        draw_line _x1 _y1 _x0 _y1
        draw_line _x0 _y1 _x0 _y0
    # if a `return` name is present, the callsite evaluates to this value
    return = dep
draw_rect = macro # parameter name with default value: x ?= ... * empty right hand side evaluates to undefined * parameter order is order of declaration dep ?= x0 ?= 50.0 # hidden temporaries are prefixed with `_`, otherwise public _x0 = ftos x0 4 y0 ?= 50.0 _y0 = ftos y0 4 x1 ?= 100.0 _x1 = ftos x1 4 y1 ?= 100.0 _y1 = ftos y1 4 dep -> do draw_line _x0 _y0 _x1 _y0 draw_line _x1 _y0 _x1 _y1 draw_line _x1 _y1 _x0 _y1 draw_line _x0 _y1 _x0 _y0 # if a `return` name is present, the callsite evaluates to this value return = dep
draw_rect = macro # parameter name with default value: x ?= ... * empty right hand side evaluates to undefined * parameter order is order of declaration dep ?= x0 ?= 50.0 # hidden temporaries are prefixed with `_`, otherwise public _x0 = ftos x0 4 y0 ?= 50.0 _y0 = ftos y0 4 x1 ?= 100.0 _x1 = ftos x1 4 y1 ?= 100.0 _y1 = ftos y1 4 dep -> do draw_line _x0 _y0 _x1 _y0 draw_line _x1 _y0 _x1 _y1 draw_line _x1 _y1 _x0 _y1 draw_line _x0 _y1 _x0 _y0 # if a `return` name is present, the callsite evaluates to this value return = dep
  • Copy link
  • Flag this post
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.2.6 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct