Skip to content

Latest commit

 

History

History
75 lines (57 loc) · 1.65 KB

keywords.md

File metadata and controls

75 lines (57 loc) · 1.65 KB

Keywords

  1. @name or @var
  2. @when
  3. @loop
  4. @fn
  5. @type
  6. @impl
  7. @next * replaces 'continue': go to next loop iteration.
  8. @fall (fallthrough) * may not be needed because of pattern matching
  9. @break * replaces 'break': break from current loop.
  10. @yield * replaces 'yield': yield from current block.
  11. @return * replaces 'return': return from current block.
  • 'Done' wraps a value while indicating we return a value and are done.
  • 'Some' wraps a value while indicating we yield a value and keep going.
  • 'None' wraps no value while indicating we keep going.
  1. @return
  2. @panic
  3. @class
  4. @struct / @record / @value
  5. @trait
  6. @union
  7. @alias

Module keywords

  1. @pkg \ Package (project)
  2. @mod \ Module (folder)
  3. @cmp \ Component (file)
  4. @import
  5. @export

Named Operators

  • @and &&
  • @or ||
  • @not !
  • @least >=
  • @most <=
  • @above >
  • @below <
  • @between start < x < end @x @is @between 3 @and 5 . @x @between 3..5
  • @within start <= x <= end
  • @outside x < val < x

Annotations

  • @@co // TODO: coroutines. * may be a std library function
  • @@mut // TODO: mutability keywords?
  • @@imm // TODO: mutability keywords?
  • @@defer // TODO: implement
  • @select //TODO: coroutine select in std library

Execution time annotation

  • @@compile (execute at compile time)
  • @@execute (compile and execute at runtime)
  • @@analyze (interpret and execute at runtime)

Keywords vs Builtins

Keywords start with the @ sigil. builtin functions like if come from the si namespace.

EXAMPLE

@let age:u32 = 0x21;

&si::if age \at_least 18 \and hasPaid $then 'welcome!' $else 'halt!!!';

if age >= 18 && hasPaid