Friday, June 15, 2018

Digest for comp.lang.c++@googlegroups.com - 25 updates in 7 topics

ram@zedat.fu-berlin.de (Stefan Ram): Jun 15 12:07PM

There is this programming-language "shootout" site,
where the runtime of programs for different programming
languages is shown. C++ was clearly slower than C there,
which seemed strange, given that, ostensibly, C is a part of
C++. Maybe C++ triggered different algorithms in programmers,
which were slower.
 
But recently I saw that on this site C++ now nearly is
as fast as C. Maybe C++ enthusiast took some time to
run-time optimize the C++ programs for the "shootout".
ram@zedat.fu-berlin.de (Stefan Ram): Jun 15 12:09PM

I just occured to me that C is "B with type" and
C++ is "C with classes", one also might say that
C++2x is "C++ with concepts".
 
It seems as if progress on this branch of programming
languages always means improvements of the type system!
ram@zedat.fu-berlin.de (Stefan Ram): Jun 15 12:15PM

Supersedes: <types-20180615130753@ram.dialup.fu-berlin.de>
[Spelling]
 
It just occured to me that C is "B with types" and
C++ is "C with classes", one also might say that
C++2x is "C++ with concepts".
 
It seems as if progress on this branch of programming
languages always means improvements of the type system!
legalize+jeeves@mail.xmission.com (Richard): Jun 14 11:54PM

[Please do not mail me a copy of your followup]
 
SilverSlimer <.m@nsn.s> spake the secret code
>> issues. Reuters reported on the latest Consumer Reports reliability
>> study, which was published on Thursday.
 
>Sad to hear that it doesn't beat the iPad Pro.
 
I'm happy with my Surface Book. It's what I've been using for Utah
C++ Programmers presentations for a couple of years now, with no
complaints about the hardware. I hardly use the touch aspect of the
machine; I mostly use it as a very lightweight development laptop.
I wish there was a distinction between Fn keys and special function
keys, like on my Toshiba. As a VS user, you often need to go back and
forth between PageUp/PageDown and Fn keys and these are overloaded on
the surface book keyboard.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
SilverSlimer <.m@nsn.s>: Jun 14 08:08PM -0400

On Thu, 14 Jun 2018 23:54:02 +0000 (UTC),
>keys, like on my Toshiba. As a VS user, you often need to go back and
>forth between PageUp/PageDown and Fn keys and these are overloaded on
>the surface book keyboard.
 
I'm glad that it works for you but I've read more than a few articles
of widespread complaints about the hardware. I'm not a fan of thin
laptops myself and would probably never buy one but it sucks to know
that yet another piece of hardware Microsoft designs is unreliable for
a large amount of people. They never get things right the first time.
 
Hell, I had a Microsoft Trackball a few years ago. The worst piece of
crap I've ever used. Meanwhile, this Logitech M570 has been
spectacular since 2011 or so.
nospam <nospam@nospam.invalid>: Jun 14 08:32PM -0400

In article <dip5idho7upvsspabgtlp8r5sdja6luqv3@4ax.com>, SilverSlimer
> > issues. Reuters reported on the latest Consumer Reports reliability
> > study, which was published on Thursday.
 
> Sad to hear that it doesn't beat the iPad Pro.
 
why is it sad?
boltar@cylonHQ.com: Jun 15 08:37AM

On Thu, 14 Jun 2018 14:50:22 -0400
 
>nonsense.
 
>apple's market cap is roughly *four* times what it was when steve jobs
>died.
 
Share values have little relation to reality these days. Sure, they're still
very profitable, but name me one significant device that they've brought out
since Jobs. There's only the watch, and that was a flop. Cook has zero vision,
he's just an accountant in a poloneck. He's trying to emulate job's style
without any of the substance.
boltar@cylonHQ.com: Jun 15 08:41AM

On Thu, 14 Jun 2018 14:50:22 -0400
>> a C++ forum, try using vi in a shell or eclipse on a phone. You'll soon get
>> sick of it and wish for a large screen and a mouse.
 
>there are people doing all of that on their tablet and even phone.
 
Really? 8 hours a day, 5 days a week they're coding on their 3 inch phone
screens? Don't be an ass.
 
>> or 3 of them to do their jobs.
 
>some tasks might require multiple large displays, but the number of
>such tasks is rapidly shrinking.
 
No it isn't. There's a reason people moved to multiscreen and it wasn't
because monitors were getting smaller.
 
>you are assuming that today's phones will never improve, that what
>exists today is how it always will be.
 
>that is a very, very bad assumption.
 
Oh, so we'll soon be walking around with phones with 32 inch screens and
a keyboard will we? It doesn't matter how good the tech inside the phone is,
the human interface won't be changing anytime soon and THAT is the problem.
That and the feeble internal storage and poor support for external. And no,
the cloud isn't the answer to everything.
nospam <nospam@nospam.invalid>: Jun 15 07:36AM -0400

> since Jobs. There's only the watch, and that was a flop. Cook has zero vision,
> he's just an accountant in a poloneck. He's trying to emulate job's style
> without any of the substance.
 
nonsense. apple has released numerous products since then, including
the watch, which is in no way a flop. apple sells more watches than the
entire swiss watch industry combined, and that's in just 3 years or so.
nospam <nospam@nospam.invalid>: Jun 15 07:36AM -0400


> >there are people doing all of that on their tablet and even phone.
 
> Really? 8 hours a day, 5 days a week they're coding on their 3 inch phone
> screens? Don't be an ass.
 
straw man.
 
the reality is that *can* be done on a mobile device, whereas it was
difficult to impossible even just a few years ago.
 
mobile devices are becoming increasingly more capable and the number of
tasks that require a desktop system will continue to shrink.
 
the trend is clear. very, very clear.
boltar@cylonHQ.com: Jun 15 11:53AM

On Fri, 15 Jun 2018 07:36:47 -0400
>> Really? 8 hours a day, 5 days a week they're coding on their 3 inch phone
>> screens? Don't be an ass.
 
>straw man.
 
Sorry? Thats how people work. Perhaps you've never had a real job yet and don't
understand that.
 
>the reality is that *can* be done on a mobile device, whereas it was
>difficult to impossible even just a few years ago.
 
I could walk 100 miles. But I'd rather use a vehicle. Ditto using a phone
for doing real work on.
 
>mobile devices are becoming increasingly more capable and the number of
>tasks that require a desktop system will continue to shrink.
 
>the trend is clear. very, very clear.
 
No, the trend is people buying these things to use for media consumption, not
to work on.
boltar@cylonHQ.com: Jun 15 11:55AM

On Fri, 15 Jun 2018 07:36:48 -0400
>> he's just an accountant in a poloneck. He's trying to emulate job's style
>> without any of the substance.
 
>nonsense. apple has released numerous products since then, including
 
Such as?
 
>the watch, which is in no way a flop. apple sells more watches than the
>entire swiss watch industry combined, and that's in just 3 years or so.
 
Says an obvious fanboy. WHere are they then? I almost never see anyone wearing
one, in fact wearing a watch these days is becoming rarer but when I do see
a watch its not apple.
Rosario19 <Ros@invalid.invalid>: Jun 15 07:29AM +0200

On Thu, 14 Jun 2018 11:57:38 +0200, Rosario19 wrote:
 
 
>T *p=malloc(sizeof(T));
>if(p)
> {p->T(); // call manually the default void arg constructor for p
 
appear that above not compile as not compile (*p).T()
 
 
> ... // code using p and *p
> p->~T();// call manually the default destructor for p
 
appear that above compile ok and link ok
 
> free(p);
> }
 
my workaround
 
T *p=malloc(sizeof(T));
 
if(p)
{u8 *pc;
u32 i;
pc=(u8*) p; for(i=0;i<sizeof(T);++i) pc[i]=0;
.....
(*p).~T();
free(p);
}
 
this because in my memory, out the possible case of double (or float
point)
the obj all 0, is one valid obj that has to be initializated and other
operator (as operator=, can initialize it ok)
Rosario19 <Ros@invalid.invalid>: Jun 15 07:33AM +0200

On Thu, 14 Jun 2018 09:55:52 -0700, red floyd wrote:
 
>to do. If all you are trying to do is allocate a T dynamically, then
>just do
 
>T* p = new T;
 
ci dovrebbe esser un proverbio
 
"preferisco sempre quello che ho scritto"
 
perche' quello che ho scritto lo posso correggere
conosco come trattarlo,
ma quello che hanno scritto gli altri nn lo posso correggere
e nn lo conosco
Rosario19 <Ros@invalid.invalid>: Jun 15 07:37AM +0200

On Fri, 15 Jun 2018 07:29:28 +0200, Rosario19 wrote:
 
> (*p).~T();
> free(p);
> }
 
this above compile run and not leak
 
>point)
>the obj all 0, is one valid obj that has to be initializated and other
>operator (as operator=, can initialize it ok)
 
if the obj has one element that has the len of memory of its sub obj
and that element is 0, than it is called malloc() for give memory
at last in all class i wrote using malloc() until now
"Öö Tiib" <ootiib@hot.ee>: Jun 14 10:59PM -0700

On Friday, 15 June 2018 08:28:47 UTC+3, Rosario19 wrote:
> conosco come trattarlo,
> ma quello che hanno scritto gli altri nn lo posso correggere
> e nn lo conosco
 
If you don't care what others answer then why to write the
question "how to do it?" here at the first place?
Every regular in this group knows how to do it but it is
pointless to answer that to you.
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Jun 15 12:50PM +0100

On Fri, 15 Jun 2018 07:29:28 +0200
> point)
> the obj all 0, is one valid obj that has to be initializated and other
> operator (as operator=, can initialize it ok)
 
You have two problems. First your postings are nearly unintelligible.
Why not try using something like Google translate which may make a
better fist of it? It is worth checking it out to see.
 
Secondly and more importantly, you have already been given the answer,
namely to use placement new, which is specifically intended to deal
with this case, namely a case where an object is to be constructed in
pre-allocated raw memory, such as has been returned by malloc(). The
form is this:
 
void* p = malloc(sizeof(T));
T* tp = new (p) T;
... do something with tp ...
tp->~T();
free(tp);
 
There is even a similar example on the link I gave you. Your approach
does not work and demonstrates sheer pig-headed stupidity in the face
of your attention having been drawn to the correct tool for the job.
You think you know better. I am afraid that that is a grave over-
estimation of your abilities.
wyniijj@gmail.com: Jun 15 01:19AM -0700

I have a piece of test code to compare std::sort and my Wy::sort.
 
const int Test_Sort_Count=500;
 
template<typename T>
void test_sort_std(const int len)
{
assert(len>0);
using std::swap;
Wy::ErrNo r; // Wy::ErrNo is a class wraps type int
Wy::Array<T> arr(len,0); // Wy::Array is a dynamic array
 
// Random
for(int count=Test_Sort_Count; count>0; --count) {
for(int i=0; i<len; ++i) {
arr[i]=std::rand()%len;
}
std::sort(arr.begin(),arr.end()); // line 38
for(int i=1; i<len; ++i) {
if(arr[i]<arr[i-1]) {
WY_THROW( Wy::ErrNo() );
}
}
}
//.......
//.......
};
 
template<typename T> Wy::swap(T& a, T& b); is implemented in my library,
it used to compile fine. (probably caused by adding compile opt. -std=gnu++11)
Is there any one any idea how to solve this compilation problem?
 
-------------------
[]$make sp_sort
 
/usr/include/c++/8/bits/stl_algobase.h: In instantiation of 'void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = Wy::Timespec*; _ForwardIterator2 = Wy::Timespec*]':
/usr/include/c++/8/bits/stl_algo.h:84:20: required from 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = Wy::Timespec*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/8/bits/stl_algo.h:1921:34: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = Wy::Timespec*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/8/bits/stl_algo.h:1953:38: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = Wy::Timespec*; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/8/bits/stl_algo.h:1968:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = Wy::Timespec*; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
/usr/include/c++/8/bits/stl_algo.h:4834:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = Wy::Timespec*]'
sp_sort.cpp:38:13: required from 'void test_sort_std(int) [with T = Wy::Timespec]'
sp_sort.cpp:397:37: required from here
/usr/include/c++/8/bits/stl_algobase.h:148:11: error: call of overloaded 'swap(Wy::Timespec&, Wy::Timespec&)' is ambiguous
swap(*__a, *__b);
~~~~^~~~~~~~~~~~
 
--- Wy::Timespec is a class wrapper of ::timespec
Bo Persson <bop@gmb.dk>: Jun 15 10:35AM +0200

> swap(*__a, *__b);
> ~~~~^~~~~~~~~~~~
 
> --- Wy::Timespec is a class wrapper of ::timespec
 
Why do you have a swap functions with the same signature as the std::swap?
 
template<typename T> Wy::swap(T& a, T& b); says "for absolutely ANY
type, do this". Which is a bit wide for an interface.
 
You can avoid the ambiguity by only supplying the more specialized overload
 
swap(your_type&, your_type&);
 
 
 
Bo Persson
wyniijj@gmail.com: Jun 15 04:25AM -0700

Bo Persson於 2018年6月15日星期五 UTC+8下午4時35分20秒寫道:
 
> Why do you have a swap functions with the same signature as the std::swap?
 
> template<typename T> Wy::swap(T& a, T& b); says "for absolutely ANY
> type, do this". Which is a bit wide for an interface.
 
As regard to the 'swap'. It's because I adopted 'the move ctor' approach.
template<typename T> Wy::swap(T& a, T& b) is thus natuarly defined.
Even the standard C++ adopted rref latter, I decided not to use it.
 
> You can avoid the ambiguity by only supplying the more specialized overload
 
> swap(your_type&, your_type&);
 
This ambiguity issue occurs only in the present rewritting of the
library, all previous versions are fine. So I wonder where went wrong?
And how to fix it from the compiler error report.
 
Rosario19 <Ros@invalid.invalid>: Jun 15 01:01PM +0200

On Thu, 14 Jun 2018 12:17:22 +0200, Rosario19 wrote:
 
 
>[where i64 is a define of one interger type of 64 bit]i think yes...
>what would be the link it is better to follow?
 
>thank you
 
this is the first try but seems something goes wrong...
 
void print(i64& n)
{char p[128];
*p=0;
_i64toa(n, p, 10);
P("%s", p);
}
 
#include <math.h>
 
#define sqrti64(x) ((i64) sqrtl((long double) x) )
#define absi64(x) (x>=0?x:-x)
 
 
class form{
i64 a;
i64 b;
i64 c;
i64 dD;
 
i32 IsReduced(void){i64 t;t=dD-2*absi64(a);R absi64(t)<b && b<dD;}
 
form(){a=b=c=dD=0;}
form(i64 fa, i64 fb, i64 fc){a=fa; b=fb; c=fc; dD=b*b-4*a*c;}
 
void assign(i64 fa, i64 fb, i64 fc){a=fa; b=fb; c=fc;
dD=b*b-4*a*c;}
 
friend ostream& operator<<(ostream& o,const form& x)
{o<<"("<<(long double)x.a<<", "<<(long double)x.b<<", "<<(long
double)x.c<<", "<<(long double)x.dD<<")";
R o;
}
 
friend i32 fr(i64* res, i64& xb, i64& xa, i64& xdD)
{i64 a2,absa,r,k;
 
if(res==0) R -1;
*res=0;
if(xa ==0) R -1;
r=xb; a2=2*xa; absa=absi64(xa);
if(absa==xdD)
{P("errore0"); R -1;}
if(absa>xdD)
{if(xa>0) k=((-xa-xb)/a2)+1;
else k=(( xa-xb)/a2)-1;
r=xb+k*a2;
if(r> absa)
r-=absi64(a2);
if(r> absa)
{ P("errore1 r="); print(r); P(" |a|="); print(absa);
P("\n");
P("k="); print(k); P(" b="); print(xb); P(" a2=");
print(a2); P("\n");
R -1;
}
if(r<=-absa)
{P("errore2");R -1;}
}
else
{if(xa>0) k=((xdD-a2-xb)/a2)+1;
else k=((xdD+a2-xb)/a2)-1;
r=xb+k*a2;
if(r> xdD)
r-=absi64(a2);
if(r> xdD)
{P("errore3"); R -1;}
if(r<=xdD-2*absa)
{P("errore4"); R -1;}
}
*res=r;
R 0;
}
 
 
friend i32 rhoF(form* res, form& f)
{i64 r, r2, fc4;
i32 v;

if(res== 0)R -1;
if(f.c== 0)R -1;
res->a=res->b=res->c=res->dD=0;
r2=-f.b;
v=fr(&r, r2, f.c, f.dD);
if(v ==-1)R -1;
res->a =f.c; res->b=r;
r2=r*r; fc4=4*f.c; res->c =(r2-f.dD)/fc4;
res->dD=r2-fc4*res->c;
R 0;
}
 
 
// suppone che i numeri a esso passato nn siano primi
friend i32 Squfof(i64* res, i64& n)
{i64 xdD,xb,dd,t,x, m, bound, l, gx, b1, ve[512];
i32 r;
u32 i;
form f,g, h;
Mset<i64> buf;

if(n<=1||res==0)R -1;
*res=0; dd=sqrti64(n);
if(dd*dd==n){*res=dd; R 0;}
 
if(n%4==1){xdD= n; m=1; xb=(dd-1)/2; xb=2*xb+1;}
else {xdD=4*n; m=2;dd=sqrti64(xdD); xb= dd /2; xb=2*xb ;}
f.a=1; f.b=xb; f.c=(xb*xb-xdD)/4; l=sqrti64(dd); bound=4*l;
f.dD=xb*xb-4*f.c;
t=absi64( f.c );
if(t==0)R -1;
gx=gcdi64(t,m); gx=t/gx;
buf.assegnaMem(ve, 512);
 
if(gx<=l)
{r=buf.add1(gx);
if(r==-1)R -1;
}
bound=158;
F(i=2;i<bound;++i)
{
r=rhoF(&g,f);
if(r==-1)
R -1;
f=g;
ooo<<"i="<<i<<" f="<<f<<"\n";
if(i%2==0) continue;
if(f.c>=0)
{x=sqrti64(f.c);
if(x<=1) R -1;
if(x*x==abs(f.c) && !buf.is(x))
break;
}
if(f.c==0)
R -1;
gx=absi64(f.c); x=gcdi64(gx,m); gx=gx/x;
if(gx<=l){r=buf.add1(gx);
if(r==-1)
R -1;
}
}
if(i>=bound)
R -1;
h.a=x*f.a; h.b=-f.b; h.c=-f.c; h.dD=h.b*h.b-4*h.a*h.c;
r=rhoF(&g, h);
if(r==-1)
R -1;
la: b1=g.b; r=rhoF(&h, g);
if(r==-1)
R -1;
g=h;if(b1!=g.b)G la;
if(g.c%2==0) g.c=g.c/2;
*res=absi64(g.c); R 0;
}
 
friend i32 squfofM(i64* res, i64 n)
{i64 xdD,xb,dd,t,x, m, bound, l, gx, b1, ve[512];
i32 r;
u32 j, i;
form f,g, h;
Mset<i64> buf;

if(n<=1||res==0)R -1;
*res=0; dd=sqrti64(n);
if(dd*dd==n){*res=dd; R 0;}
if(n%4==1){xdD= n; m=1; xb=(dd-1)/2; xb=2*xb+1;}
else {xdD=4*n; m=2;dd=sqrti64(xdD); xb= dd /2; xb=2*xb ;}
l=sqrti64(dd);
f.a=1; f.b=xb; f.c=(xb*xb-xdD)/4; f.dD=xb*xb-4*f.c;
buf.assegnaMem(ve, 512);
F(i=1;;++i)
{r=rhoF(&g,f);if(r==-1)R -1;f=g;
if(i%2==0&&f.a>=0)
{x=sqrti64(f.a);
if(x*x==f.a)
{if(!buf.is(x)) break; // nn trovato
}
}
x=absi64(f.a);
if(x<=l)
buf.add1(x);
if(i>300)R -1;
}
m=gcdi64(x, f.b); m=gcdi64(m, xdD);
if(m>1){*res=m; R 0;}
g.a=x; g.b=-f.b; g.c=x*f.c; g.dD=g.b*g.b-4*x*g.c;
r=rhoF(&h,g);if(r==-1)R -1;g=h;
la: b1=g.b; r=rhoF(&h, g);if(r==-1)R -1;g=h;if(b1!=g.b)G la;
if(g.a%2==0) g.a=g.a/2;
*res=absi64(g.a);
R 0;
}
 
};
 
#undef sqrti64
#undef absi64
 
i32 main96()
{i64 m1, m2, mm;
u32 i,j;
i32 r;
u8 *pc;
 
mm=633003781;
r=Squfof(&m1, mm);
ooo<<"r="<<r<<" res=";print(m1);P("\n");
R 0;
}
 
but print it give always 2 results
 
i=2 f=(-7125.000000, 633002591.000000, -14059378230867.000,
633003781.000000)
i=3 f=(-14059378230867.000, -633002591.000000, -7125.000000,
633003781.000000)
i=4 f=(-7125.000000, 633002591.000000, -14059378230867.000,
633003781.000000)
i=5 f=(-14059378230867.000, -633002591.000000, -7125.000000,
633003781.000000)
i=6 f=(-7125.000000, 633002591.000000, -14059378230867.000,
633003781.000000)
i=7 f=(-14059378230867.000, -633002591.000000, -7125.000000,
633003781.000000)
i=8 f=(-7125.000000, 633002591.000000, -14059378230867.000,
633003781.000000)
i=9 f=(-14059378230867.000, -633002591.000000, -7125.000000,
633003781.000000)
 
and continue always in this way...
someone know where is the problem?
James Kuyper <jameskuyper@alumni.caltech.edu>: Jun 15 01:12AM -0400

On 06/14/2018 05:30 PM, Paavo Helde wrote:
 
> Of course the tests cannot fully replace the requirements and the
> design, but they can be helpful for maintaining those requirements and
> designs.
 
You're missing my point. I'm not saying that it would be a good idea to
write a test that tested every possible input. I'm saying that a test
which fails to test every possible input cannot justifiably be
interpreted as semantically equivalent to a requirements document in
English that specifies precisely what should be done with every possible
input. A test that only covers a subset of the possible inputs can be
passed by code which does what the English requirements document says it
should do, but only for those inputs; such code would not satisfy the
English requirements, but would satisfy the requirement implicitly
specified by such a test.
"Öö Tiib" <ootiib@hot.ee>: Jun 14 10:45PM -0700

On Thursday, 14 June 2018 21:50:25 UTC+3, James Kuyper wrote:
> encourage people to address each other's points directly, so I can learn
> something about TDD from the discussion other than the fact that some of
> you strongly believe in it, and the others do not.
 
For example my issue with buzzword "TDD" is that the scholars or their
fanboys tend to talk nonsense into it like "testing is designing",
"tests are specification", "coverall" and so on. In outcome that
results with inadequate team composition, overblown expectations, bad
documentation and weak product. Then they search for especially talented
people in hope these do something rather miraculous or heroic about it
and become scammed second time. :D
 
Actual benefits of unit testing must be are quite apparent to everybody.
Thinking how to test the behavior helps to discover gaps in requirements.
Tests reduce need to build and deploy whole product repeatedly.
Tests reduce need of debugger usage or to dig in logs and traces.
Writing tests also helps to think about convenience of unit's interface.
That can save time, reduce frustration, improve reviews and overall
quality and reliability.
 
However nothing magical does happen there, tests are still more code
and that code also contains bugs and has to be maintained together
with product code. That is subject to balance and takes learning
like everything. How to structure and name the tests, how to use the
frameworks, how to make tests simple enough, how to avoid writing
pointless tests, how to keep them deterministic and so on.
Ian Collins <ian-news@hotmail.com>: Jun 15 06:57PM +1200

On 15/06/18 17:12, James Kuyper wrote:
> should do, but only for those inputs; such code would not satisfy the
> English requirements, but would satisfy the requirement implicitly
> specified by such a test.
 
There will always be requirements that cannot be converted into a
manageable set of tests, whether you use TDD or not. These requirements
are hard to validate no matter what the development methodology.
 
There a large set of requirements where tests can and do provide a level
of detail and coverage lacking in the written documents. Most of the
requirements I work with are written by users, they aren't qualified to
write formal requirements but they do know what they want when they see
it. This is why we encourage them to be involved with the acceptance
tests.
 
A recent application I had to produce had a requirement to "monitor a
directory and copy a subdirectory to a remote server when a marker file
in that subdirectory arrives". The requirement was plain and (in the
context of the project) complete and unambiguous. How that requirement
was implemented and how the code responds to a set of possible error
conditions is defined by the tests. The user doesn't care (or may not
even know) about most of the low level failure mechanisms.
 
--
Ian.
"Öö Tiib" <ootiib@hot.ee>: Jun 14 05:32PM -0700

On Thursday, 14 June 2018 22:40:48 UTC+3, David Brown wrote:
> away. If the pointer could legally be null, the check is carried out -
> if you've already demonstrated that it cannot possibly be null, the
> check is skipped. That seems fair enough to me.
 
The logic of those compilers is that it can't legally be null, the same
way as references can not be legally null. The only way a 'this'
can be null is when some code in the program has called nonstatic method
of class through a null-pointer. Doing that is explicitly stated to be
undefined behavior. Unless the implementation has defined it (as an
extension) it may as well optimize such checks out.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: