On Saturday, 13 May 2017 at 09:51:40 UTC, k-five wrote:
On Saturday, 13 May 2017 at 09:05:17 UTC, Jonathan M Davis
But obviously, to know what's actually happening with your
code, you're going to have to profile and benchmark it -
Can you please give a link or page or something to read about
On Saturday, 13 May 2017 at 09:05:17 UTC, Jonathan M Davis wrote:
For the most part, when parsing a string, std.conv.to's
approach of just parsing the string and throwing an exception
if/when it fails is the most efficient, because it's only going
to parse the string once, whereas calling a
On Saturday, 13 May 2017 at 08:50:20 UTC, k-five wrote:
Way arguing when a simple code can clarify the subject? right?
If am not clear so consider me as an stupid man, no problem at
all.
but CAN you please solve it for me?
import std.stdio: writeln;
import std.conv:to;
void
On Friday, May 12, 2017 10:42:18 H. S. Teoh via Digitalmars-d-learn wrote:
> On Fri, May 12, 2017 at 12:47:04PM +0200, ag0aep6g via Digitalmars-d-learn
wrote:
> > On 05/12/2017 10:32 AM, k-five wrote:
> > > Interesting! I was worried about performance and for that I did not
> > > want to use
On Saturday, 13 May 2017 at 02:40:17 UTC, Mike B Johnson wrote:
You are not making a lot of sense:
1. Exception do bubble up, so you don't need to "handle"
exceptions at the call site if you don't want to. The whole
point of exceptions is do effectively do what you want.
2. You say that
On Thursday, 11 May 2017 at 16:07:22 UTC, k-five wrote:
On Wednesday, 10 May 2017 at 21:19:21 UTC, Stanislav Blinov
wrote:
On Wednesday, 10 May 2017 at 15:35:24 UTC, k-five wrote:
On Wednesday, 10 May 2017 at 14:27:46 UTC, Stanislav Blinov
On Fri, May 12, 2017 at 12:47:04PM +0200, ag0aep6g via Digitalmars-d-learn
wrote:
> On 05/12/2017 10:32 AM, k-five wrote:
> > Interesting! I was worried about performance and for that I did not
> > want to use try-catch.
> > So (isNumberic) is a good solution.
> >
On 05/12/2017 10:32 AM, k-five wrote:
Interesting! I was worried about performance and for that I did not want
to use try-catch.
So (isNumberic) is a good solution.
http://dlang.org/phobos/std_traits.html#isNumeric
If you're doing this for speed, you better be benchmarking. Exceptions
are
On Friday, 12 May 2017 at 09:03:39 UTC, Jonathan M Davis wrote:
That's the wrong isNumeric. Unfortunately, both std.string and
std.traits have an isNumeric. std.traits.isNumeric is an
eponymous template that tests whether a type is an integral or
floating point type, whereas
On Friday, May 12, 2017 08:32:03 k-five via Digitalmars-d-learn wrote:
> On Thursday, 11 May 2017 at 19:59:55 UTC, Jordan Wilson wrote:
> > On Thursday, 11 May 2017 at 18:07:47 UTC, H. S. Teoh wrote:
> >> On Thu, May 11, 2017 at 05:55:03PM +, k-five via
> >>
> >> Digitalmars-d-learn wrote:
>
On Friday, 12 May 2017 at 08:32:03 UTC, k-five wrote:
On Thursday, 11 May 2017 at 19:59:55 UTC, Jordan Wilson wrote:
On Thursday, 11 May 2017 at 18:07:47 UTC, H. S. Teoh wrote:
On Thu, May 11, 2017 at 05:55:03PM +, k-five via
Digitalmars-d-learn wrote:
On Thursday, 11 May 2017 at 17:18:37
On Thursday, 11 May 2017 at 19:59:55 UTC, Jordan Wilson wrote:
On Thursday, 11 May 2017 at 18:07:47 UTC, H. S. Teoh wrote:
On Thu, May 11, 2017 at 05:55:03PM +, k-five via
Digitalmars-d-learn wrote:
On Thursday, 11 May 2017 at 17:18:37 UTC, crimaniak wrote:
> On Wednesday, 10 May 2017 at
On Thursday, 11 May 2017 at 18:07:47 UTC, H. S. Teoh wrote:
On Thu, May 11, 2017 at 05:55:03PM +, k-five via
Digitalmars-d-learn wrote:
On Thursday, 11 May 2017 at 17:18:37 UTC, crimaniak wrote:
> On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote:
On Thu, May 11, 2017 at 05:55:03PM +, k-five via Digitalmars-d-learn wrote:
> On Thursday, 11 May 2017 at 17:18:37 UTC, crimaniak wrote:
> > On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote:
> -
> > try this:
> >
On Thursday, 11 May 2017 at 17:18:37 UTC, crimaniak wrote:
On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote:
-
try this:
https://dlang.org/phobos/std_exception.html#ifThrown
Worked. Thanks.
import std.stdio;
import std.conv:
On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote:
I have a line of code that uses "to" function in std.conv for a
purpose like:
int index = to!int( user_apply[ 4 ] ); // string to int
When the user_apply[ 4 ] has value, there is no problem; but
when it is empty: ""
it throws an
On Wednesday, 10 May 2017 at 21:44:32 UTC, Andrei Alexandrescu
wrote:
On 5/10/17 3:40 PM, k-five wrote:
---
I no need to handle that, so is there any way to prevent this
exception?
Use the "parse" family:
https://dlang.org/phobos/std_conv.html#parse -- Andrei
On Wednesday, 10 May 2017 at 21:19:21 UTC, Stanislav Blinov wrote:
On Wednesday, 10 May 2017 at 15:35:24 UTC, k-five wrote:
On Wednesday, 10 May 2017 at 14:27:46 UTC, Stanislav Blinov
---
I don't understand. If you don't want to take
On 05/10/2017 05:40 AM, k-five wrote:
> I have a line of code that uses "to" function in std.conv for a purpose
> like:
>
> int index = to!int( user_apply[ 4 ] ); // string to int
>
> When the user_apply[ 4 ] has value, there is no problem; but when it is
> empty: ""
> it throws an ConvException
On 5/10/17 3:40 PM, k-five wrote:
I have a line of code that uses "to" function in std.conv for a purpose
like:
int index = to!int( user_apply[ 4 ] ); // string to int
When the user_apply[ 4 ] has value, there is no problem; but when it is
empty: ""
it throws an ConvException exception and
On Wednesday, 10 May 2017 at 21:19:21 UTC, Stanislav Blinov wrote:
"nothrow" does not turn off exceptions, it simply forbids
throwing them in the enclosing scope (i.e. calling anything
that might throw is not allowed).
nothrow disallows the function scope to throw exceptions not
derived from
On Wednesday, 10 May 2017 at 15:35:24 UTC, k-five wrote:
On Wednesday, 10 May 2017 at 14:27:46 UTC, Stanislav Blinov
wrote:
On Wednesday, 10 May 2017 at 13:27:17 UTC, k-five wrote:
Thanks, but I know about what are you saying. The
user_apply[4] has so many possibilities and I cannot use
On Wednesday, 10 May 2017 at 14:27:46 UTC, Stanislav Blinov wrote:
On Wednesday, 10 May 2017 at 13:27:17 UTC, k-five wrote:
Thanks, but I know about what are you saying. The
user_apply[4] has so many possibilities and I cannot use
if-else
That doesn't sound right. Either you've already
On Wednesday, 10 May 2017 at 13:27:17 UTC, k-five wrote:
Thanks, but I know about what are you saying. The user_apply[4]
has so many possibilities and I cannot use if-else
That doesn't sound right. Either you've already handled all the
possible cases and thus expect the to! to not throw (can
On Wednesday, 10 May 2017 at 13:12:46 UTC, Ivan Kazmenko wrote:
On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote:
--
I assume that an empty string is a valid input then.
The question is, what value do you want `index` to have when
On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote:
I have a line of code that uses "to" function in std.conv for a
purpose like:
int index = to!int( user_apply[ 4 ] ); // string to int
When the user_apply[ 4 ] has value, there is no problem; but
when it is empty: ""
it throws an
On Wednesday, 10 May 2017 at 12:40:41 UTC, k-five wrote:
I have a line of code that uses "to" function in std.conv for a
purpose like:
int index = to!int( user_apply[ 4 ] ); // string to int
When the user_apply[ 4 ] has value, there is no problem; but
when it is empty: ""
it throws an
I have a line of code that uses "to" function in std.conv for a
purpose like:
int index = to!int( user_apply[ 4 ] ); // string to int
When the user_apply[ 4 ] has value, there is no problem; but when
it is empty: ""
it throws an ConvException exception and I want to avoid this
exception.
28 matches
Mail list logo