On Monday, 9 February 2015 at 09:52:13 UTC, Marc Schütz wrote:
You could also hide the ugly __ctor() call behind a nicely
named factory method.
Yes, that's pretty much what I ended up doing. Added a couple
static member functions like:
static Boring CreateWithOption1(args);
static Boring
On 02/14/2015 12:13 PM, Adam D. Ruppe wrote:
On Saturday, 14 February 2015 at 20:08:09 UTC, Ali Çehreli wrote:
int foo()
{
return 42;
}
the difference is C# also allows you to implement A.foo separately from
B.foo. I don't think D allows that.
Yeah, I obviously read too
On Saturday, 14 February 2015 at 10:23:48 UTC, Gary Willoughby
wrote:
I wrote a similar function here:
https://github.com/nomad-software/dunit/blob/master/source/dunit/toolkit.d#L42
or using an epsilon value:
https://github.com/nomad-software/dunit/blob/master/source/dunit/toolkit.d#L134
I
On Sat, 14 Feb 2015 11:29:28 +, Jack Applegame wrote:
why std.conv.to is not pure?
string foo(real v) pure { return v.to!string; }
// Error: pure function 'foo' cannot call impure function
'std.conv.to!string.to!(real).to'
'cause float-string conversion is damned hard task. to perform
On Saturday, 14 February 2015 at 09:37:05 UTC, Jack Applegame
wrote:
I wrote this function for comparing two floating point values:
import std.math;
import std.traits;
bool isEqual(T)(T v1, T v2) if(isFloatingPoint!T) {
return T.mant_dig - feqrel(v1, v2) 2;
}
What do you think about it?
why std.conv.to is not pure?
string foo(real v) pure { return v.to!string; }
// Error: pure function 'foo' cannot call impure function
'std.conv.to!string.to!(real).to'
There is an approxEqual in std.math, in addition in feqrel:
http://dlang.org/phobos/std_math.html#.approxEqual
It takes maximum absolute and relative difference as arguments.
I wrote this function for comparing two floating point values:
import std.math;
import std.traits;
bool isEqual(T)(T v1, T v2) if(isFloatingPoint!T) {
return T.mant_dig - feqrel(v1, v2) 2;
}
What do you think about it?
On Sat, 14 Feb 2015 07:59:51 +, weaselcat wrote:
how smart pointers can help here? they don't magically hiding all the
low-level mechanics.
The file he was referring to was a smart pointer implementation.
*one* of the files.
signature.asc
Description: PGP signature
It is your profile?
http://www.cyberforum.ru/members/491746.html
The next version https://bpaste.net/show/dc3c5f10f2ca
I use https://github.com/dsimcha/Rational/blob/master/rational.d
I want to do it:
auto c = new Currencies!Rational.rational.Rational!(BigInt);
where Rational.rational.Rational it is std.rational.Rational
I get the error:
Error: template
Does D provide a way for explicit interface implementation?
[C#] https://msdn.microsoft.com/en-us/library/ms173157.aspx
ref2401 wrote:
Does D provide a way for explicit interface implementation?
[C#] https://msdn.microsoft.com/en-us/library/ms173157.aspx
Not exactly, but you may try something like this:
interface A
{
void foo();
}
interface B
{
void foo();
}
class C : A
{
class Nested : B
{
On Saturday, 14 February 2015 at 12:24:51 UTC, ketmar wrote:
On Sat, 14 Feb 2015 11:29:28 +, Jack Applegame wrote:
why std.conv.to is not pure?
string foo(real v) pure { return v.to!string; }
// Error: pure function 'foo' cannot call impure function
'std.conv.to!string.to!(real).to'
On 02/14/2015 09:19 AM, ref2401 wrote:
Does D provide a way for explicit interface implementation?
[C#] https://msdn.microsoft.com/en-us/library/ms173157.aspx
Apparently, yes:
interface A
{
int foo();
}
interface B
{
int foo();
}
class C : A, B
{
int foo()
{
return
On Saturday, 14 February 2015 at 20:08:09 UTC, Ali Çehreli wrote:
int foo()
{
return 42;
}
the difference is C# also allows you to implement A.foo
separately from B.foo. I don't think D allows that.
You can call a specific interface at the usage site, but
implementing
On Sat, 14 Feb 2015 19:59:58 +, Gary Willoughby wrote:
On Saturday, 14 February 2015 at 12:24:51 UTC, ketmar wrote:
On Sat, 14 Feb 2015 11:29:28 +, Jack Applegame wrote:
why std.conv.to is not pure?
string foo(real v) pure { return v.to!string; }
// Error: pure function 'foo'
While snprintf might be one thing that provides to be an interesting
obstacle, the better answer to why std.conv.to isnt pure is that no one
has invested the time to work through issues like that to make it so.
It _should_ be pure.
On 2/14/2015 12:32 PM, ketmar via Digitalmars-d-learn wrote:
Is there a brief way to iterate an array of objects, and process
only objects of certain type (in either two ways, with/without
inheritance)?
foreach(p; obj.children){ // KObj[] children
DPFile dfile = cast(DPFile)p;
if(!dfile)continue;
I found a solution I like a lot, with templated opApply:
class Cont{
Thing[] kids;
int opApply(T)(int delegate(ref T) dg){
int result = 0;
for (int i = 0; i kids.length; i++){
T t = cast(T)kids[i];
On Saturday, 14 February 2015 at 06:38:19 UTC, ketmar wrote:
On Sat, 14 Feb 2015 00:57:33 +, weaselcat wrote:
On Friday, 13 February 2015 at 22:55:27 UTC, anonymous wrote:
On Thursday, 12 February 2015 at 23:52:41 UTC, Foo wrote:
This is something I've done recently.
Would be glad if my
On Friday, 13 February 2015 at 22:39:10 UTC, bearophile wrote:
H. S. Teoh:
So it could be called ilog2?
Perhaps floorIlog2? Isn't ilog2 a different function?
Bye,
bearophile
I think the naming depends on use context, so it is reasonable to
land on different names in different domains.
On Saturday, 14 February 2015 at 08:01:27 UTC, Ola Fosheim
Grøstad wrote:
I think the naming depends on use context, so it is reasonable
to
land on different names in different domains. Maybe the standard
notation should be ffs(x):
Oops, I meant fls(x)... I just woke up :-P. It is a bad name
23 matches
Mail list logo