melt-umn / silver

An attribute grammar-based programming language for composable language extensions
http://melt.cs.umn.edu/silver/
GNU Lesser General Public License v3.0
57 stars 7 forks source link

Abbreviating the Decorated type syntax #797

Closed krame505 closed 10 months ago

krame505 commented 1 year ago

I've been increasingly realizing that Silver's Decorated type syntax is much too verbose, especially with unique reference types showing up frequently in production signatures and dispatch attribute types; this is making error messages pretty hard to read.

As a part of #751, I'm thinking we should change the syntax to #Expr for Decorated Expr, #!Expr with {} for Decorated! Expr with {}, etc. Also with the #751 changes, the "real" decorated type constructor will be Dec :: (Uniqueness -> InhSet -> * -> *), so this change would just be new syntactic sugar.

This doesn't have to be a breaking change, as we can leave Decorated as a (deprecated?) alternative, but doing a big find/replace would be pretty easy.

remexre commented 1 year ago

Not sure how I feel about #! in particular, with that being shebang :laughing:

Sounds good overall, though the downside of punctuation is gonna be that it's hard to search for. (#, in particular, seems to be an ungoogleable character.) Maybe good enough error messages might help?

krame505 commented 1 year ago

Hmm, didn't thing about any potential confusion with shebang. But at least this shouldn't be showing up at the start of any files?

Any better ideas for shorthand for unique references?

krame505 commented 1 year ago

Maybe a better char for decorated types is &, which is used for reference types in C++. That would give &Expr, &!Expr, &Expr with {env}, &!Expr with {env} for example.

unironically commented 11 months ago

I am o-k with & and am not a fan of # for the reason Nathan pointed out. Can't say I love & either, but can't think of anything better TBH.

krame505 commented 11 months ago

The consensus was to use the above prefix & and &! notation for references. The existing Decorated keyword can stay for now, with possibly a deprecated warning.

krame505 commented 10 months ago

Abandoning this for now with #812, since we are doing away with unique references, and ordinary references will not frequently appear in production signatures.