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

Add named constants (enums) to Small Basic #139

Open
McSherry opened this issue Jul 27, 2020 · 0 comments
Open

Add named constants (enums) to Small Basic #139

McSherry opened this issue Jul 27, 2020 · 0 comments
Labels
pri/3 Priority 3 - Something that can be done in SBO 1.1 or later type/compiler Issues related to the compiler/language services type/infrastructure Infrastructure issues/enhancement to the codebase.

Comments

@McSherry
Copy link
Member

This issue stems from a Yammer discussion.

At the moment, properties such as TextWindow.ForegroundColor take a string colour name. This is a poor experience for learners as IntelliSense cannot currently suggest correct values. This occurs at various points in Small Basic's API.

To fix this, Small Basic should support named constants (i.e. enum values) so that the compiler has a defined set of values it can suggest. This would be best implemented building over the existing enum infrastructure used by C# etc.

To improve user experience, it may be worth considering:

  • Allowing the declaring type to be omitted (so e.g. ConsoleColor.Cyan could be written as Cyan alone in a context that accepts a named constant value)
  • Warning if a named constant and variable name clash, but only if a named constant is used (so that programs that don't use the named constants don't have variable names clobbered)
  • Including a new Small Basic object to turn strings into named constant values
@McSherry McSherry added type/infrastructure Infrastructure issues/enhancement to the codebase. type/compiler Issues related to the compiler/language services labels Jul 27, 2020
@Caseysch Caseysch added the pri/3 Priority 3 - Something that can be done in SBO 1.1 or later label Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pri/3 Priority 3 - Something that can be done in SBO 1.1 or later type/compiler Issues related to the compiler/language services type/infrastructure Infrastructure issues/enhancement to the codebase.
Projects
None yet
Development

No branches or pull requests

2 participants