Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C++ templates

78 views
Skip to first unread message

Rick C. Hodgin

unread,
Jan 27, 2017, 10:51:38 AM1/27/17
to
Following a post in comp.lang.c:

https://groups.google.com/d/msg/comp.lang.c/k3mIThpIDlM/hNNnatCPAwAJ

David Brown suggested the concept I convey below is templates, and that
I continue this discussion here:

"The quick answer is 'templates'. Details should probably be taken
to C++, if you really are interested in knowing about them."

The specific portion summed up here:

-----[ Begin ]-----

In the following example, I am able to take a defined block and
copy it into another function so as to prevent the dispatch of
the callback function call:

block my_qsort_compare
{
input left as SStruct1*, right as SStruct1*;

if (left->value > right->value) result = 1;
else if (left->value < right->value) result = -1;
else result = 0;

output result;
}

Then in a modified qsort_block() version, I could provide params:

qsort_block(&data[0], count, data_size,
my_qsort_compare, sizeof(my_qsort_compare));

The qsort_block() function copies in the block of code so that it
doesn't have to issue function call dispatches, but inlines the
logic through some kind of established input and output protocols
where parameters enter and exit knowingly without going through
the stack, but reference wherever they already are in the specific
instance use.

-----[ End ]-----

So ... how do templates allow the my_qsort_compare block of code so
that it could be generated at compile time in a generic manner able
to be copied into qsort_block() (to save the function call overhead)?

Thank you,
Rick C. Hodgin

Mr Flibble

unread,
Jan 27, 2017, 11:46:05 AM1/27/17
to
You see I know the answer to your question but I am not going to give
you it unless you promise to stop with the Christian bullshit posts to
this newsgroup. I hope others will follow my lead.

/Flibble

Rick C. Hodgin

unread,
Jan 27, 2017, 11:52:34 AM1/27/17
to
> you it unless you promise to stop with the Christian .. posts to
> this newsgroup. I hope others will follow my lead.

Your pattern follows a known pattern:
https://groups.google.com/d/msg/comp.arch/vFwmR11a7AE/mDcMFGZ6DwAJ

My pattern also follows a known pattern:
https://groups.google.com/d/msg/comp.arch/vFwmR11a7AE/eM4KQol_DwAJ

Mr. Flibble ... I care too much about you to honor your request, or
Mitch's request.

Rick C. Hodgin

unread,
Jan 27, 2017, 1:36:52 PM1/27/17
to
On Friday, January 27, 2017 at 11:46:05 AM UTC-5, Mr Flibble wrote:
You have been given a lot of information in your life, Leigh. You've
been educated in things, had various jobs, opportunities to personally
study. You've honed your life into a well-powered machine capable of
approaching countless tasks, and mastering them fully. You command a
great set of skills in all you do.

You must come to realize that those were all given to you by God. Even
the times you had to work a job to get money to pay for education, or
whatever it was, God gave you the ability to do all of those things.

He has a plan for you in your life. He has a purpose for you to serve
Him in this world. He has a purpose for all of the skills and crafts
and abilities and knowledge He's given you, and they all involve a
direct purpose and focus on helping other people, and not in hoarding
that knowledge in any capacity.

You will personally be held accountable for what you did with His gifts
to you. By denying me or anyone else the knowledge you were freely
given, you will give an account before God for that decision ... and it
will not bode well for you.

Consider that the next time you have the capacity to help another, and
choose voluntarily to withhold that information.

And FWIW, I forgive you (and Mitch) for not helping me, so you will not
be able to summon me as a witness against you in your case. God Himself
will summon me as a witness, and I will tell Him the truth. But I have
personally discharged you of any wrongness toward me, so you will stand
before Him and Him alone giving an account. I will not accuse you, but
I will be forced to answer His questions truthfully.

Ian Collins

unread,
Jan 27, 2017, 4:35:48 PM1/27/17
to
What he said. You can't flout the Usenet rules of common decency by
spamming and then expect help.

--
Ian

Gareth Owen

unread,
Jan 27, 2017, 4:38:51 PM1/27/17
to
Yeah, I'm with Ian and Mr Flibble

Rick C. Hodgin

unread,
Jan 27, 2017, 4:44:59 PM1/27/17
to
You are not harming me by not helping me, because I am legitimately
coming before you asking for help. But there are potentially many
being harmed by you not helping me. It is not me you will be
accountable two for harming them, but it is your very maker.

It's why I teach you about sin, about the Lord, about forgiveness
and repentance. It's so you won't stand guilty before God, and
will not be injured by your sinful actions. I want you to be
stripped of your sin by Jesus, just as He stripped me of my sin,
so that you and I stand before God faultless, blameless.

I pray you consider deeply these words. Your eternal soul is
riding on whether or not you accept His free offer of forgiveness.

Rick C. Hodgin

unread,
Jan 27, 2017, 4:48:29 PM1/27/17
to
FWIW, I don't think this ability exists in C or C++. I believe this
is a new idea that doesn't have a standard, common, and commensurate
ability in established compilers, toolchains, and OSes.

What's at issue is the ability to leverage the compiler's abilities
to create essentially a block of data which can be wielded as easily
as data, but that it is actually binary code which can be overlain
where needed, replacing a purposefully inserted block of nops, for
example, resulting in code that works without the need for callbacks,
and even with functions linked to at runtime.

For multi-threads you allocate a block for each thread. For single-
threaded apps you can use the one function instance in memory.

I'd be interested to hear if this ability already exists because I
do not believe it does.

Rick C. Hodgin

unread,
Jan 27, 2017, 5:04:31 PM1/27/17
to
This idea also goes along with an idea I had in an extension in
hardware, whereby the move takes place transparently to real memory
as by something called and SMCB protocol:

Hardware Architecture and Self-Modifying Code
https://groups.google.com/d/msg/comp.arch/-T_Gam9_TvY/xZ4hyl1FAAAJ

In this protocol, portions of memory can be overlain over other areas
of memory, effectively allowing for self-modifying code. The hardware
provides facilities which allow this, allowing a single qsort_block()
function to be written and used, with only the relevant compare block
being overlain, and it is done so contextually per thread, and per
instance based on information stored currently on the stack. In this
way the hardware-visible expression of software changes contextually
based on the dynamic runtime needs of the program, yet without actually
affecting the underlying code.

I'm very keen to know if this ability already exists in hardware or
software.

Alf P. Steinbach

unread,
Jan 27, 2017, 6:24:02 PM1/27/17
to
On 27.01.2017 17:45, Mr Flibble wrote:
> On 27/01/2017 15:51, Rick C. Hodgin wrote:
>> [snip] So ... how do templates allow
>
> You see I know the answer to your question but I am not going to give
> you it unless you promise to stop with the Christian bullshit posts to
> this newsgroup. I hope others will follow my lead.

I agree. Rick, you've spammed this group with fundamentalist religious
postings, and you're still doing that, even in a follow-up to Mr.
Sausage here. Of course in a matter of life and death we'll help you,
but not for something less. I guess four months or so of normal behavior
would suffice to forgive (but not forget) your behavior.

Cheers & hth.,

- Alf

Mr Flibble

unread,
Jan 27, 2017, 6:38:30 PM1/27/17
to
Again if you want your questions answered then agree to stop with the
Christian proselyting in this newsgroup. Others agree with me on this.

/Flibble

Rick C. Hodgin

unread,
Jan 27, 2017, 7:05:43 PM1/27/17
to
Allow me to riposte, er ... I mean re-post:

https://groups.google.com/forum/#!msg/comp.arch/vFwmR11a7AE/eM4KQol_DwAJ

-----[ Begin ]-----

You should ask yourself why I post the things I do. Do you think I do
it to be rude? Mean? Hurtful? Demeaning? Is it jusr to troll? Or
is it for another reason? I mean what is the central message I post?

It's this:

I want the absolute best for you.
I want you to live on forever in a body like the angels,
young, fit, strong, beautiful, and without limitation.
I want you to prosper greatly, and to help others prosper
greatly by your gifts and talents being given to them.

Jesus is the only one who can make that happen, and it's because if
what He did at the cross. His blood was shed to save our eternal
souls.

It means so much to each of us ... it must be the focus of our lives.

-----[ End ]-----

Rick C. Hodgin

unread,
Jan 27, 2017, 7:06:15 PM1/27/17
to
You all mean too much to me to disregard you in that way. If you ever
come to faith ... you'll understand why.

Ian Collins

unread,
Jan 28, 2017, 3:46:49 AM1/28/17
to
On 01/28/17 01:06 PM, Rick C. Hodgin wrote:

>
> You all mean too much to me to disregard you in that way.

If others meant as much as you claim, you would stop your antisocial
behaviour in this group. I know reason is generally wasted on fanatics,
but I guess it's worth one last try.

--
Ian

w...@totalbb.net.tw

unread,
Jan 28, 2017, 8:58:57 AM1/28/17
to
For the question first, qsort_block() should be compile time generated, those
arguments, too. I'm less and less using template.

At times, it's good knowing and appreciating the best part of someone's religion. But I think it is impolite if too many.
I just don't want wasting my time seeing this thread.

ruben safir

unread,
Jan 28, 2017, 3:19:29 PM1/28/17
to
don't feed the troll

Rick C. Hodgin

unread,
Jan 28, 2017, 3:35:47 PM1/28/17
to
On Saturday, January 28, 2017 at 8:58:57 AM UTC-5, w...@totalbb.net.tw wrote:
> For the question first, qsort_block() should be compile time generated, those
> arguments, too. I'm less and less using template.

I did a test where the native approach, an inline approach, and a
somewhat modified block {..} approach were compared:

https://groups.google.com/d/msg/comp.lang.c/k3mIThpIDlM/oEUQ4p6RAAAJ

David Brown

unread,
Jan 29, 2017, 4:27:17 PM1/29/17
to
I don't approve of Rick's religious posts any more than anyone else
here. And it is a perfectly reasonable attitude to withhold help to
people who don't follow the rules of a newsgroup, at least roughly.

But Rick did start this thread with a reasonable C++ question. His
religious posting was a follow up to Mr. Flibble's post - which was a
clear and deliberate troll post knowing /exactly/ the reaction he was
going to provoke.

I have no idea what it would take to stop Rick bursting into religious
posts. But I /do/ know that posts like Mr. Flibble's certainly do not help.

0 new messages