November 05, 2015 bearophile is back! :) was: Re: conver BigInt to string | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On 11/05/2015 09:40 AM, bearophile wrote:
> Bye,
> bearophile
Were you immersed in another language? Rust?
Ali
|
November 05, 2015 Re: bearophile is back! :) was: Re: conver BigInt to string | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Thursday, 5 November 2015 at 19:30:02 UTC, Ali Çehreli wrote:
> On 11/05/2015 09:40 AM, bearophile wrote:
>
>> Bye,
>> bearophile
>
> Were you immersed in another language? Rust?
>
> Ali
His D doesn't seem to be Rusty though!
|
November 05, 2015 Re: bearophile is back! :) was: Re: conver BigInt to string | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris | On 11/05/2015 11:35 AM, Chris wrote:
> On Thursday, 5 November 2015 at 19:30:02 UTC, Ali Çehreli wrote:
>> On 11/05/2015 09:40 AM, bearophile wrote:
>>
>>> Bye,
>>> bearophile
>>
>> Were you immersed in another language? Rust?
>>
>> Ali
>
> His D doesn't seem to be Rusty though!
Good one! ;) I'm really happy that he is still around.
Ali
|
November 05, 2015 Re: bearophile is back! :) was: Re: conver BigInt to string | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Thursday, 5 November 2015 at 19:38:23 UTC, Ali Çehreli wrote:
>
> Good one! ;) I'm really happy that he is still around.
>
> Ali
So am I! The more, the merrier!
|
November 05, 2015 Re: conver BigInt to string | ||||
---|---|---|---|---|
| ||||
Posted in reply to Meta | On Thursday, 5 November 2015 at 16:45:10 UTC, Meta wrote:
> The second issue is that using .sort instead of .sort() (note the parentheses) calls the built-in sort instead of std.algorithm.sort, which is strongly discouraged. You should always use std.algorithm.sort over the built-in sort, which you can do just by appending those parentheses.
Whoa whoa whoa... This is the first time I've heard about this difference, and I've used .sort plenty of times... That seems like really, REALLY bad design, especially considering the language allows functions to be called without parentheses. I thought I was using std.algorithm's version the whole time.
What's the difference between the implementations of arrays' .sort property and std.algorithm.sort()? And does sort() throw out that "unable to deduce function argument" error for a character array of all things?
|
November 05, 2015 Re: conver BigInt to string | ||||
---|---|---|---|---|
| ||||
Posted in reply to TheGag96 | On Thursday, 5 November 2015 at 20:45:45 UTC, TheGag96 wrote: > Whoa whoa whoa... This is the first time I've heard about this difference, and I've used .sort plenty of times... That seems like really, REALLY bad design, especially considering the language allows functions to be called without parentheses. I thought I was using std.algorithm's version the whole time. It's a legacy issue that will hopefully be fixed someday. The issue is that ever since D1, arrays have had a .sort property that uses a built-in sorting function. The compiler will only recognize it as the std.algorithm version of sort if you use parentheses. > What's the difference between the implementations of arrays' .sort property and std.algorithm.sort()? And does sort() throw out that "unable to deduce function argument" error for a character array of all things? The built-in sort is buggy and slow and should never be used. As far as I know it does not produce errors of its own, so any error messages you see like that are coming from the std.algorithm sort. |
November 06, 2015 Re: conver BigInt to string | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Thursday, 5 November 2015 at 17:40:12 UTC, bearophile wrote:
> Namal:
>
>> Hello I am trying to convert BigInt to string like that while trying to sort it:
>
> void main() {
> import std.stdio, std.algorithm, std.conv, std.bigint, std.string;
>
> auto n = 17.BigInt ^^ 179;
> n.text.dup.representation.sort().release.assumeUTF.writeln;
> }
>
> Bye,
> bearophile
can I import libraries anywhere? Is this the proper way to do so?
|
November 06, 2015 Re: conver BigInt to string | ||||
---|---|---|---|---|
| ||||
Posted in reply to Namal | On Friday, 6 November 2015 at 10:00:23 UTC, Namal wrote:
> On Thursday, 5 November 2015 at 17:40:12 UTC, bearophile wrote:
>> Namal:
>>
>>> Hello I am trying to convert BigInt to string like that while trying to sort it:
>>
>> void main() {
>> import std.stdio, std.algorithm, std.conv, std.bigint, std.string;
>>
>> auto n = 17.BigInt ^^ 179;
>> n.text.dup.representation.sort().release.assumeUTF.writeln;
>> }
>>
>> Bye,
>> bearophile
>
> can I import libraries anywhere? Is this the proper way to do so?
You can, and some say you should. The thing is, if you use templates and import the necessary libraries within the template then the import occurs only if the template is instantiated which can be a big gain. Phobos makes great use of this technique for example.
|
Copyright © 1999-2021 by the D Language Foundation