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

Parser defect: number should take priority over abbreviation #25

Open
tyomitch opened this issue Dec 27, 2020 · 1 comment
Open

Parser defect: number should take priority over abbreviation #25

tyomitch opened this issue Dec 27, 2020 · 1 comment

Comments

@tyomitch
Copy link

The reference says:

When the parser encounters a sequence of characters which could represent a symbol, or could represent a number or abbreviation, then the number or abbreviation will take priority.

Currently this means that numbers starting with a period are parsed as meth-name, so e.g. (let decay-rate .05) fails with an "error: unbound symbol 'meth-name'"
This is never helpful, as 05 is not a valid method name.

@fleabitdev
Copy link
Owner

The parser is working as specified. We imitate Rust's syntax for numbers and strings wherever possible, and in Rust, .05 isn't a valid floating-point literal.

Leaving this issue open, because you've raised two good points:

  • We should definitely try to provide a better error message for incorrect use of the meth-name abbreviation.

  • We could consider adopting a more relaxed syntax for floats in GameLisp, compared to Rust. There are a number of pros and cons. It would be more intuitive and convenient, but less consistent, and more difficult to document. It would require us to add a special-case to the parser, to disable the meth-name abbreviation for numbers. It would prevent us from adding any syntax like .0 which imitates Rust's tuple-indexing syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants