Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design question: Semicolons and import statements #192

Open
200sc opened this issue Feb 11, 2022 · 2 comments
Open

Design question: Semicolons and import statements #192

200sc opened this issue Feb 11, 2022 · 2 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@200sc
Copy link

200sc commented Feb 11, 2022

I was surprised when writing some bebop schemas that:

import "./example.bop";

struct Test {
    string Field;
}

... did not compile -- Expected Enum or Struct or Message or Union or Service, but found ';' of kind Semicolon.

And

import "./example.bop"

struct Test {
    string Field
}

Also did not compile -- Expected Semicolon, but found '}' of kind CloseBrace

The rules are, in one way, consistent -- top level definitions do not use semicolons and field definitions do use semicolons -- but why care? Why enforce the use of semicolons at all? It's been demonstrated by compilers in the past (Javascript + Typescript)(Go) that you can remove the need for semicolons as above entirely by injecting a semicolon if they are required and not provided.

An additional point of inconsistency: based on the theoretical rule I stated above, this should compile, as it is a top level statement:

const bool boolconst = true

But we get: Expected Semicolon, but found '' of kind EndOfFile

Were bebop to remove the need for semicolons but still support their presence, it would be a backwards compatible change, and formatters could automatically remove all of them (or place them where they are allowed, if that's your preferred style).

@lynn lynn added the bug Something isn't working label Feb 11, 2022
@mattiekat
Copy link
Contributor

@lynn I don't think this is technically a bug, but I do agree with @200sc, when I started writing bebop for the first time the semicolons confused me a bit. I could see making them optional since (correct me if I am wrong) there is no case where we actually need it.

@lynn lynn added the enhancement New feature or request label Feb 11, 2022
@andrewmd5
Copy link
Contributor

This is up next on my TODO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants