BenjaminSchaaf / sbnf

A BNF-style language for writing sublime-syntax files
MIT License
58 stars 6 forks source link

kebab-case is less usable than snake_case #28

Closed mitranim closed 3 years ago

mitranim commented 3 years ago

I have usability complaints about kebab identifiers.

First off:

Now for the ergonomic annoyance. Excerpt from the code:

constraint : kw['constraint'] name-constraint ;

name-constraint{entity.name.constraint} : ident-any ;

create-domain : kw['domain'] name-type kw['as'] storage-type constraint? ;

alter-table-action-add :
  NONE
  | (kw['constraint'] if-not-exists? name-constraint (kw['not'] kw['valid'])?)
  | (kw['column']?    if-not-exists? declare-column)
;

alter-table-action-rename :
  NONE
  | (kw['to']         name-table)
  | (kw['constraint'] ident-other kw['to'] name-constraint)
  | (kw['column']?    ident-other kw['to'] name-column)
;

Addendum: this particular case is solvable by using dots in names: name.constraint. In this case, that's a better naming scheme anyway. But this is not viable in all cases, and the dot may end up repurposed for namespacing when imports are added. The compiler doesn't let me do that.

mitranim commented 3 years ago

This also annoys me in YAML syntaxes. It's too late to fix that in YAML, but not too late for SBNF.

BenjaminSchaaf commented 3 years ago

loads of false positives like name-constraint because according to \b\b, hyphen is a word delimiter.

That's an issue in the core of ST, see: https://github.com/sublimehq/sublime_text/issues/4901. I'm going to close this as kebab-case is the accepted standard for syntax definitions (which are affected by the same issue) and it's clearly easier to write.

mitranim commented 3 years ago

I agree this should be fixed in the core to support syntaxes already committed to kebab-case. But I don't think it fully absolves kebab-case. Users may want to use regex search with \b\b for refactoring. Admittedly that's an edge case, but it shows that this word break problem "leaks" into many places.

BenjaminSchaaf commented 3 years ago

The core fix would make all search regexes use the correct word boundaries.