Skip to content

dynamic function arguments or generic system #44

@MSMissing

Description

@MSMissing

Since functions are basically macros, it would make sense to have a data type for function arguments that can be any type that works with the code.

fn sum(dyn stack, i16 r) {
  r = 0;
  cell x = 0;
  while stack.len {
    pop(stack, x);
    add(r, x);
  }
}

Or, there could be a type abstraction system (would fit with #43)

generic stack {
  cell len,
  fn push(),
  fn push_d(),
  fn unshift(),
  fn unshift_d()
  fn pop(),
  fn shift()
}

fn sum(stack s, i16 r) {
  r = 0;
  cell x = 0;
  while s.len {
    s.pop(x);
    r.add(x);
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions