-
Notifications
You must be signed in to change notification settings - Fork 24
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
Ability to cast int/double <-> string #78
Comments
Not having the ability to have more than one method with the same name across different types is obviously a silly limitation. |
luispedro
added a commit
that referenced
this issue
Dec 4, 2020
These are very simple. The choice of API was to allow for a default on empty, but to error on anything else that cannot be parsed This patch also adds the ``__assert`` function for internal use and generalizes some of the transformation mechanics closes #78
luispedro
added a commit
that referenced
this issue
Jan 25, 2021
An accummulation of improvements rather than a big new feature is what triggers the new release. Full `ChangeLog`: - Better error message if the user attempts to use the non-existent <\> operator (suggest </>) - Add min-ngless-version field for modules - Add early check that block assignments are always to block variables - Use ZStd compression for temporary files from preprocess() - Correctly handle subpaths in samples for collect (fixes #141) - Add to_string() to int and double types (partially fixes #78 & fixes #81) - Add read_int() and read_double() functions (fixes #78)
luispedro
added a commit
that referenced
this issue
Jan 26, 2021
An accummulation of improvements rather than a big new feature is what triggers the new release. Full `ChangeLog`: - Validate count() headers on --validate-only - Better error message if the user attempts to use the non-existent <\> operator (suggest </>) - Add min-ngless-version field for modules - Add early check that block assignments are always to block variables - Use ZStd compression for temporary files from preprocess() - Correctly handle subpaths in samples for collect (fixes #141) - Add to_string() to int and double types (partially fixes #78 & fixes #81) - Add read_int() and read_double() functions (fixes #78)
luispedro
added a commit
that referenced
this issue
Jan 26, 2021
An accummulation of improvements rather than a big new feature is what triggers the new release. Full `ChangeLog`: - Validate count() headers on --validate-only - Better error message if the user attempts to use the non-existent <\> operator (suggest </>) - Add min-ngless-version field for modules - Add early check that block assignments are always to block variables - Use ZStd compression for temporary files from preprocess() - Correctly handle subpaths in samples for collect (fixes #141) - Add to_string() to int and double types (partially fixes #78 & fixes #81) - Add read_int() and read_double() functions (fixes #78)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Motivation:
fails to typecheck since
ARGV[]
are strings.and similarly:
Will either fail on the first if cutoff is a string or the second if an integer/double.
One possibility I explored was to add a method
number.to_string()
to all numeric types but I hit a limitation in that different types cannot have a method with the same name. The code compiles but when executed NGLess gives a confusing error (paraphrasing)method 'to_string' doesn't exist, did you mean 'to_string'?
So I ended up with:
Alternatively I also considered a function
to_string(variable)
but ran into similar limitations in that different functions are necessary to handle different types.The above code doesn't address the
ARGV[] -> int/double
use-case. I'd probably go forstring.to_int()
andstring.to_double()
and error if the transformation isn't possible.Any suggestions on better ways to address the need for casting variables?
The text was updated successfully, but these errors were encountered: