Monday, October 15, 2018

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

Juha Nieminen <nospam@thanks.invalid>: Oct 15 06:37AM

> I am a witness for Jesus Christ in this world,
 
No, what you are is an asshole, and a fucking spammer,
plain and simple.
gazelle@shell.xmission.com (Kenny McCormack): Oct 15 11:48AM

In article <pq1cjd$bv2$2@adenine.netfront.net>,
>> I am a witness for Jesus Christ in this world,
 
>No, what you are is an asshole, and a fucking spammer,
>plain and simple.
 
The two of you (Juha and Rick) have said the same thing - just using
different terminology.
 
Of the two, I prefer Juha's framing, but, again, the content is the same.
 
--
"Only a genius could lose a billion dollars running a casino."
"You know what they say: the house always loses."
"When life gives you lemons, don't pay taxes."
"Grab 'em by the p***y!"
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 15 05:34AM -0700

On Monday, October 15, 2018 at 2:37:42 AM UTC-4, Juha Nieminen wrote:
> > I am a witness for Jesus Christ in this world,
 
> No, what you are is an .. , and a .. spammer,
> plain and simple.
 
Juha, is there any project you are working on that I could lend
my labor to, to help you achieve more in this world than you are
able to do by yourself?
 
I offer my services, skills, talents, knowledge, and abilities
in computer programming, to help you in those things of interest
to you.
 
I want you to thrive, Juha. I'm willing to help you achieve that
goal by giving you my labor.
 
--
Rick C. Hodgin
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 15 05:36AM -0700

On Monday, October 15, 2018 at 7:48:18 AM UTC-4, Kenny McCormack wrote:
 
> The two of you (Juha and Rick) have said the same thing - just using
> different terminology.
 
> Of the two, I prefer Juha's framing, but, again, the content is the same.
 
Kenny, is there anything I can do to help you achieve more
in this world than you are able to do on your own? Do you
have any projects that you need computer programming assist-
ance on? If so, please contact me and I will see if I can
help you.
 
I want to see you doing more and better than you're able to
do by yourself. I offer to give you my service and labor
to help you achieve more.
 
--
Rick C. Hodgin
"Öö Tiib" <ootiib@hot.ee>: Oct 15 06:00AM -0700

On Monday, October 15, 2018 at 3:34:55 PM UTC+3, Rick C. Hodgin wrote:
 
> I offer my services, skills, talents, knowledge, and abilities
> in computer programming, to help you in those things of interest
> to you.
 
How can people measure your talents and abilities? Can you get
your CAlive into state where someone can try to compile something
with it? Some other fruit of yours?
Juha Nieminen <nospam@thanks.invalid>: Oct 15 01:10PM

> Juha, is there any project you are working on that I could lend
> my labor to, to help you achieve more in this world than you are
> able to do by yourself?
 
Yes: Stop spamming this newsgroup with off-topic posts.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 15 09:12AM -0400

On 10/15/2018 9:00 AM, Öö Tiib wrote:
 
> How can people measure your talents and abilities? Can you get
> your CAlive into state where someone can try to compile something
> with it? Some other fruit of yours?
 
It's on its way. People will see the fruit from it in a year or so.
 
As for my talents, I can be given tasks to do and see if I can do
them. I won't blow smoke. I can tell people if I can do something,
if it's outside of my abilities, etc.
 
I just want people to realize my caring for them is sincere.
 
--
Rick C. Hodgin
boltar@cylonhq.com: Oct 15 01:14PM

On Mon, 15 Oct 2018 06:00:25 -0700 (PDT)
>> in computer programming, to help you in those things of interest
>> to you.
 
>How can people measure your talents and abilities? Can you get
 
They wouldn't need to. He'd probably turn up, tell them they'd all burn in
hell unless they devoted themselves to jesus or hired him to help them see
the true faith and the interview would be over.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 15 09:18AM -0400


> They wouldn't need to. He'd probably turn up, tell them they'd all burn in
> hell unless they devoted themselves to jesus or hired him to help them see
> the true faith and the interview would be over.
 
I'm not asking for a job. I'm offering my labor for free to help
people. I'm willing to spend time helping Juha or Kenny improve
their products / tasks / plans / goals, so they can accomplish more
with the assistance than they could do on their own.
 
It's not a for-fee service. It's a gift of free labor, because I
truly care about people and want them to see that love in practice,
and not just in words.
 
--
Rick C. Hodgin
boltar@cylonhq.com: Oct 15 01:35PM

On Mon, 15 Oct 2018 09:18:53 -0400
 
>It's not a for-fee service. It's a gift of free labor, because I
>truly care about people and want them to see that love in practice,
>and not just in words.
 
Nothing is free, even from people like yourself. The price would be having to
listen to you sermonising. You can't yourself.
"Öö Tiib" <ootiib@hot.ee>: Oct 15 06:39AM -0700

On Monday, 15 October 2018 16:12:43 UTC+3, Rick C. Hodgin wrote:
> > your CAlive into state where someone can try to compile something
> > with it? Some other fruit of yours?
 
> It's on its way. People will see the fruit from it in a year or so.
 
I'll ask again in 15. October 2019 then.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 15 09:51AM -0400

>> and not just in words.
 
> Nothing is free, even from people like yourself. The price would be having to
> listen to you sermonising. You can't yourself.
 
No sermons. Military people wear their various badges and insignia
on their uniforms as they go. As I am known as a Christian, so I
would be as I go as well, but it would not be the equivalent of me
pointing to my badges and insignia and saying, "I was awarded this
one for such-and-such activity and such-a-such place." I would
simply be there, doing for the people. Who I am would naturally
carry with me.
 
Boltar, why do you think I reach out to people about the knowledge
of Jesus Christ? Am I doing it to grow my posse? Am I doing it
so people will send me money? Am I doing it for some self-serving
reason? Or am I doing it because people have sin and I want them
to be forgiven and to be saved?
 
Have you ever truly thought about it?
 
--
Rick C. Hodgin
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 15 09:53AM -0400

On 10/15/2018 9:39 AM, Öö Tiib wrote:
>>> with it? Some other fruit of yours?
 
>> It's on its way. People will see the fruit from it in a year or so.
 
> I'll ask again in 15. October 2019 then.
 
You're welcome to come on board and help me with my projects. I do
not have just one. I'm trying to create a full hardware and software
stack, one that is built not on profit-seeking, but one on honoring
the Lord Jesus Christ first, and then being given to people for the
cost of manufacturing and production second. In the software area,
that is for free. In the hardware area, it will be the cost of what-
ever it costs to have the technology manufactured.
 
I'm honestly and truly looking to serve God in this world, by looking
to the people He placed here and serving Him by giving to them in
this world. I'm not duplicitous. I'm sincere in my love for Christ,
and that love applied toward people.
 
You are a great talent based on your posts, Öö Tiib. Your skills
would be put to use if you're interested.
 
--
Rick C. Hodgin
boltar@cylonhq.com: Oct 15 02:00PM

On Mon, 15 Oct 2018 09:51:08 -0400
>reason? Or am I doing it because people have sin and I want them
>to be forgiven and to be saved?
 
>Have you ever truly thought about it?
 
Your reasons are irrelevant. People don't want to be preached at whether it
be from you or from the crazy in the street wearing an End of the World is
Nigh sandwich board.
Dan Purgert <dan@djph.net>: Oct 15 02:40PM

> Your reasons are irrelevant. People don't want to be preached at
> whether it be from you or from the crazy in the street wearing an End
> of the World is Nigh sandwich board.
 
To be fair, that guy at least makes good sandwiches. And if it takes
listening to a little bit of preaching while I wait for my turkey club,
well...
 
 
 
--
|_|O|_| Registered Linux user #585947
|_|_|O| Github: https://github.com/dpurgert
|O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Oct 14 11:47PM -0400

JiiPee wrote:
> so can you give and example how to change that Animal class not to place
> the data there
As written, Animal::age_ is inaccessible from outside the class. When
you decide who is to use it (what methods/classes), you will have better
idea where to put it. If you want age to be accessible for every animal
via a public or protected method, you can leave it in Animal. If all you
are interested in for your interface is talking, you should probably
rename your interface to Talker and move age_ to some LivingThing class
-- that don't even need to have virtuals unless there are other
requirements, thus having something like
class Talker {
public:
virtual void talk() const = 0;
...
};
class LivingThingData {
int age_;
public:
int age() const { return age_; }
};
then,
class Cat: public Talker, private LivingThingData { /* assuming you only
need age inside, say, to decide on the pitch for meowing.. */
};
 
Essentially, analyze business model and separate concerns. I don't think
you can get once-and-for-all "correct" problem decomposition: good model
for a set of requirements may become inadequate as requirements are
added so you have to plan for some rework. The best you can do is to
separate concerns that you know should be separate as of the *current*
set of business requirements.
 
HTH
-Pavel
Juha Nieminen <nospam@thanks.invalid>: Oct 15 06:29AM

> functions, it's no problem to inherit from several of them. If there
> are members, you need virtual inheritance (which is complicated and less
> efficient).
 
No, you don't.
 
You might need virtual inheritance in a case of diamond inheritance.
However, interfaces aren't inherited from a common base class, so
virtual inheritance isn't needed and would do nothing.
Juha Nieminen <nospam@thanks.invalid>: Oct 15 06:33AM

> The term "interface" is terribly overused in various senses and in all
> programming including in C++.
 
It doesn't exactly help that "interface" means in other context simply
the collection of public methods of a class (as in the "public interface"
of the class).
 
"Interface" in those language is really ill-named. Objective-C uses
the term "protocol" instead, which is probably better. (Of course
"protocol" itself is already in use in other contexts, but those
contexts are different enough that it's justifiable.)
David Brown <david.brown@hesbynett.no>: Oct 15 08:46AM +0200

On 15/10/18 08:29, Juha Nieminen wrote:
 
> You might need virtual inheritance in a case of diamond inheritance.
> However, interfaces aren't inherited from a common base class, so
> virtual inheritance isn't needed and would do nothing.
 
You are right - you only need the virtual inheritance if you are getting
the interface (and therefore the same data member) from more than one
ancestor. For some kinds of interface classes that can be likely, so
you might still end up using virtual inheritance just in case.
vambola@proekspert.ee: Oct 15 05:03AM -0700

On Monday, October 15, 2018 at 12:44:59 AM UTC+3, Thiago Adams wrote:
> I am using this pattern (not the C++ version, but the C one,
> with int as tag and switch cases) to implement an AST data
> structure.
 
Lets call your solution with some name? Something like
"intrusive tags"? Then it is easier to reason when things have
names. ;) Modern day often only profiler can tell for sure what
has advantage or disadvantage in fastness in concrete usage
situations. Thinking helps a bit but since compilers are quite
clever now it is often wrong. If it is faster then it can be used
as performance optimization. I don't see how it is simpler.
 
> I cannot have fruit. If we had ICarPart then the glass or tire
> is very coupled with the original problem and is difficult to reuse
> and confuse as well.
 
We can use some problem domain oriented name like
"IPart" for possibly spare parts of different vehicles or
"IConsumable" for stuff that can be possibly eaten by
beings. But we will lose compile-time checking that
"wing" is unacceptable "part" for "car" or "hay" is
unacceptable "food" for "tiger" both with such
interfaces and with your intrusive tagging.
With visitor it is also likely run-time issue, with variant
there is concrete set of types so it is compile-time
issue.
 
> In the AST, one sample is static_assert it can be in different
> positions without any relationship with the other parts.
 
Two things are important: if it is easy to unit-test and
if less skilled programmers can take over its maintenance.
I feel that intrusive tagging can be unit-tested OK but it
takes yourself to be in control over it right now.
 
With AST-like problems I would go with variant anytime,
smaller types directly, bigger, polymorphic and/or recursive
types as (smart)pointer in variant. We can concentrate on
actual features and leave performance questions for later.
 
Code of std::variant is huge but it is mostly compile-time
meta-programming. The external tag of it is not such a
speed or storage issue and the compile-time type safety
defeats lot of issues with clumsy maintenance.
 
> I will consider this solution in many other cases,
> where I am the owner of the types. (I know all types)
 
Yes, I think the weakness is that you have to own the types.
With unknown, future types the options are always limited
to usage of abstract interface classes, clever compile-time
meta-programming, code generators, callbacks, lambdas
and/or std::function. But your intrusive tags can be useful
as performance optimization in implementation details.

 
> The sample is avoiding coupling cause by interfaces.
> I am not using this dynamic_select in any program, but I am
> using the 'dynamic switch selection' in a C program.
 
Yes, in C it makes lot of sense since every data in C is POD
with certain binary layout. In C++ the intrusive tags are tricky
for two reasons:
 
1) Same binary location of tags in objects of different types is
hard to achieve. "Standard layout" is rather restrictive trait.
Otherwise it is undefined behavior. Having special purpose
interface to read the tag (like ITagged) would however defeat
most efficiency advantages. Also dynamic (cross?)casting to
what it apparently leads into can raise major violent
controversy (AKA shitstorm) in some collectives.
 
2) Difference between different tags and equality of tags
to same type in shared library and main program is hard
to achieve automatically. There are no "link-time counters"
or "link-time GUID" in C++. Linking is perhaps mentioned
in less than handful of non-normative comments of
standard. That issue leads either to language extensions
or to code generators.
Thiago Adams <thiago.adams@gmail.com>: Oct 15 05:47AM -0700


> Lets call your solution with some name? Something like
> "intrusive tags"? Then it is easier to reason when things have
> names. ;)
 
OK!
 
> situations. Thinking helps a bit but since compilers are quite
> clever now it is often wrong. If it is faster then it can be used
> as performance optimization. I don't see how it is simpler.
 
I could have used pointer to some function or global variable
like vtable as intrusive tag.
Then the linker would give me a value for the tag and I don't
need to manage unique ids for all objects.
 
But I believe that integers, preferentially sequencial,
can give me the best performance because the compiler will
see the switch case instead of if else if else ..
Also something interesting for performance is when the virtual
function is very small it can be inlined inside the switch.
 
void Shape_Draw(struct Shape* pShape) /*default*/
{
switch (pShape->id)
{
case 2:
Circle_Draw((struct Circle*)pShape);
//could be inlined
break;
case 1:
Box_Draw((struct Box*)pShape);
break;
default:
break;
}
}
 
 
> With visitor it is also likely run-time issue, with variant
> there is concrete set of types so it is compile-time
> issue.
 
Exactly. I realized the collection makes the problem worst
because they create this problem of have a common base interface.
 
Some hierarchies like iostreams doesn't need to worry about
this because this problem would be difficult to happen
in that scenario.
 
In other software I did an interface to represent data source
like IDataSource.
Then I could add more data sources without to have to change
the code that uses data source.
In more than one situation I had to add new function in the
IDataSource interface and implement this function in all types.
But some data sources were not able to implement that function
and I had to return an error.
 
I think this scenario was a good use case for interfaces. But
I am not sure I would try the 'intrusive tag' next time.
The advantage is that we can implement some algorithm selectively.
For instance, a need a new function F that only works for some
types. Then I can implement this diferences (return an error for instance)
in my switch cases without to change the classes that implement
the interface the diferences will be clear at the algorithm itself.
 
The disadvantage of having the switch is manually update.
This is why I think we could have support from the language
and do something like an template instantiation.
 
I already did this in my transpiler.
http://thradams.com/web/cprime.html
See polimorphism sample. The switch is edited by the compiler.
 
 
 
> Yes, in C it makes lot of sense since every data in C is POD
> with certain binary layout. In C++ the intrusive tags are tricky
> for two reasons:
 
In C++ we can have a base class like TaggedObject.
This doesn't create coupling because the object is very
simple.

woodbrian77@gmail.com: Oct 14 07:29PM -0700

On Sunday, October 14, 2018 at 2:56:37 PM UTC-5, Öö Tiib wrote:
> has not been posted. The default argument to A(int) uses comma
> operator to achieve that temporary A with parameter 5 is constructed
> first.
 
I guess this is a "garbagio" constructor.
 
 
Brian
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Oct 15 10:07AM +0100

On Sun, 14 Oct 2018 19:29:32 -0700 (PDT)
> > operator to achieve that temporary A with parameter 5 is constructed
> > first.
 
> I guess this is a "garbagio" constructor.
 
It seems intended as an illustration of how sub-expressions work in
relation to the noexcept keyword.
 
So far as the comma operator is concerned, I don't find myself using
it very often, but one use is in relation to copy constructors. Say you
have a type T with a member 'x' protected by a mutex 'm'. The lifetime
rules for temporaries mean that the following initialization of 'x' is
atomic because the mutex will be remain locked while the initialization
is taking place (the full expression in which the temporary is created
does not expire until initialization of the new 'x' has completed):
 
T(const T& t): x((std::lock_guard(t.m), t.x)) {}
 
This avoids having to first default construct the new 'x' and then
assign to it under the mutex in the constructor.
 
I was somewhat surprised about this when I first came across it, but if
you add some instrumentation it can be seen that it does actually work.
Fraser Ross <fraser.ross8ATbtinternet.com@com>: Oct 15 12:03PM +0100


> Brian
> Ebenezer Enterprises - Enjoy programming again
> http://webEbenezer.net
 
Implicit conversions from int to A has not been mentioned by anyone. It
is not specifically saying anything about that such as with this
theoretical code:
implicit A(int = (A(5),0))noexcept;
Although there is the keyword explicit there is not implicit. Using
implicit would at least suppress warnings if it existed.
 
Fraser.
vambola@proekspert.ee: Oct 15 05:17AM -0700

On Monday, October 15, 2018 at 12:07:30 PM UTC+3, Chris Vine wrote:
 
 
> T(const T& t): x((std::lock_guard(t.m), t.x)) {}
 
> This avoids having to first default construct the new 'x' and then
> assign to it under the mutex in the constructor.
 
If it is really needed then it can lead to someone naively thinking
that ...
 
T(const T& t)
: x((std::lock_guard(t.m), t.x))
, y((std::lock_guard(t.m), t.y))
{}
 
... is also thread-safe and typical surprises about how that T with
broken invariant was constructed. ;-)
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: