Comments (6)
IsInt
should really be named IsOfTypeInt
because I really mean it to test for type compatibility (straight python code translation) rather than to confirm that a value can be potentially treated as an integer.
So how about implementing IsInt
with Int32.TryParse()
the way you describe and redirect the current internal usages of IsInt
to a IsOfTypeInt
method? I wonder if AsInt
should not be revisited as well?
If IsInt
was directly implemented using Int32.TryParse()
the test LanguageAgnosticTests.Test_104
would be broken because "--speed=20"
would be wrongly be considered of type int
.
Regarding the constructor, ValueObject
is known to take arguments of type int
in the context of incremented flags as produced by:
Usage: prog [-vv]
from docopt.net.
Okay. I can propose a PR with something like that. But is there any value to having IsOfTypeInt
exposed to consumers of the library? Your description of it makes it sound like it is used only internally. If that's so, I'd make it internal
.
Relatedly, there is an IsString
property. This property is implemented like IsOfTypeString
. If we create IsInt
with this implementation, should it be permissible that something that has IsInt
= true
also have IsString
= true
? On the one hand, it can be used like a string. On the other hand, one would think these properties would be mutually exclusive. I can see a good argument for both sides.
from docopt.net.
Agreed, internal it should be. Sounds to me like IsOfTypeInt and IsOfTypeString should be mutually exclusive. Have a look at the Match method in LeafPattern.—
Sent from Mailbox for iPad
On Wed, Dec 18, 2013 at 6:02 PM, Kyle Peter Fritz
[email protected] wrote:
Okay. I can propose a PR with something like that. But is there any value to having
IsOfTypeInt
exposed to consumers of the library? Your description of it makes it sound like it is used only internally. If that's so, I'd make itinternal
.Relatedly, there is an
IsString
property. This property is implemented likeIsOfTypeString
. If we createIsInt
with this implementation, should it be permissible that something that hasIsInt
=true
also haveIsString
=true
? On the one hand, it can be used like a string. On the other hand, one would think these properties would be mutually exclusive. I can see a good argument for both sides.Reply to this email directly or view it on GitHub:
#5 (comment)
from docopt.net.
Yeah, clearly IsOfTypeInt
and IsOfTypeString
should be mutually exclusive. My question was regarding the behavior of the new public properties IsInt
and IsString
. Should they behave like "CanBeConvertedIntoInt
" and "CanBeConverteredIntoString
", in which case a integer would be true for both? Or should they behave mutually exclusively where an integer value is not considered a string?
from docopt.net.
Thanks for the PR @kyle-fritz-zocdoc!
I think the first interpretation (CanBeConvertedIntoInt
) makes sense as a general scenario and it would be consistent with properties like StringExtensions.IsInt. I do not see a scenario where a client needs to know if the value is stored as an int
.
I will push a release with your changes soon.
from docopt.net.
Fix released as part of 0.6.1.5.
from docopt.net.
Related Issues (20)
- Sync PR builds not occurring during CI on AppVeyor
- Argument that is both boolean and string (git exec-path option) HOT 1
- Assembly version is 0.0.0.0 HOT 1
- Source generator fails when arguments classes are named the same but belong to different namespaces
- Source generator fails with arguments classes in separate files
- Nested class using `[DocoptArguments]` fails to build
- Make entire code base null-safe
- Leading dot in generated hint name when project has no namespace
- Bad example or bug in new parser implementation? HOT 2
- Add MatchAsync to `IParser<T>.IResult` HOT 2
- Reinstalling docopt.net
- Code style errors can break building of user project
- Feature Request: Description in summary comments HOT 2
- Docopt not parsing when running with 'dotnet run' HOT 3
- IsNullOrEmpty on a command throws System.NullReferenceException
- spaces in filenames HOT 3
- Upgrade to netstandard2.0 HOT 1
- run naval_fate HOT 2
- condition to properly build the project and have it work correctly HOT 8
- T4 template doesn't run in "T4DocoptNetHostApp" HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docopt.net.