On Tue, 08 Mar 2011 15:25:27 -0500, Steven Schveighoffer wrote:
Hey, wouldn't it be cool if I could add a custom allocator to all
classes!?...
class Collection(T, alloc = DefaultAllocator!T) {
Collection!(T) add(T t) { ...; return this; } // 20 other now subtly
incorrect functions
I gave this some thought, and I'm probably just a bit braindamaged by C#.
Consider you wish to unittest a class that fetches data from a database and
sends an
email.
The common scenario here is to use IoC and mock the objects so you can check
that
FetchData was called and SendEmail is called
In a (template) data structure I'm working on, I had the following thinko:
auto a = new T[n];
foreach (T i, ref e; a) {
e = i;
}
Then I instantiated it with T=bool, and n=256. Infinite loop, of course
-- the problem being that i wraps around to 0 after the last iteration.
1) Why does this code not work (dmd 2.051) and how do I fix it:
struct S
{
static S New()
{
S s;
return s;
}
const bool opEquals(ref const(S) s)
{
return true;
}
}
void main()
{
S s;
On Wed, 09 Mar 2011 11:40:25 -0500, SiegeLord n...@none.com wrote:
1) Why does this code not work (dmd 2.051) and how do I fix it:
struct S
{
static S New()
{
S s;
return s;
}
const bool opEquals(ref const(S) s)
{
Steven Schveighoffer Wrote:
It's a mis-designed feature of structs. There is a bug report on it:
http://d.puremagic.com/issues/show_bug.cgi?id=3659
It worked fine in D1. Or did you mean that the mis-designed feature is the
const system?
Anyway, thanks for the link to the bug report. I'll
On Wed, 09 Mar 2011 12:15:26 -0500, SiegeLord n...@none.com wrote:
Steven Schveighoffer Wrote:
It's a mis-designed feature of structs. There is a bug report on it:
http://d.puremagic.com/issues/show_bug.cgi?id=3659
It worked fine in D1. Or did you mean that the mis-designed feature is
On 03/09/2011 09:09 AM, Magnus Lie Hetland wrote:
In a (template) data structure I'm working on, I had the following thinko:
auto a = new T[n];
foreach (T i, ref e; a) {
e = i;
}
Then I instantiated it with T=bool, and n=256. Infinite loop, of course
-- the problem being that i wraps around to
Nick Sabalausky napisał:
Is there a way to get the fully-qualified name of an identifier without
doing demange( mangledName!(foo) )?
Heh, looks like there isn't. It may be worth filing an enhancement request for
__traits(fullyQualifiedName, foo).
BTW, what do you need it for?
--
Tomek
What is the most efficient way of implement a rotation of ubyte[4] array?
By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3]
TIA,
Tom;
This is on Windows 7. Using a def file to stop the terminal window
coming up.
win.def
EXETYPE NT
SUBSYSTEM WINDOWS
bug.d
import std.stdio;
import std.string;
void main() {
auto f = File( z.txt, w );
scope( exit )
f.close;
string foo = bar;
Tom:
What is the most efficient way of implement a rotation of ubyte[4] array?
By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3]
Two versions, I have done no benchmarks so far:
import std.c.stdio: printf;
union Four {
ubyte[4] a;
uint u;
}
void showFour(Four f) {
On 03/09/2011 03:41 PM, Tom wrote:
What is the most efficient way of implement a rotation of ubyte[4] array?
By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3]
TIA,
Tom;
I don't know of anything more efficient than:
ubyte[4] bytes = [1,2,3,4];
bytes = bytes[$-1] ~
import std.process;
void main()
{
char[] chBuffer = new char[](256);
chBuffer[] = '\0';
chBuffer[0..3] = dir.dup;
auto result = shell(chBuffer.idup);
}
It does two things:
1. It prints out the result of the shell invocation to stdout. This shouldn't
happen.
2. It throws
On Wednesday, March 09, 2011 15:35:29 Kai Meyer wrote:
On 03/09/2011 03:41 PM, Tom wrote:
What is the most efficient way of implement a rotation of ubyte[4] array?
By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3]
TIA,
Tom;
I don't know of anything more efficient than:
On 03/09/2011 04:25 PM, bearophile wrote:
Tom:
What is the most efficient way of implement a rotation of ubyte[4] array?
By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3]
Two versions, I have done no benchmarks so far:
import std.c.stdio: printf;
union Four {
ubyte[4] a;
On 03/10/2011 12:55 AM, Jonathan M Davis wrote:
I don't know of anything more efficient than:
ubyte[4] bytes = [1,2,3,4];
bytes = bytes[$-1] ~ bytes[0..$-1]; // Rotate left
I'm stunned that this works. I'd even consider reporting it as a bug. You're
concatenating a ubyte[] ont a
On 03/10/2011 12:19 AM, Joel Christensen wrote:
This is on Windows 7. Using a def file to stop the terminal window coming up.
win.def
EXETYPE NT
SUBSYSTEM WINDOWS
bug.d
import std.stdio;
import std.string;
void main() {
auto f = File( z.txt, w );
scope( exit )
f.close;
string foo = bar;
Found myself a solution. And probably the cause of the issue. shell()
doesn't expect a null-terminated string, but just a string with the
shell command without any newlines or nulls.
So I can do this (importing std.algorithm for until):
auto command = to!string(chBuffer[].until('\n'));
On Wednesday, March 09, 2011 15:55:07 Andrej Mitrovic wrote:
import std.process;
void main()
{
char[] chBuffer = new char[](256);
chBuffer[] = '\0';
chBuffer[0..3] = dir.dup;
auto result = shell(chBuffer.idup);
}
It does two things:
1. It prints out the result of
Hi, all. I'm in college, taking a freshman-level CS class. (I'm actually a
senior chemist with free time.)
Anyhoo, the warm-up assignment was Hardy Taxi problem, phrased like this:
[Exposition removed.] 1729 is the smallest number such that for
(a!=b!=c!=d)0, there exists a combination of a, b, c,
== Quote from bearophile (bearophileh...@lycos.com)'s article
Tom:
What is the most efficient way of implement a rotation of ubyte[4] array?
By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3]
Two versions, I have done no benchmarks so far:
import std.c.stdio: printf;
union Four
Charles McAnany Wrote:
(There's also a StopWatch timing things, and isTaxiNumber returns a struct,
not a bool. See attached code.)
This code runs in about 0.09 seconds.
If I comment out the writefln, it takes 0.11 seconds.
(These are collected from about 20 runs of each. Times are very
On 10-Mar-11 1:04 PM, spir wrote:
On 03/10/2011 12:19 AM, Joel Christensen wrote:
This is on Windows 7. Using a def file to stop the terminal window
coming up.
win.def
EXETYPE NT
SUBSYSTEM WINDOWS
bug.d
import std.stdio;
import std.string;
void main() {
auto f = File( z.txt, w );
scope( exit
On Wed, Mar 9, 2011 at 5:19 PM, Joel Christensen joel...@gmail.com wrote:
This is on Windows 7. Using a def file to stop the terminal window coming
up.
win.def
EXETYPE NT
SUBSYSTEM WINDOWS
bug.d
import std.stdio;
import std.string;
void main() {
auto f = File( z.txt, w );
On Wed, Mar 9, 2011 at 7:25 PM, U2 fan i...@u2fan.com wrote:
== Quote from bearophile (bearophileh...@lycos.com)'s article
Tom:
What is the most efficient way of implement a rotation of ubyte[4] array?
By rotation I mean: rotateRight([1, 2, 3, 4]) - [4, 1, 2, 3]
Two versions, I have done
On Thu, Mar 10, 2011 at 1:31 AM, Jonathan M Davis jmdavisp...@gmx.com wrote:
On Wednesday 09 March 2011 23:15:13 Andrew Wiley wrote:
On Wed, Mar 9, 2011 at 5:19 PM, Joel Christensen joel...@gmail.com wrote:
This is on Windows 7. Using a def file to stop the terminal window coming
up.
27 matches
Mail list logo