Wednesday, January 15, 2020

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

woodbrian77@gmail.com: Jan 15 11:21AM -0800

Shalom
 
I was listening to Ben Shapiro's podcast today
and he is talking about the Democratic debate
yesterday. He said that Joe Biden has a tenuous
grasp of reality and that Bernie Sanders has no
grasp of reality "and still lives in cloud cuckoo
land, where Stalin's 5 year plans were actually
excellent."
 
That reminded me of some of the comments I got
here 10+ years ago about my on-line code generator:
https://github.com/Ebenezer-group/onwards
 
It writes low-level code based on high-level
input: <https://github.com/Ebenezer-group/onwards/blob/master/src/cmw/tiers/cmwA.mdl>
 
I'm not sure if any have changed their minds yet,
but on-line code generation is here to stay.
 
 
Brian
Ebenezer Enterprises - If you think Ben Shapiro is simply
a G-dly, thoughtful, intelligent and articulate young man,
you are wrong. He's also a great musician -- check out
his tribute to Game of Thrones.
 
<https://duckduckgo.com/?q=game+thrones+ben++shapiro&atb=v72-1__&iar=videos&iax=videos&ia=videos&iai=WoSvVDQJGv4>
 
 
<https://duckduckgo.com/?q=shapiro+living+dead&iar=videos&iax=videos&ia=videos&iai=T4NhkwWtrMA>
 
Imo, Mr. Shapiro is a modern day Martin Luther King Jr.
He may be even more humble and G-dly than MLK Jr. was.
I can't recommend him enough. He's a G-dsend for all
who care to think about things. That he has received
death threats is so pathetic and twisted. Please pray
for his safety.
Keith Thompson <Keith.S.Thompson+u@gmail.com>: Jan 15 11:38AM -0800


> I was listening to Ben Shapiro's podcast today
> and he is talking about the Democratic debate
> yesterday.
 
This is comp.lang.c++. Please don't post about politics here.
 
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
[Note updated email address]
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
"Öö Tiib" <ootiib@hot.ee>: Jan 15 12:00PM -0800


> I'm not sure if any have changed their minds yet,
> but on-line code generation is here to stay.
 
May be so but your tool generates code for serialization library
that has clearly lost in competition to other such libraries.
 
Your mixed post only causes feeling that you had nothing good
to say about your library and so you filled it with your
cuckoo land politician stories.
 
It is so because mixing politics into your advertisements serves
no rational purpose. Most users of serialization libraries worth
targeting are software craftsmen who will try to be masters of
their trade regardless of what political trends are popular. Most
politically active people OTOH are totally uninterested in
serialization libraries.
Daniel <danielaparker@gmail.com>: Jan 15 02:09PM -0800


> my on-line code generator:
> https://github.com/Ebenezer-group/onwards
 
Is anyone using this? Nobody is raising issues.
 
Daniel
"Öö Tiib" <ootiib@hot.ee>: Jan 15 03:21PM -0800

On Thursday, 16 January 2020 00:09:59 UTC+2, Daniel wrote:
 
> > my on-line code generator:
> > https://github.com/Ebenezer-group/onwards
 
> Is anyone using this? Nobody is raising issues.
 
His serialization format is not even documented. Plus he wants to
keep something of it proprietary and closed source and so there
likely will never be actual users.
 
Everybody are choosing something from list like that:
<https://en.wikipedia.org/wiki/Comparison_of_data-serialization_formats>
All well-documented, several even standardized, plus several have
open source serialization libraries even for multiple programming
languages.
 
He could still maybe generate code for any of those serialization
formats or for any of serialization libraries that use those formats.
Online or offline does not matter. Anyone can put offline tool out
as online service as idle time hobby within weeks.
legalize+jeeves@mail.xmission.com (Richard): Jan 15 09:45PM

[Please do not mail me a copy of your followup]
 
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> spake the secret code
>> declaration are disguised pointers.
 
>A (very) small part of the API is written for use in scripting
>languages. [...]
 
Not that it's relevant to C++, but a huge portion of the API is
available to scripting languages because you can create COM objects
and huge chunks of the Win32 services are exposed as COM objects.
 
Now here's where C++ comes in. If you want to access a chunk of the
Win32 API from script, but there isn't an existing COM object that
exposes that API, you can easily write such a COM object in C++.
 
Also, did you know that Windows ships with a scriptable JavaScript
engine, complete with a visual debugger? No need to keep writing ugly
DOS batch scripts, just use JavaScript. It's been shipping with
Windows for over 15 years, yet developers continue to remain unaware
of it.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
James Kuyper <jameskuyper@alumni.caltech.edu>: Jan 14 09:52PM -0500

On 1/14/20 12:11 PM, Öö Tiib wrote:
> On Tuesday, 14 January 2020 17:30:46 UTC+2, Tim Rentsch wrote:
>> Tiib writes:
 
>>> On Monday, 13 January 2020 19:02:00 UTC+2, Tim Rentsch wrote:
...
 
>> When T1 is 'int' and T2 is 'base' (aka 'struct base'), which of these
>> categories do you think applies?
 
> T1 is also 'base' so (a) applies.
 
No, it isn't. He asked you whether int and struct base are layout
compatible. In terms of his subsequent discussion, that means that T1 is
"int", and nothing else, while T2 is "struct base", and nothing else.
What makes you think you can just randomly replace the correct type with
a different type?
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jan 14 08:58PM -0800

On 1/14/2020 7:05 AM, Tim Rentsch wrote:
 
>> I added in the extraneous base in the union out of some sort of
>> reflex mixed with trying to just read from o.b.
 
> Maybe you were thinking of programming in C.
 
I am a C programmer at heart. The funny part is that I removed the
struct keyword as in writing:
_____________________
struct object_0
{
base b;
int p0;
};
 
// instead of:
 
struct object_0
{
struct base b;
int p0;
};
_____________________
 
:^)
 
 
 
 
 
In C there is often
> benefit to have a "stub" type that serves mainly to differentiate
> the "concrete" types. AFAICT in C++ there is not, except perhaps
> as some sort of aid to the reader.
 
Interesting points to ponder. Actually, a decent chunk of my C++ work in
the past was wrapping up a C API. A lot of times the C API would be
wrapping up some externally assembled, assembly language.
 
For some reason, sometimes, when I created a pure C++ object, I would
code it up in C on my free time. Well, this was a habit wrt interfaces
that need to be exported in a shared lib. A nice clean C API is great
for this. C++ can have some issues wrt creating, say .so, or .dlls.
 
A C binding is okay with me.
"Öö Tiib" <ootiib@hot.ee>: Jan 14 11:15PM -0800

On Wednesday, 15 January 2020 04:52:19 UTC+2, James Kuyper wrote:
> "int", and nothing else, while T2 is "struct base", and nothing else.
> What makes you think you can just randomly replace the correct type with
> a different type?
 
I agree that int and base are not layout compatible standard layout
class types. But it is struct base whose first element that int is
and that base is standard layout class type layout compatible with
base.
 
Yes, it may be that there are some kind of optimization opportunities
when to ignore that the two bases are at same offset and so reorder
reads from and writes to those. Since standard can be (apparently)
interpreted in a way that the two bases are unrelated and such
optimization is allowed then writing to one and reading from other
should not be used anyway.
"Öö Tiib" <ootiib@hot.ee>: Jan 15 01:22AM -0800

On Monday, 13 January 2020 03:28:10 UTC+2, Chris M. Thomasson wrote:
> object_1 o1;
> };
> ________________
 
Actually to get rid of the odd controversy you should go in the
other direction and add more bloat:
 
#include <iostream>

struct base
{
int p0;
};

struct object_0
{
base b;
int p0;
};
 
struct object_1
{
base b;
int p0;
int p1;
};
 
