Saturday, February 27, 2016

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

Jerry Stuckle <jstucklex@attglobal.net>: Feb 27 04:40PM -0500

On 2/27/2016 10:34 AM, David Brown wrote:
> bleeding-edge. (I would prefer not to name the tools as I have only
> helped out another developer here, rather than studying the tool in
> detail.)
 
I remember the Borland Turbo C++ compiler back in the early-mid 90's.
They never admitted they had any bugs in their compilers, but every year
or so they came out with another version (which you had to pay for) that
"fixed" most of the bugs. Except you then had to find a whole new set
of bugs.
 
Plus they charged for reporting a bug. I remember one basic C++ course
where a student's code wasn't working right. In my hotel that night, I
found the problem - he was passing an object by reference, and on return
the object's destructor was called. I called Borland to report it, and
they wanted something like $35 or $40 at that time just to let them know
they had a bug. I didn't pay, but the next version had it fixed. New
bugs in it, though.
 
I actually think this was a big cause of the eventual failure of their
compiler. It was cheap, fast, and once you knew the bugs, pretty good.
But it got a bad reputation for having bugs; one that was only partly
deserved.
 
The bottom line is - you aren't going to hide bugs. They will be found,
and people talk.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Paavo Helde <myfirstname@osa.pri.ee>: Feb 28 12:47AM +0200

On 27.02.2016 23:40, Jerry Stuckle wrote:
> bugs in it, though.
 
> I actually think this was a big cause of the eventual failure of their
> compiler.
 
Except that it is not dead. Nowadays this is called Embarcadero
C++Builder and the last release according to Wikipedia was on 31 Aug.
2015 (C++Builder 10 Seattle (23)).
Jerry Stuckle <jstucklex@attglobal.net>: Feb 27 06:21PM -0500

On 2/27/2016 5:47 PM, Paavo Helde wrote:
 
> Except that it is not dead. Nowadays this is called Embarcadero
> C++Builder and the last release according to Wikipedia was on 31 Aug.
> 2015 (C++Builder 10 Seattle (23)).
 
C++ Builder is a derivative of Turbo C++, but it is not Turbo C++, nor
is it owned by Borland any longer. It has changed significantly since
Borland owned it.
 
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Paavo Helde <myfirstname@osa.pri.ee>: Feb 28 01:33AM +0200

On 28.02.2016 1:21, Jerry Stuckle wrote:
 
> C++ Builder is a derivative of Turbo C++, but it is not Turbo C++, nor
> is it owned by Borland any longer. It has changed significantly since
> Borland owned it.
 
So... and which part of this means "eventual failure of [Turbo C++]"?
 
Of course it has evolved significantly over the years, and there have
been name changes and sell-offs (to shake off some alleged bad
reputation or not, I don't know), but as far as I can see there is no
"eventual failure".
"Öö Tiib" <ootiib@hot.ee>: Feb 27 12:48PM -0800

On Saturday, 27 February 2016 20:55:54 UTC+2, Marcel Mueller wrote:
> agrument below.
> int Arg; ///< Arbitrary argument to the parser function.
> };
 
I see you use string literals to initialize 'Name' so I don't
understand why there is that mutable array and that L, do you want
to dynamically modify it? String literal is guaranteed to live
forever so you could use pointer to it or pointer and length pair.
 
> int in this example. But this is not safe. Mostly the type is some enum.
> But each function takes another argument type, and of course, the third
> argument in the table must match the argument type of the function.
 
Use some type-safe variant then instead of 'int' for example Boost.Variant,
QVariant, Eggs.Variant.
 
> agrument below.
> P Arg; ///< Arbitrary argument to the parser function.
> };
 
That would not be issue if P was a variant not template argument.
'boost::variant<paramtype1,paramtype2,paramtype3>'. You must know
anyway all the different types of parameters when you initialize
that 'opcodeMap' of yours. Btw words like "Map" and "List" may be
misleading in name of variable since readers sometimes assume
underlying container.
 
> another type P in general and all of these structures must fit into the
> same storage. Of course, there is only a solution when sizeof(P) has an
> upper limit, since this is similar to a union.
 
No ... union is not type-safe, it is type-punning.
 
 
> Could this be expressed type safe in C++11, without the need to deal
> with pointers, new and delete for each line?
 
Unfortunately the 'variant' is not in C++11. The proposal of it
N4542 added default empty state to it while 'boost::variant' has
never-empty guarantee (unless you put 'boost::blank' as first type
that is). Huge language lawyer shitstorm and lot of controversy
later it has transformed into P0088R1 so maybe in C++17 we will have
it.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Feb 27 09:58PM +0100

On 27.02.2016 19:55, Marcel Mueller wrote:
> upper limit, since this is similar to a union.
 
> Could this be expressed type safe in C++11, without the need to deal
> with pointers, new and delete for each line?
 
Easy-peasy.
 
struct Op_entry
{
char const* name;
std::function<void()> parser_func;
};
 
// ... later
Op_entry e{ "Blah!", [=](){ Parser::assembleADD( Inst::A_ADD ); } };
 
Hope I got all the braces matched.
 
Cheers & hth.,
 
- Alf
ram@zedat.fu-berlin.de (Stefan Ram): Feb 27 08:24PM

>>Could this be expressed type safe in C++11, without the need to deal
>>with pointers, new and delete for each line?
>You can declare the array under the scope of a template, e.g.:
 
The code compiled, but I can't read out the actual values.
 
The code commented out in the program below results in
linker errors:
 
#include <initializer_list>
#include <iostream>
#include <ostream>
 
enum class my { A_ADD };
 
template< typename T >struct entry{ int tag; T arg; };
 
::std::ostream & operator<<( ::std::ostream & out, ::my const & v )
{ out << "This is a my value.";
/* if( v == ::my::A_ADD )out << "It is ::my::A_ADD."; */
return out; }
 
::std::ostream & operator<<( ::std::ostream & out, ::entry< ::my >const & v )
{ out << "This is an entry with my enum."; return out; }
 
::std::ostream & operator<<( ::std::ostream & out, ::entry< bool >const & v )
{ out << "This is an entry with a bool."; return out; }
 
template< typename T >const entry< T >array[] ={ { 0, ::my::A_ADD },{ 1, false }};
 
int main()
{ /* ::std::cout << array< ::my >[ 0 ].tag<< '\n'; */
::std::cout << array< ::my >[ 0 ].arg<< '\n'; }
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: