gc icon indicating copy to clipboard operation
gc copied to clipboard

Use `open` instead of `final` in the text format

Open bvisness opened this issue 2 years ago • 6 comments

Addresses discussion from #333. With this patch, the keyword final in subtypes has been replaced with the keyword open:

(type $s1 (sub (struct)))                       ;; final with no super types
(type $s2 (sub open (struct)))                  ;; non-final with no super types
(type $s3 (sub $s2 (struct (field i32))))       ;; final with one super type
(type $s4 (sub open $s2 (struct (field i32))))  ;; non-final with one super type

(type $s5 (struct))                             ;; equivalent to $s1 (final)

This avoids a confusing flip-flopping behavior where a seemingly-unnecessary empty sub was commonly used to make types non-final. An empty sub is now equivalent to no sub, making the abbreviation more obvious.

This patch is currently quite minimal, and only modifies enough of the spec and interpreter to support open in the text format. The word final is otherwise used throughout the spec and interpreter. If we would rather use the word open everywhere, I'd be happy to update the rest of the spec and interpreter to match.

bvisness avatar Jul 28 '23 21:07 bvisness

I would support having both sub open and sub final. That seems strictly clearer, although slightly more verbose. It's also useful to still have the "final" language for non-open types.

@bvisness, will you have time to work on this more today and Monday? If not, I can help out.

tlively avatar Sep 08 '23 16:09 tlively

@rossberg, would it suffice to add sub open just to the text format and keep final? in the abstract syntax, or would you want to change the abstract syntax to have final | open as well?

tlively avatar Sep 09 '23 01:09 tlively

I think we should keep them consistent. It actually simplifies some formulations as well when we have a named phrase like ext ::= FINAL | OPEN, because then ext can be used as a metavariable instead of clumsy FINAL?.

rossberg avatar Sep 09 '23 16:09 rossberg

@rossberg, would you be able to work on completing this change? If not, I will take a stab at it in the morning pacific time.

tlively avatar Sep 11 '23 04:09 tlively

@tlively, I can try, but I can't promise anything — I'm on an a flight Odyssee right now after I was dumped from my flight back to Europe yesterday. Hence my bigger concern is that I even make it back in time for the meeting tomorrow. ;)

rossberg avatar Sep 11 '23 12:09 rossberg

Apologies for my absence. I can resume work on this tomorrow if it's not already done.

bvisness avatar Sep 11 '23 19:09 bvisness