savi-lang / savi

A fast language for programmers who are passionate about their craft.
BSD 3-Clause "New" or "Revised" License
154 stars 12 forks source link

A `let` property cannot be reassigned after all fields have been initialized #391

Open mneumann opened 1 year ago

mneumann commented 1 year ago
:struct A
  :let field U8: 5

  :new (@field)

I'd assume that it is possible assign a value to a let field in a constructor and if not, the :let declarators default value is taken.

jemc commented 1 year ago

I agree this would be nice to have, but it will make the completeness analysis significantly more complicated, I think.

mneumann commented 1 year ago

I see. So we should better raise an error at compile time in these situation. IIRC, there is already an open issue for that.

mneumann commented 1 year ago

Sorry, mixing things up. Well, :let default values as of now are more or less constant as you cannot change them.

jemc commented 1 year ago

Right, I agree it would be more useful if default values for :let could be overridden by explicit values in a constructor, and right now, that is not possible.