[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ePiX-devel] Re: Stable release (Version 1.2.0)
From: |
Maik Beckmann |
Subject: |
[ePiX-devel] Re: Stable release (Version 1.2.0) |
Date: |
Wed, 26 Sep 2007 17:56:36 +0200 |
User-agent: |
KMail/1.9.7 |
Am Mittwoch, 26. September 2007 16:55:38 schrieb Andrew D. Hwang:
> As I understand it, the new syntax accepts the same arguments as the old
> (so is not more restrictive to the user), and is slightly more efficient:
> Both implementations copy u, but the second carries the small overhead of
> passing a const reference for the first argument.
passing something as const reference is faster than non-const reference. The
performance cost comes from the added temporary P tmp(u). But this minimal
runtime overhead (a triple is a very small object) isn't an issue for epix
IMHO.
> Please let me know if
> this is incorrect, particularly, if there are argument types that work as
> expected with the old syntax but not with the new.
I'm afraid it isn't valid, consider:
void foo(P const& p1, P const& p2)
{
P mid = 0.5*(p1 + p2);
// where + has the signature
// P operator+(P lhs, P const& rhs);
}
This dosn't work, since p1 is const and you can't pass a const object as
no-const (the opposite: passing a non-const as const works).
Btw. at some places you wrote things like
double foo(const double arg);
which is very uncommon. This signature
double foo(double arg);
which is used is some place like:
bar()
{
double feed= ...;
double feed_copy = feed;
double myfoo = foo(feed);
feed == feed_copy // is allway true!!
}
keeps feed allways untouched, since its passed by value.
Regards, Maik
PS: Can you add a hatching example? It doesn't work for me so far.