union object
{
struct X {base b;} x;
object_0 o0;
object_1 o1;
};


int main() {
object o;

o.x.b.p0 = 41;
o.o0.b.p0 += 1;
o.o1.b.p0 += 1;
 
// humm
int r = o.x.b.p0; // OK
 
std::cout << "r = " << r << "\n";
 
return 0;
}
 
There are no anonymous structs in C++ so only extensions
of certain compilers make it possible to rewrite in a way
that you can use "o.b.p0" instead of "o.x.b.p0".
James Kuyper <jameskuyper@alumni.caltech.edu>: Jan 15 08:04AM -0500

On 1/15/20 4:22 AM, Öö Tiib wrote:
...
 
> union object
> {
> struct X {base b;} x;
 
Note: the "X" is unnecessary; struct tags are optional, and you have no
need for this one.
 
 
> int main() {
> object o;
 
> o.x.b.p0 = 41;
 
Note: x is also unnecessary; you can simply use o.o0.b.p0 here.
 
> o.o0.b.p0 += 1;
> o.o1.b.p0 += 1;
 
> // humm
 
And also here:
 
"Öö Tiib" <ootiib@hot.ee>: Jan 15 09:38AM -0800

On Wednesday, 15 January 2020 15:05:06 UTC+2, James Kuyper wrote:
> > struct X {base b;} x;
 
> Note: the "X" is unnecessary; struct tags are optional, and you have no
> need for this one.
 
Unnecessary in C. In C++ it has been always needed and even C++20 does
not add anonymous structs.
 
 
> > // humm
 
> And also here:
 
> > int r = o.x.b.p0; // OK
 
You snipped my elaboration that: There are no anonymous structs in C++
so only extensions of certain compilers make it possible to rewrite
in a way that you can use "o.b.p0" instead of "o.x.b.p0".
 
Possibly you used a compiler with such extension and without
-pedantic option when trying it out.
James Kuyper <jameskuyper@alumni.caltech.edu>: Jan 15 11:01AM -0800

> > need for this one.
 
> Unnecessary in C. In C++ it has been always needed and even C++20 does
> not add anonymous structs.
 
That wouldn't be an anonymous struct, it would be an unnamed struct, and
C++ has always had them. "A class-specifier whose class-head omits the
class-head-name defines an unnamed class." (12p1).
Andrew Z <formisc@gmail.com>: Jan 15 07:35AM -0800

On Wednesday, January 1, 2020 at 4:48:46 PM UTC-5, Alf P. Steinbach wrote:
> }
> --------------------------------------------------------------------------
 
> - Alf
 
 
Alf,
thank you very much for the reply. It took me some time to learn all the concepts you used in it. And i'm thankful for that.
 
If i may step back for a moment and describe what im trying to achieve, maybe it will be better, than me asking to "fix my code" .
 
I'm dealing with a number of devices ( outlet, humidity, temp instruments) attached to "Arduino" board.
 
Each device wowuld use 2 routines from RTOS:
Task - https://www.freertos.org/a00125.html
Timer - https://www.freertos.org/FreeRTOS-timers-xTimerCreate.html
 
Timer is used to (re)set a flag;
Task is used to constantly pull the flag value and (once flag changed) activate the device - take a temp/hum measurement etc.
 
I certainly can add both routines ( task and timer) as part (member function) of the device's class.
 
My current idea is to have a routine to create a task and a timer per device - setup_task();
 
Two issues i have:
 
xTaskCreate( ... void *pvParameters... ) - thus i can pass "this" and you already explained how to go about that.
 
TimerHandle_t xTimerCreate
( ..., void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction );
 
has pvTimerID, that theoretically can be used to pass "this".
 
BUT the callback function (TimerCallbackFunction_t pxCallbackFunction) has a predetermine signature:
void vCallbackFunction( TimerHandle_t xTimer );
 
and this is where i'm uncertain how to proceed.
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: