Wednesday, June 6, 2018

Digest for comp.programming.threads@googlegroups.com - 4 updates in 4 topics

Sky89 <Sky89@sky68.com>: Jun 05 09:16PM -0400

Hello...
 
 
I think C++ is the future, and i have learned Delphi and FreePascal that
uses modern Object Pascal, and i have coded in C++, and i think i am
understanding more C++, and i think that C++ is "easy" for me because
i am a more experienced computer programmer, and also i found it easy,
and since i am experienced with modern Object Pascal that is good on
readability, modern Object Pascal has learned me to write "clear" code
and less crypted code, so an important requirement is to write
clear code and less crypted code, this is why i am more apt to write
clear C++ code that easy maintenance and that enhance reliability,
also in the last days i have thought about those implicit type
conversions in C++ that were also inherited from C, and i have said to
myself that it is not good for reliability, but as i was learning more
C++ , i have discovered that you can control and disallow those implicit
type conversions as i have showed you in my previous post using operator
overloading etc. and i have also thought about bounds checking on
base arrays in C++, so C++ lacks bounds checking on base arrays,
and this is not good for reliability, so i have discovered that you
can solve this problem by using STL vectors that perform bounds checking
when the .at() member function is called, also
i have thought about integer overflow and underflow and conversion from
negative signed to unsigned , and i have showed
you that you can solve those problems with with C++ SafeInt here:
 
https://github.com/dcleblanc/SafeInt
 
 
So i have finally come to the conclusion that C++ is really powerful,
so i have said that i will continu to bring the best to C++..
 
 
And here is what i wrote on my previous posts about that, read them
carefully to understand me more:
 
I have thought more about C++, and I think C++ is really powerful
because STL vectors perform bounds checking when the .at() member
function is called, and for integer overflow or underflow and conversion
from negative signed to unsigned or more efficient strict-type safety,
here is how to do it with SafeInt here:
 
https://github.com/dcleblanc/SafeInt
 
 
I have just written the following program using SafeInt, please look at
it and try it to notice that C++ is powerful:
 
===
 
#include "SafeInt.hpp"
using namespace std;
#include <climits>
#include <iostream>
#include <sstream>
#include <stdexcept>
 
class my_exception : public std::runtime_error {
std::string msg;
public:
my_exception(const std::string &arg, const char *file, int line) :
std::runtime_error(arg) {
std::ostringstream o;
o << file << ":" << line << ": " << arg;
msg = o.str();
}
~my_exception() throw() {}
const char *what() const throw() {
return msg.c_str();
}
};
 
#define throw_line(arg) throw my_exception(arg, __FILE__, \
__LINE__);
 
 
class CMySafeIntException : public SafeIntException
{
public:
static void SafeIntOnOverflow()
{
cout << "Caught a SafeInt Overflow exception!" << endl;
throw_line("SafeInt exception");
}
static void SafeIntOnDivZero()
{
cout << "Caught a SafeInt Divide By Zero exception!" << endl;
throw_line("SafeInt exception");
}
};
 
void a1(SafeInt<unsigned __int8, CMySafeIntException> a)
{
 
cout << (int)a << endl;
}
 
int main()
{
try {
 
//throw std::invalid_argument("exception");
 
unsigned __int8 i1 = 250;
unsigned __int8 i2 = 150;
SafeInt<unsigned __int8, CMySafeIntException> si1(i1);
SafeInt<unsigned __int8, CMySafeIntException> si2(i2);
SafeInt<unsigned __int8, CMySafeIntException> siResult = si1 + si2;
cout << (int)siResult << endl;
 
 
a1(-1);
 
}
catch (const std::runtime_error &ex) {
std::cout << ex.what() << std::endl;
}
//catch (const std::invalid_argument &ex) {
// std::cout << ex.what() << std::endl;
// }
 
 
}
 
 
====
 
 
 
Also I have said before that C++ allows some "implicit" type conversions
and that is not good, but i have learned more C++ and now i
am understanding it more, and i think C++ is really powerful !
because you can "control" implicit conversins(that means disallowing
implicit conversions) by doing the following in C++, look carefully at
the following C++ code that you can extend:
 
 
===
 
include <iostream>
#include <stdexcept>
 
struct controlled_int {
// allow creation from int
controlled_int(int x) : value_(x) { };
controlled_int& operator=(int x) { value_ = x; return *this; };
// disallow assignment from bool; you might want to use
BOOST_STATIC_ASSERT instead
controlled_int& operator=(bool b) { std::cout << "Exception: Invalid
assignment of bool to controlled_int" << std::endl;
throw; return *this; };
 
// creation from bool shouldn't happen silently
explicit controlled_int(bool b) : value_(b) { };
 
// conversion to int is allowed
operator int() { return value_; };
 
// conversion to bool errors out; you might want to use
BOOST_STATIC_ASSERT instead
 
operator bool() { std::cout << "Invalid conversion of controlled_int
to bool" << std::endl;
// throw std::logic_error("Exception: Invalid conversion of
controlled_int //to bool");
};
 
private:
int value_;
};
 
int main()
{
controlled_int a(42);
 
// This errors out:
// bool b = a;
// This gives an error as well:
a = true;
 
std::cout << "Size of controlled_int: " << sizeof(a) << std::endl;
std::cout << "Size of int: " << sizeof(int) << std::endl;
 
return 0;
}
 
 
===
 
 
 
And as you have noticed i have invented my C++ synchronization objects
library for Windows and Linux here:
 
https://sites.google.com/site/scalable68/c-synchronization-objects-library
 
And i have invented my Scalable Parallel C++ Conjugate Gradient Linear
System Solver Library for Windows and Linux here:
 
https://sites.google.com/site/scalable68/scalable-parallel-c-conjugate-gradient-linear-system-solver-library
 
My next invention that is coming soon is the following:
 
I am finishing a C++ implementation of a "scalable" reference counting
with a "scalable" C++ implementation of shared_ptr and weak_ptr. Because
the implementations in Boost and C++ are "not" scalable. I will bring to
you my new scalable algorithms soon.
 
 
So stay tuned !
 
 
Thank you,
Amine Moulay Ramdane.
Sky89 <Sky89@sky68.com>: Jun 05 08:14PM -0400

Hello...
 
Now that i have understood more C++ that it is really powerful, look
at my previous post about C++ implicit type conversions to notice it,
and i have also said that STL vectors perform bounds checking when the
.at() member function is called, and for integer overflow or underflow
or more efficient strict-type safety, here is how to do it with C++
SafeInt here:
 
https://github.com/dcleblanc/SafeInt
 
So C++ is safe and really powerful, so i will continu to bring the
best to C++..
 
So as you have noticed i have invented my C++ synchronization objects
library for Windows and Linux here:
 
https://sites.google.com/site/scalable68/c-synchronization-objects-library
 
And i have invented my Scalable Parallel C++ Conjugate Gradient Linear
System Solver Library for Windows and Linux here:
 
https://sites.google.com/site/scalable68/scalable-parallel-c-conjugate-gradient-linear-system-solver-library
 
My next invention that is coming soon is the following:
 
I am finishing a C++ implementation of a "scalable" reference counting
with a "scalable" C++ implementation of shared_ptr and weak_ptr. Because
the implementations in Boost and C++ are "not" scalable. I will bring to
you my new scalable algorithms soon.
 
 
So stay tuned !
 
 
Thank you,
Amine Moulay Ramdane.
Sky89 <Sky89@sky68.com>: Jun 05 08:01PM -0400

Hello...
 
I think C++ is really powerful, read the following:
 
I have said before that C++ allows some "implicit" conversions
and that is not good, but i have learned more C++ and now i
am understanding it more, and i think C++ is really powerful !
because you can "control" implicit conversiosn(that means disallowing
implicit conversions) by doing the following in C++, look carefully at
the following C++ code that you can extend:
 
 
===
 
include <iostream>
#include <stdexcept>
 
struct controlled_int {
// allow creation from int
controlled_int(int x) : value_(x) { };
controlled_int& operator=(int x) { value_ = x; return *this; };
// disallow assignment from bool; you might want to use
BOOST_STATIC_ASSERT instead
controlled_int& operator=(bool b) { std::cout << "Exception: Invalid
assignment of bool to controlled_int" << std::endl;
throw; return *this; };
 
// creation from bool shouldn't happen silently
explicit controlled_int(bool b) : value_(b) { };
 
// conversion to int is allowed
operator int() { return value_; };
 
// conversion to bool errors out; you might want to use
BOOST_STATIC_ASSERT instead
 
operator bool() { std::cout << "Invalid conversion of controlled_int
to bool" << std::endl;
// throw std::logic_error("Exception: Invalid conversion of
controlled_int //to bool");
};
 
private:
int value_;
};
 
int main()
{
controlled_int a(42);
 
// This errors out:
// bool b = a;
// This gives an error as well:
a = true;
 
std::cout << "Size of controlled_int: " << sizeof(a) << std::endl;
std::cout << "Size of int: " << sizeof(int) << std::endl;
 
return 0;
}
 
 
===
Sky89 <Sky89@sky68.com>: Jun 05 06:20PM -0400

Hello..
 
 
Microsoft stock up after strong guidance
 
- The company beat estimates on earnings and revenue.
- The Azure cloud had 93 percent revenue growth, which is up from the
previous quarter.
- The company's major More Personal Computing segment included 21
percent revenue growth from Windows commercial products and cloud services.
 
Read more here:
 
https://www.cnbc.com/2018/04/26/microsoft-earnings-q3-2018.html
 
 
Thank you,
Amine Moulay Ramdane.
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.programming.threads+unsubscribe@googlegroups.com.

No comments: