Tuesday, June 28, 2016

Digest for comp.lang.c++@googlegroups.com - 9 updates in 4 topics

James Moe <jimoeDESPAM@sohnen-moe.com>: Jun 28 01:16PM -0700

Hello,
A case insensitive substring search: How hard can it be?.
I searched for it. There are lots of case insensitive string searches,
but very few case insensitive substring searches. Nothing that I could
understand.
I came up with the following. It seemed that search_n() was perfect
for a substring search; I just had to supply an appropriate comparison
function. which is where I stalled.
 
bool icompare (unsigned char a, unsigned char b)
{
return (toupper(a) == toupper(b));
}
 
bool strstricmp (string & s1, string & sub2)
{
string::iterator pos;
 
pos = search_n(s1.begin, s1.end(),
1,
sub2,
icompare());
return (pos != s1.end());
}
 
The main problem is what to supply icompare() as parameters? Probably
the wrong choice.
 
This was a cakewalk in C. Creating a C++-worthy function is not so easy.
 
--
James Moe
jmm-list at sohnen-moe dot com
Think.
Ben Bacarisse <ben.usenet@bsb.me.uk>: Jun 28 11:48PM +0100

> I came up with the following. It seemed that search_n() was perfect
> for a substring search; I just had to supply an appropriate comparison
> function. which is where I stalled.
 
You need search, not search_n. And if you are using modern C++ you can
pass a lambda for the comparison function so there is no need for an
extra named function (though that's not a big deal).
 
<snip>
--
Ben.
grizlyk <grizlyk1@yandex.ru>: Jun 28 12:24PM -0700

Concerning implicit template parameter specification.
 
Good day.
1. There is random taken original code
 
//mouse wheel
class Va_mw: public Vaction{
public:
void proceed();
 
Va_mw():key_timer_passed(0){}
 
protected:
//what mouse event to do in child
virtual
void m_event()=0;
 
//repeat time counter
unsigned key_timer_passed;
};
 
//mouse wheel up
class Te_mw_up: public Va_mw{
public:
//on hold
void m_event();
};
 
//mouse wheel dn
class Te_mw_dn: public Va_mw{
public:
//on hold
void m_event();
};
 
The code was redesigned and it was useful to apply template here. If you have questions about template parameter type definition, you can consider the folowing way of the implicit type definition
 
//Ta_mwe::Tevent compile time interface
template<class Tevent>
class Ia_mwe_event{
public:
//void m_event();
typedef
void
(Tevent::* f_m_event)
();
 
public:
Ia_mwe_event(){
f_m_event m_event= &Tevent::m_event;
}
};
 
//mouse wheel up
class Tevent_mw_up{
public:
//on hold
void m_event();
 
protected:
Ia_mwe_event<Tevent_mw_up>
anIevent;
};
 
//mouse wheel
template<class Tevent>
class Ta_mwe: public Vaction{
public:
void proceed();
 
protected:
Tevent e_mw;
 
protected:
Ia_mwe_event<Tevent>
anIevent;
};
 
2. To remove the low level type support code, C++ can be improved.
 
the code above is C++ "allows but does not support" low level implicit way to use the following proposed rules:
 
compile time interface for abstract types of data (ADT)
#//mouse wheel event
#using interface = std::ct_adt_interface;
#interface Ia_mw_event{
#public:
# void m_event();
#};
';' is mandatory here, the same as class scope
 
interface name can be used instead of typeless "class" keyword for template parameter declaration
interface name can be used to specialization of declared typeless "class" template parameter
#//mouse wheel
#template<Ia_mw_event Tevent>
#class Ta_mw: public Vaction{
#public:
#...
 
interface can not be used as run-time template (as ordinary C++ run-time interface "class" does)
because there is no the object in memory as "interface" and object of "interface type" can not be defined
 
abstract types of data itself has no "inheritance" mechanism of class creation of object programming
so interface can not be inherited as ordinary C++ class does
and interface can not be inherited by class syntax to avoid confusing with class specific inheritance rules
 
but abstract types of data itself must have a way to generic use different ADTs with the same methods in code templates
so to declare class, which is complaint an interface, the following syntax must be used
class name [: list of base class](optional) [interface: list of interfaces](optional) [{ class body }](class definition);
#//mouse wheel up
#class Tevent_mw_up
#interface: public Ia_mw_event{
#public:
#...
here class Tevent_mw_up can be used where interface Ia_mw_event does
 
members and types which are declared in an interface must be defined in classes which are complaint the interface
and the interface members can not be removed by class declaration
 
to declare interface, which is complaint the other interface, the following syntax must be used
interface name [interface: list of interfaces](optional) [{ interface body }](interface definition);
#interface Ia_mw_event2
#interface: Ia_mw_event{
#public:
# void m_event2();
#};
here interface Ia_mw_event2 can be used where interface Ia_mw_event does
 
interface can declare other interfaces as members by the following syntax of object definition of "interface type"
#interface Ia_mw_event3{
#public:
# Ia_mw_event a_mw_event;
#};
in classes Ia_mw_event interface type name must be replaced by class type name which are complaint the interface
here Ia_mw_event must not be used as template parameter
because all Ia_mw_event replacements are the same Ia_mw_event3 compile time interface
but template parameters used to create different compile-time interfaces by different parameters with similar compile-time interface
in other words, all compile time interface names "already generic by default"
 
the same example with "template" used for another purpose and the interface definition
will produce set of different compile time interfaces Ia_mw_event4<>, depends on anIa_mw_event
#template<Ia_mw_event anIa_mw_event>
#interface Ia_mw_event4{
#public:
# anIa_mw_event a_mw_event;
#};
 
interface can define internal interfaces as own namespace members with the same generic "interface definition"
 
interface can define own members by exporting member declaration from other interfaces with "using" by the following syntax
using [interface](optional) interface_name;
using interface_name::member_name;
in the case "new" interface is not the same as "used" though has the same members
the way is intended to break links between different classes with similar members by type, but logically not equal ones
interface can explicitly redeclare items inserted by "using" by ordinary rules
 
interface can define own scope member by the following syntax of namespace definition
namespace scope_name{
}
"interface scope" can be accessed with "::" operator like this: "interface_name::scope_name", not by "."
interface scope can define own members by exporting member declaration from other interfaces with "using" keyword
interface can explicitly redeclare items within namespace inserted by "using" by ordinary rules
 
class can include interfaces with "using" keyword for internal purposes
all members of the "using" interface must be declared in the class
but the class will not be complaint the "using" interface
 
changed interface can be added to class outside of class definition by ordinary work with interfaces
which are already declared inside class definition
(work by inherinace existed interface, by include existed interface, etc)
in general case it is prohibited to add changed interfaces to class outside of class definition
 
so in order to add new interfaces to class outside of class definition
in general case you must create new class but the same as existing
but to avoid the useless work with run-time properties of the existing class
there is a way to add new interfaces to class outside of class definition
by the following syntax
interface interface_name = class_name [, class_name](optional);
"interface_name" and "class_name" must be declared (but may be not defined)
"class_name" can be tested for compliant to "interface_name" in the point of both class and interface definition
the same as if "interface_name" was declared inside "class_name" definition
 
PS:
Complete text of the code example can be obtained here http://grizlyk1.narod.ru/cpp_new/msg02/template_interfaces_280616.pdf (only C++ code and C++ improvements rules in english)
 
Best regards.
"J. Clarke" <j.clarke.873638@gmail.com>: Jun 27 09:59PM -0400

In article <be4c8772-84b7-4d08-aa70-acd4496da460@googlegroups.com>,
ootiib@hot.ee says...
> > reflect the age of the language more than it does the quality of it.
 
> Example about nonexistence of programming language is hardly about
> age of it.
 
It is exactly about the age of it. No code was written before it
existed. A little code was written shortly after it existed. More code
was written later.
 
 
> > > 14 years old programming language is not new.
 
> > Cobol is over 50. Fortran is over 60. APL is 52.
 
> What known software is written in those, then? Or are those "too old"?
 
The entire accounting system at my employer for one. The Fortran is
being ported to C, a piece at a time but the Cobol is doing just fine.
The APL is used for the testing that keeps the other code honest.
 
That software is managing a portfolio larger than the GDP of Sweden.
 
Don't assume that the only software that exists is the stuff you find on
github or can buy online. And don't assume that it all runs on PCs and
Linux either.
 
> old programming language. The reason is that you for one consider it too
> new for that. You seemingly even consider about 21 years old Java and
> Python as new. For me tools of that age must be rather mature.
 
No, the reasoning is that arguing quanity of code is pointless.
"Öö Tiib" <ootiib@hot.ee>: Jun 28 12:52AM -0700

On Tuesday, 28 June 2016 04:59:40 UTC+3, J. Clarke wrote:
 
> It is exactly about the age of it. No code was written before it
> existed. A little code was written shortly after it existed. More code
> was written later.
 
That all is true but what has it to do with the usefulness of results
of that writing of code?
 
 
> The entire accounting system at my employer for one. The Fortran is
> being ported to C, a piece at a time but the Cobol is doing just fine.
> The APL is used for the testing that keeps the other code honest.
 
You dodge "known". So how we can judge quality of it?

 
> That software is managing a portfolio larger than the GDP of Sweden.
 
That is perhaps indirect indicator of quality of described software? Not
convincing, sorry.
 
 
> Don't assume that the only software that exists is the stuff you find on
> github or can buy online. And don't assume that it all runs on PCs and
> Linux either.
 
I was not about quantity of code lines that exist and run somewhere.
It is perhaps PHP and Javascript that win that field (despite being "young"
by your standards). Quantity is orthogonal to quality.
 
> > new for that. You seemingly even consider about 21 years old Java and
> > Python as new. For me tools of that age must be rather mature.
 
> No, the reasoning is that arguing quanity of code is pointless.
 
You seem to misunderstand my point and fight with a straw man. I was
writing "what is expressed in it" in meaning "what are the best known pieces
expressed in it". It does not indeed matter how lot of (whatever garbage)
code is written in a language. C# may be indeed wins both C and C++
already on that field despite its younger age.
scott@slp53.sl.home (Scott Lurndal): Jun 28 12:40PM

>> being ported to C, a piece at a time but the Cobol is doing just fine.
>> The APL is used for the testing that keeps the other code honest.
 
>You dodge "known". So how we can judge quality of it?
 
Good grief. The vast majority of software is bespoke.
Ghost <no@spam.net>: Jun 28 10:21AM -0300

Em 27/06/2016 22:59, J. Clarke escreveu:
 
> The entire accounting system at my employer for one. The Fortran is
> being ported to C, a piece at a time but the Cobol is doing just fine.
> The APL is used for the testing that keeps the other code honest.
 
Not assuming that you don't already know, perhaps it is worth mentioning
that the Fortran standard has had a couple of revisions, the latest of
which being called "Modern" Fortran by authors (Fortran 2003 and
Fortran 2008). One notable addition is what the standard calls
/interoperability/ with C, which is a standardized way to link Fortran
code to C code. It is notable that so many Fortran programmers (mostly
nonprofessionals programming academic stuff like myself) are not aware
of the many new additions to the standard, already available in many
compilers.
 
"Öö Tiib" <ootiib@hot.ee>: Jun 28 07:55AM -0700

On Tuesday, 28 June 2016 15:40:20 UTC+3, Scott Lurndal wrote:
> >> The APL is used for the testing that keeps the other code honest.
 
> >You dodge "known". So how we can judge quality of it?
 
> Good grief. The vast majority of software is bespoke.
 
That may be true but is irrelevant. We still can't say how good it is,
even if we know that there are huge amounts of unknown software.
 
Similarly wast majority of what is said in English may be vulgar
nonsense but that does not reduce its usefulness for writing
poetry or scientific papers.
Ghost <no@spam.net>: Jun 28 10:25AM -0300

Em 23/06/2016 14:05, Ghost escreveu:
> that Fortran doesn't have unsigned types.
 
> Any help appreciated.
> Thanks.
 
I should mention that doing this wasn't necessary after all. The
Fortran standard, through its /iso_c_binding/ module, has this
situation covered by means of things like c_ptr and c_funptr.
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: