aya-dev icon indicating copy to clipboard operation
aya-dev copied to clipboard

Question: allow overwriting fields that have default values?

Open imkiva opened this issue 4 years ago • 3 comments

fields that have default values are called FieldImpl in Aya source code. Are we going to allow overwriting the field impls? for example

\struct Cross : \Set
  | base : Nat
  | plus1 => suc base

The plus1 has a value which depends on base. So we can use this syntax to create Cross:

\new Cross { | base => zero }

where the plus1 should be suc zero

Should we allow this new operation ?

\new Cross { | base => zero | plus1 => zero }

I think we should because we will have extends in the future which also overwrites fields. What do you think?

imkiva avatar Mar 17 '21 12:03 imkiva

I just wanna point out one thing -- the order of overwriting should matter. Say, if you wanna overwrite a field, you gotta override it before new fields got added.

ice1000 avatar Mar 17 '21 14:03 ice1000

I think we should establish the dependency between fields and instantiate by that order.

re-xyr avatar Mar 20 '21 09:03 re-xyr

Unchangeable fields are semantically identical to mere function definitons so we won't need that (or we have that as a sugar).

re-xyr avatar Mar 20 '21 09:03 re-xyr