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

(all) Support int literals in addition to doubles #40

Merged
merged 1 commit into from
May 10, 2020

Conversation

perlun
Copy link
Collaborator

@perlun perlun commented May 10, 2020

I decided to use dynamic to implement this for now. It's the simplest way to not having to handle all various combinations of integer types manually.

Doing it like this made it quite easy in the end, it felt impossible just some day ago. :)

As for how to handle integer literals, I decided to with the same rules are C# applies for now.

If the literal has no suffix, its type is the first of the following
types in which its value can be represented: int, uint, long, ulong.

(quoting https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types)

The suffix stuff is not supported at the moment; we provide no way to explicitly specify neither ulong, uint or double. This will probably have to fixed at some point, but just supporting various integer types and double is probably a good start. (We could do the same for the floating point values btw, to coerce them into float if
the encountered floating point literal is small enough.)

I decided to use `dynamic` to implement this for now. It's the simplest
way to not having to handle all various combinations of integer types
manually.

Doing it like this made it quite easy in the end, it felt impossible
just some day ago. :)

As for how to handle integer literals, I decided to with the same rules
are C# applies for now.

> If the literal has no suffix, its type is the first of the following
> types in which its value can be represented: int, uint, long, ulong.

(quoting https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types)

The suffix stuff is not supported at the moment; we provide no way to
explicitly specify neither `ulong`, `uint` or `double`. This will
probably have to fixed at some point, but just supporting various
integer types and `double` is probably a good start. (We could do the
same for the floating point values btw, to coerce them into `float` if
the encountered floating point literal is small enough.)
@perlun perlun added the enhancement New feature or request label May 10, 2020
@perlun perlun merged commit a9e1a3d into master May 10, 2020
@perlun perlun deleted the fix/supprt-integer-literals branch May 10, 2020 21:03
@perlun perlun added this to the 0.1.0 milestone Feb 18, 2022
@perlun perlun added the language Language features (or bugs) label Feb 26, 2022
@perlun perlun changed the title (all) Support integer literals, not just doubles (all) Support int literals in addition to doubles Feb 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request language Language features (or bugs)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant