This corrects the parallel example range in the second foreach.
Still slow.
void printDiamonde2cpa(in uint N)
{
size_t N2 = N/2;
char p[] = uninitializedArray!(char[])(N2+N);
p[0..N2] = ' ';
p[N2..$] = '*';
char nl[] = uninitializedArray!(char[])(1);
nl[] = '\n';
ch
On Wednesday, 26 March 2014 at 04:47:48 UTC, Jay Norwood wrote:
This is a first attempt at using parallel, but no improvement
oops. scratch that one. I tested a pointer to the wrong function.
This is a first attempt at using parallel, but no improvement in
speed on a corei7. It is about 3x slower than the prior
versions. Probably the join was not a good idea. Also, no
foreach_reverse for the parallel, so it requires extra
calculations for the reverse index.
void printDiamonde2
On Tue, 25 Mar 2014 19:13:07 -0400, H. S. Teoh
wrote:
On Tue, Mar 25, 2014 at 10:02:33PM +, monarch_dodra wrote:
On Tuesday, 25 March 2014 at 21:35:47 UTC, Mark Isaacson wrote:
>Is there a performance benefit? Is it simply because it's more general?
[...]
There is *1* thing you should
On Tue, Mar 25, 2014 at 10:02:33PM +, monarch_dodra wrote:
> On Tuesday, 25 March 2014 at 21:35:47 UTC, Mark Isaacson wrote:
> >Is there a performance benefit? Is it simply because it's more general?
[...]
> There is *1* thing you should take into account though: "to!" is a
> no-op for string=>
Much appreciated everyone! I had a vague intuition that these
were the reasons, but it was helpful to spell them out. I'm
especially partial to the self-documentation reasoning.
On Tuesday, 25 March 2014 at 21:35:47 UTC, Mark Isaacson wrote:
Is there a performance benefit? Is it simply because it's more
general?
Mostly because it's more generic. For example:
If instead you want to do "string" => "char[]", then your code
will have to be changed to use "dup".
if instead
Mark Isaacson:
why use `to!string` instead of just doing `line[2 .. $].idup`?
I sometimes prefer the text function:
= line[2 .. $].text;
Bye,
bearophile
On Tue, 25 Mar 2014 21:35:46 +, Mark Isaacson wrote:
> I am presently working my way through TDPL for the second time, and
> there's an example in chapter 1 to the effect of:
>
> [code]
> string currentParagraph;
> foreach(line; stdin.byLine()) {
>if (line.length > 2) {
> currentPara
I am presently working my way through TDPL for the second time,
and there's an example in chapter 1 to the effect of:
[code]
string currentParagraph;
foreach(line; stdin.byLine()) {
if (line.length > 2) {
currentParagraph = to!string(line[2 .. $]);
}
}
[/code]
The explicit conversion
On 03/25/2014 02:01 PM, Uranuz wrote:
>> Your code compiles with the development branch of dmd. What version
>> are you using?
>>
> Now I'm using 2.064.
Still compiles for me. Could you please show us a minimal main() as well.
Thank you,
Ali
anonymous:
When you know that it won't be reached, you can (should?) put
assert(false) instead of a return.
Yes, right, I use assert(false) in those cases :-)
Bye,
bearophile
Sigh. I figured out what was going on. The reason why the
compiler never complained and the intended function never got
called is because I had a static if checking for
__traits(compiles, ...). The attributes made sense, but _I_ was
silencing the compiler.
Ugh.
Atila
On Tuesday, 25 March 2014
On Tuesday, 25 March 2014 at 20:49:57 UTC, bearophile wrote:
This code compiles with no errors or warnings:
struct Foo {
int opApply(int delegate(ref ubyte) dg) {
int result;
ubyte x;
while (true) {
result = dg(x);
if (result) return result;
On Tuesday, 25 March 2014 at 20:49:57 UTC, bearophile wrote:
This code compiles with no errors or warnings:
struct Foo {
int opApply(int delegate(ref ubyte) dg) {
int result;
ubyte x;
while (true) {
result = dg(x);
if (result) return result;
Chris Williams:
I'm not seeing it. "while (true)" is no more an infinite loop
than "for (i = 0; i < x; i++)", if the body of the while has a
break or return statement.
I see, so there's nothing to improve here :-)
Bye,
bearophile
On Tuesday, 25 March 2014 at 20:49:57 UTC, bearophile wrote:
Note how the opApply() of Foo should not end with a return,
while the opApply() of Bar is required by the D compiler to end
with a return.
Yet, Foo is contains an infinite loop, so the result of Bar
will not be reached. But the type
Your code compiles with the development branch of dmd. What
version are you using?
Now I'm using 2.064. May be this bug is already fixed. In 2.065 I
experience problem that std.json library module is not compatible
with code written for previous versions. This is why I returned
to 2.064. As f
This code compiles with no errors or warnings:
struct Foo {
int opApply(int delegate(ref ubyte) dg) {
int result;
ubyte x;
while (true) {
result = dg(x);
if (result) return result;
x++;
}
//return result; // Warning:
On Tuesday, 25 March 2014 at 18:10:17 UTC, Meta wrote:
On Tuesday, 25 March 2014 at 18:05:47 UTC, Frustrated wrote:
Due to a previous issue I am trying to do the following
mixin template A()
{
mixin((function () => "int x;")() );
}
the problem is that the compiler will not let me use the
d
On Tuesday, 25 March 2014 at 20:20:29 UTC, Frustrated wrote:
On Tuesday, 25 March 2014 at 18:10:17 UTC, Meta wrote:
On Tuesday, 25 March 2014 at 18:05:47 UTC, Frustrated wrote:
Due to a previous issue I am trying to do the following
mixin template A()
{
mixin((function () => "int x;")() );
}
On 03/25/2014 12:20 PM, Uranuz wrote:
> I have problem with understanding of work of modifiers const, inout,
> immutable modifiers.
I am sure you know these as well, but here is my quick list:
const: "I shall not modify data"
immutable: "I demand immutable data"
inout: "Whatever the actual type
On Tuesday, 25 March 2014 at 15:31:12 UTC, monarch_dodra wrote:
I love how D can achieve *great* performance, while still
looking readable and maintainable.
Yes, I'm pretty happy to see the appender works well. The
parallel library also seems to work very well in my few
experiences with it.
This works for me (2.064):
import std.stdio : writeln;
void main() {
mixin({ return "int x;"; }());
writeln(x);
}
I have problem with understanding of work of modifiers const,
inout, immutable modifiers. As I understand inout keyword is
intended to consume const, immutable and data without modifiers.
It's how I expect it to work otherwise I don't understand what is
the purpose of inout. In current implemen
I probably should have mentioned that the bug is introduced in
the parent commit. The code I originally wrote that triggered the
bug was larger, of course.
Replacing that parent commit with a call to writeln does the same
thing. I would expect a compiler error instead.
On Tuesday, 25 March 2
On Tuesday, 25 March 2014 at 17:57:33 UTC, Atila Neves wrote:
I just spent a lot of time trying to debug my code and it seems
to have to do with @safe. I have some template functions in a
class, and one of them, marked as @safe, ended up making a call
to an abstract function with no attribute.
On Tuesday, 25 March 2014 at 18:05:47 UTC, Frustrated wrote:
Due to a previous issue I am trying to do the following
mixin template A()
{
mixin((function () => "int x;")() );
}
the problem is that the compiler will not let me use the
delegate because it has no this context. Of course the w
Due to a previous issue I am trying to do the following
mixin template A()
{
mixin((function () => "int x;")() );
}
the problem is that the compiler will not let me use the delegate
because it has no this context. Of course the whole point here is
that the delegate will never be used at ru
I just spent a lot of time trying to debug my code and it seems
to have to do with @safe. I have some template functions in a
class, and one of them, marked as @safe, ended up making a call
to an abstract function with no attribute. My unit test started
failing and I tried writeln-debugging but
I see thanks. I couldn't see the throwable class at the time.
On Tuesday, 25 March 2014 at 12:30:37 UTC, Jay Norwood wrote:
These are times on ubuntu. printDiamond3 was slower than
printDiamond.
Hum... Too bad :/
I was able to improve my first "printDiamon" by having a single
slice that contains spaces then stars, and make writeln's of that.
It gave (
Spacen Jasset:
I caught a FileException, and want to print out the descriptive
error, but not the stacktrace. I cannot see how to do this at
the moment. I only see the toString function.
void main() {
import std.stdio;
try {
File("hello");
} catch (Exception e) {
Am 25.03.2014 15:43, schrieb Spacen Jasset:
> I caught a FileException, and want to print out the descriptive error,
> but not the stacktrace. I cannot see how to do this at the moment. I
> only see the toString function.
>
> i.e. in the case below I would like to obtain "c:/temp\junk: The
> direc
On Tuesday, 25 March 2014 at 14:43:18 UTC, Spacen Jasset wrote:
I caught a FileException, and want to print out the descriptive
error, but not the stacktrace.
Try writing the exception's 'msg' field (it's a string).
There is also 'file' and 'line'. See the class Throwable (in
object.d or obje
I caught a FileException, and want to print out the descriptive
error, but not the stacktrace. I cannot see how to do this at the
moment. I only see the toString function.
i.e. in the case below I would like to obtain "c:/temp\junk: The
directory is not empty." or something similar, but not th
On Tuesday, 25 March 2014 at 01:15:10 UTC, Trent Forkert wrote:
On Monday, 24 March 2014 at 23:55:14 UTC, Dragos Carp wrote:
Any alternatives??
I moved cmaked2 to github [1], updated and simplified the
usage a
little (system cmake patch not necessary anymore). You can give
it a try. Dub reg
* for function parameters
On Sunday, 23 March 2014 at 10:28:54 UTC, Infiltrator wrote:
So, is this a limitation with inout, part of its design, or am
I misunderstaning something more fundamental?
It's fundamental: inout makes sense for function attributes only
and can't be used as a template parameter or struct/class f
These are times on ubuntu. printDiamond3 was slower than
printDiamond.
brad: time: 12387[ms]
printDiamond1: time: 373[ms]
printDiamond2: time: 722[ms]
printDiamond3: time: 384[ms]
jay1: time: 62[ms]
sergei: time: 3918[ms]
jay2: time: 28[ms]
diamondShape: time: 2725[ms]
printDiamond: time: 19[ms
I'm using DGUI (the one on bitbucket) and I can't work out how to
use the scrollbars. I've got them enabled but I can't work out
from the library files how to set the scale and read the
position. Also is there a way of turning off the vertical
scrollbar - the 'enable' turns them both on.
Any
Interesting. I'd have thought the "extra copy" would be an
overall slowdown, but I guess that's not the case.
I also tried your strategy of adding '\n' to the buffer, but I
was getting some bad output on windows. I'm not sure why "\n\n"
works though. On *nix, I'd have also expected a doub
On Tuesday, 25 March 2014 at 02:25:57 UTC, Jay Norwood wrote:
not through yet with the diamond. This one is a little faster.
Appending the newline to the stars and calculating the slice
backward from the end would save a w.put for the newlines ...
probably faster. I keep looking for a way to
On Monday, 17 March 2014 at 13:09:29 UTC, Russel Winder wrote:
On Sun, 2014-03-16 at 23:10 +, Joel wrote:
Thanks Russel!
I've gotten past the security problem!
There's options under Security & Privacy (and what can be
downloaded):
O-MacApp Store
O-idetinified developers
@-Anywhere.
Tho
44 matches
Mail list logo