Skip to content

Comment on Doo: A Simple, Fast Programming Language Built on Rust and LLVMparent

Comments

So, what if I want to pass a value of a primitive type by-reference? How the equivalent code for the following C++ example looks like?

  void Foo( int& x )
  {
      x= 123;
  }
  
  void Bar()
  {
      int x= 0;
      Foo(x);
  }

Doolang currently does not allow you to mutate a primitive variable from another function.

Only support this as of now

fn Foo(x: Int) { x = 123; // Only modifies Foo's local copy print("inside Foo", x); // Print 123 } fn main() { let x: Int = 0; Foo(x); // x is still 0 here after Foo returns print("out x", x); // Print 0 }

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.