On Thursday, 20 February 2014 at 18:33:02 UTC, Stanislav Blinov
wrote:
Note that you can create your own overload. Though it has to be
done "the long way", because dmd doesn't (yet?) allow
overloading templates imported from other modules:
Guess we will find out:
https://d.puremagic.com/issues
On Thursday, 20 February 2014 at 23:31:36 UTC, Mattdef wrote:
Hi
Why this code is 2 times longer in D then C# ?
Running rdmd -profile test.d it seems that to!() is eating most
of the time. Removing this brings it down from 530ms to 154ms
Num TreeFuncPer
Calls
On Thursday, 20 February 2014 at 19:46:35 UTC, w0rp wrote:
if (s.length > 0 && s.all!isDigit) {
// Never throws now.
auto x = parse!int(s);
}
Nope, integer overflow exception. Though I didn't check if it
would actually through that, but it should.
I don't have time now to do the optimization for you now, sorry.
I have improved your code a little, but I don't know the
performance of this compared to the C# code:
http://dpaste.dzfl.pl/0dab53bf85ad
I compile and run it with ldc2 with:
ldmd2 -wi -O -release -inline -noboundscheck -run test.
I don't have time now to do the optimization for you now, sorry.
I have improved your code a little, but I don't know the
performance of this compared to the C# code:
http://dpaste.dzfl.pl/0dab53bf85ad
I compile and run it with ldc2 with:
ldmd2 -wi -O -release -inline -noboundscheck -run tes
Mattdef:
Why this code is 2 times longer in D then C# ?
By "code longer" I assume you mean its run time. The answers
could be multiple, like you using DMD instead of LDC2/GDC, or you
using the wrong compilation switches, or perhaps because
Microsoft has poured on the Dotnet ten thousands ti
Hi
Why this code is 2 times longer in D then C# ?
module hello;
import std.stdio;
import std.datetime;
import std.string;
import std.conv;
int main(string[] argv)
{
writeln("Tape \"Y\" to launch benchmark or any other touch to
exit program :");
string s = chomp(readln());
On 02/19/2014 10:18 PM, Vladimir wrote:
>> Full version my very simplified example such task:
>> https://gist.github.com/Vladimir-Z/1a1755ce91cb0e7636b5
Notes:
* It is "process", not "proccess". :)
* isUseField is not used by proccessRowTemplate(). Removing it from the
parameter list (and doi
On 12/02/14 00:06, Joseph Rushton Wakeling wrote:
I've attached my current patch. It should be possible to apply this to master,
if anyone wants to test it.
I fixed my patch :-)
https://github.com/D-Programming-Language/tools/pull/117
Robin:
All in all I must say that I am more pleased with the DMD
results as I am kind of worried about the LDC allocation test
performance ...
I am not sure of the causes of this, but the D GG was improved a
little, in the last two compiler versions.
I also had to rewrite parts of the cod
Hiho,
here are the results of both compilers (DMD and LDC2) on my
system:
LDC:
=
allocationTest ...
Time required: 5 secs, 424 msecs
multiplicationTest ...
Time required: 1 secs, 744 msecs
toStringTest ...
Time required: 0 secs, 9
On Thursday, 20 February 2014 at 17:08:11 UTC, Jakob Ovrum wrote:
On Thursday, 20 February 2014 at 13:40:38 UTC, anonymous wrote:
When the value is not needed at compile time, the optimizer
may go for it, but that's not guaranteed.
That's not really true. The optimizer will never try CTFE
bec
On Thursday, 20 February 2014 at 19:58:10 UTC, Stanislav Blinov
wrote:
On Thursday, 20 February 2014 at 19:46:35 UTC, w0rp wrote:
if (s.length > 0 && s.all!isDigit) {
// Never throws now.
auto x = parse!int(s);
}
And what about +/- and U/L suffixes? Or, say, different base
(i.e. hexa
On Thursday, 20 February 2014 at 19:46:35 UTC, w0rp wrote:
if (s.length > 0 && s.all!isDigit) {
// Never throws now.
auto x = parse!int(s);
}
And what about +/- and U/L suffixes? Or, say, different base
(i.e. hexadecimal)?
It would be way more beneficial if Phobos' parse (or some
On Thursday, 20 February 2014 at 19:23:28 UTC, Cooler wrote:
On Thursday, 20 February 2014 at 19:18:15 UTC, Stanislav Blinov
wrote:
On Thursday, 20 February 2014 at 19:11:55 UTC, Cooler wrote:
The code:
string s = "...";
if(s.isNumeric){
auto x = parse!int(s); // Can I be sure here that pars
Cooler:
Is there any way to know that a string is convertible to a
number without throwing?
I suggested to add it:
https://d.puremagic.com/issues/show_bug.cgi?id=6840
Bye,
bearophile
On Thursday, 20 February 2014 at 19:11:55 UTC, Cooler wrote:
The code:
string s = "...";
if(s.isNumeric){
auto x = parse!int(s); // Can I be sure here that parse will
not throw?
}
No. s may still contain data that is not convertible to int. For
example, "nan".
On Wednesday, 19 February 2014 at 21:50:43 UTC, Meta wrote:
On Wednesday, 19 February 2014 at 19:44:12 UTC, Meta wrote:
On Wednesday, 19 February 2014 at 19:10:44 UTC, Frustrated
wrote:
Are there container templates that one can mixin to classes
that
give them container behavior?
e.g.,
inste
Note that you can create your own overload. Though it has to be
done "the long way", because dmd doesn't (yet?) allow overloading
templates imported from other modules:
import std.stdio;
import std.algorithm;
import std.traits;
template sort(alias less = "a < b", SwapStrategy ss =
SwapStrateg
On Thursday, 20 February 2014 at 17:34:37 UTC, D Apprentice wrote:
On Thursday, 20 February 2014 at 17:29:44 UTC, Stanislav Blinov
wrote:
sort(a[]);
That's still using the slice syntax though? I just reread the
documentation and it says that slicing does not copy any data,
so
there shouldn
I believe the problem is that std.algorithm.sort requires a
range, and fixed-size arrays are not ranges in D. I believe it's
because the most basic range functionality is the ability to do
this:
int[] arr = [0, 1, 2, 3];
while (arr.length > 0)
{
arr = arr[1..arr.length];
}
In other words, s
On Thursday, 20 February 2014 at 07:06:22 UTC, simendsjo wrote:
On Wednesday, 19 February 2014 at 21:55:35 UTC, Brad Anderson
wrote:
On Wednesday, 19 February 2014 at 14:46:57 UTC, simendsjo
wrote:
Spam spam
http://youtu.be/ZRUcTJC0D7M
Good stuff. Are you going to upload the older videos to t
On Thursday, 20 February 2014 at 17:29:44 UTC, Stanislav Blinov
wrote:
On Thursday, 20 February 2014 at 17:24:55 UTC, D Apprentice
wrote:
This works, but I'm curious if there's another (better) way?
sort(a[]);
That's still using the slice syntax though? I just reread the
documentation and
On Thursday, 20 February 2014 at 17:24:55 UTC, D Apprentice wrote:
This works, but I'm curious if there's another (better) way?
sort(a[]);
Greetings, D wizards.
Given a static array, int[5] a, presumed to be filled with random
numbers, how does one sort it using std.algorithm.sort? Calling
sort(a) by itself errors out with:
test.d(7): Error: template std.algorithm.sort does not match any
function template declaration. Candidates ar
On Thursday, 20 February 2014 at 13:40:38 UTC, anonymous wrote:
When the value is not needed at compile time, the optimizer may
go for it, but that's not guaranteed.
That's not really true. The optimizer will never try CTFE because
of the halting problem. Runtime is runtime, compile-time is
c
On Thursday, 20 February 2014 at 16:55:51 UTC, Andrea Fontana
wrote:
On Thursday, 20 February 2014 at 16:47:43 UTC, bearophile wrote:
Andrea Fontana:
I have a C api that need a int** params that represent a
int[][]. How can I convert from d to c to pass it? For simple
arrays, array.ptr seems
Andrea Fontana:
Ok, so it seems there's no "built-in" ways...
Yeah, and this is a very good thing :-)
Bye,
bearophile
On Thursday, 20 February 2014 at 16:47:43 UTC, bearophile wrote:
Andrea Fontana:
I have a C api that need a int** params that represent a
int[][]. How can I convert from d to c to pass it? For simple
arrays, array.ptr seems to work...
One way to do it (untested):
int** pp = myDArray.map!(a
Andrea Fontana:
I have a C api that need a int** params that represent a
int[][]. How can I convert from d to c to pass it? For simple
arrays, array.ptr seems to work...
One way to do it (untested):
int** pp = myDArray.map!(a => a.ptr).array.ptr;
Bye,
bearophile
I'm pretty sure I've just read about this, but search engines are
not useful in this case.
I have a C api that need a int** params that represent a int[][].
How can I convert from d to c to pass it? For simple arrays,
array.ptr seems to work...
On Thursday, 20 February 2014 at 14:32:40 UTC, Craig Dillabaugh
wrote:
On Thursday, 20 February 2014 at 10:28:45 UTC, simendsjo wrote:
http://youtu.be/wFqHTCBt72M
Thanks for posting these. They are well done. What text editor
are you using, emacs?
Vim with dcd and syntastic for some D supp
On Thursday, 20 February 2014 at 10:28:45 UTC, simendsjo wrote:
http://youtu.be/wFqHTCBt72M
Thanks for posting these. They are well done. What text editor
are you using, emacs?
On Wednesday, 19 February 2014 at 23:45:12 UTC, Etienne Cimon
wrote:
On 2014-02-19 17:15, Craig Dillabaugh wrote:
However, I would still be interested in finding out where I
could get a
listing of what the various exit codes mean ... or do I need
to delve
into the DMD source code?
That seem
On Thursday, 20 February 2014 at 08:10:06 UTC, simendsjo wrote:
On Wednesday, 19 February 2014 at 22:15:47 UTC, Craig
Dillabaugh wrote:
(...)
I just realized that I tried to build this on my Linode, where
DMD tends to choke and die with anything Vibe-d related (basic
Linodes have very little R
On Thursday, 20 February 2014 at 09:42:34 UTC, Gopan wrote:
const uint n = among(3, 1,2,5,3); //no error
int[n] arr; //no error.
And,
int v = 3;
const uint n = among(v, 1,2,5,3); //Error: variable v cannot be
read at compile time
int[n] arr; Error: Integer constant expression expected instead
http://youtu.be/wFqHTCBt72M
On Wednesday, 19 February 2014 at 19:45:39 UTC, Ali Çehreli wrote:
On 02/19/2014 01:46 AM, Gopan wrote:
> uint among(T, Us...)(T v, Us vals)
> {
> foreach (i, U; Us)
> {
> writeln("checking ", v, " == ", vals[i]);
> if (v == vals[i])
> return i + 1;
>
}
--
Now, among does not depend of input.length and it will never do
in any application. That is the sole reason I say it's O(1).
The application is of course O(n).
On Wednesday, 19 February 2014 at 22:05:49 UTC, Peter Alexander
wrote:
O(1) = O(2) = O(1,000,000) = O(k) for any constant k.
If you want to get even more anal about it, searching an array
is technically O(1) because an array cannot be bigger than
size_t.max, and since size_t.max is a constant,
On Wednesday, 19 February 2014 at 22:15:47 UTC, Craig Dillabaugh
wrote:
(...)
I just realized that I tried to build this on my Linode, where
DMD tends to choke and die with anything Vibe-d related (basic
Linodes have very little RAM). To many terminals open! Same
code/build config work fine
41 matches
Mail list logo