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

Implicit member structure expansion to encapsulating parent by instance use

129 views
Skip to first unread message

Rick C. Hodgin

unread,
Jan 2, 2018, 9:10:53 AM1/2/18
to
This collision detection algorithm for fir got me thinking about some-
thing.

I wonder if it would be possible to convey to the compiler information
such as a particular instance use of a structure member relates to an
encapsulating structure?

Example:

struct SLinkList
{
struct SLinkList *next;
}

struct SWhatever
{
int a;
int b;
struct SLinkList *ll;
int c;
int d;
};

To be able to tell the compiler that a specific usage of an SLinkList*
is actually passing through an SWhatever:

void my_function(struct SLinkList *p through SWhatever)
{
struct SWhatever *w;

while (p)
{
// Get w relative to p using => bywayof info
w = p=>parent;

// Now, w and p are accessible
}
}

It would be a way to provide additional information the compiler
knows, and knowledge of an instance use of a particular struct,
to allow the compiler to automatically extract out additional
information.

If more than one such member were referenced, it could identify
them distinctly:

struct SWhatever
{
int a;
int b;
struct SLinkList *ll1;
int c;
int d;
struct SLinkList *ll2;
};

// Later usages:
struct SLinkList *p1 through SWhatever:ll1;
struct SLinkList *p2 through SWhatever:ll2;

This information exists at compile time. There should be no reason
it can't be expressed and utilized.

In fir's example, since each object would have a 1:1 ratio with the
elements needed for the link list, the list could just pass through
the object structure, enabling this type of expansion to yield the
object without having to have any additional storage. And by always
inserting new items at the head, there would be no traversal needed
until the final complex collision detection algorithm is applied.

--
Rick C. Hodgin

Rick C. Hodgin

unread,
Jan 2, 2018, 9:17:35 AM1/2/18
to
On 1/2/2018 9:10 AM, Rick C. Hodgin wrote:
> To be able to tell the compiler that a specific usage of an SLinkList*
> is actually passing through an SWhatever:
>
> void my_function(struct SLinkList *p through SWhatever)
> {
> struct SWhatever *w;
>
> while (p)
> {
> // Get w relative to p using => bywayof info
> w = p=>parent;
>
> // Now, w and p are accessible
> }
> }

An optimization for this would be:

struct SLinkList
{
struct SLinkList *next;
}

struct SWhatever
{
int a;
int b;
struct SLinkList *ll;
int c;
int d;
};

To be able to auto-assign the encapsulating structure pointer to a
token, which is automatically available without assignment.

void my_function(struct SLinkList *p through SWhatever *w)
{
while (p)
{
// Now, w and p are accessible
}
}

And in other usage:

> // Later usages:
> struct SLinkList *p1 through SWhatever:ll1;
> struct SLinkList *p2 through SWhatever:ll2;

struct SLinkList *p1 through SWhatever:ll1 *w1;
struct SLinkList *p2 through SWhatever:ll2 *w2;

As p1 is advanced, w1 is automatically available. Same for p2 and w2.

--
Thank you, | Indianapolis, Indiana | God is love -- 1 John 4:7-9
Rick C. Hodgin | http://www.libsf.org/ | http://tinyurl.com/yaogvqhj

Chad

unread,
Jan 2, 2018, 12:03:38 PM1/2/18
to
Can't some of this be achieved by using the vistor pattern?

https://en.m.wikipedia.org/wiki/Visitor_pattern

Chad

unread,
Jan 2, 2018, 12:06:53 PM1/2/18
to
More to the point, couldn't this be done as you traverse the abstract syntax tree?

Melzzzzz

unread,
Jan 2, 2018, 12:07:39 PM1/2/18
to
On 2018-01-02, Chad <cda...@gmail.com> wrote:
> Can't some of this be achieved by using the vistor pattern?
>
> https://en.m.wikipedia.org/wiki/Visitor_pattern

Visitor pattern is just buzzwword for callbacks ;)

--
press any key to continue or any other to quit...

Rick C. Hodgin

unread,
Jan 3, 2018, 9:05:14 AM1/3/18
to
On Tuesday, January 2, 2018 at 9:17:35 AM UTC-5, Rick C. Hodgin wrote:
> An optimization for this would be:
>
> struct SLinkList
> {
> struct SLinkList *next;
> }
>
> struct SWhatever
> {
> int a;
> int b;
> struct SLinkList *ll;
> int c;
> int d;
> };
>
> To be able to auto-assign the encapsulating structure pointer to a
> token, which is automatically available without assignment.
>
> void my_function(struct SLinkList *p through SWhatever *w)
> {
> while (p)
> {
> // Now, w and p are accessible
> }
> }
>
> And in other usage:
>
> > // Later usages:
> > struct SLinkList *p1 through SWhatever:ll1;
> > struct SLinkList *p2 through SWhatever:ll2;
>
> struct SLinkList *p1 through SWhatever:ll1 *w1;
> struct SLinkList *p2 through SWhatever:ll2 *w2;
>
> As p1 is advanced, w1 is automatically available. Same for p2 and w2.

I have added support for this feature to CAlive:

https://groups.google.com/forum/#!topic/caliveprogramminglanguage/aRgfWTL0e0Q

--
Rick C. Hodgin

herrman...@gmail.com

unread,
Jan 4, 2018, 1:41:57 AM1/4/18
to
On Tuesday, January 2, 2018 at 6:10:53 AM UTC-8, Rick C. Hodgin wrote:
> This collision detection algorithm for fir got me thinking about some-
> thing.

> I wonder if it would be possible to convey to the compiler information
> such as a particular instance use of a structure member relates to an
> encapsulating structure?

PL/I has partial qualification for structure references.
(I believe inherited from COBOL.)

In cases that are not ambiguous, you can leave off structure
qualifiers, and the compiler will figure it out.

This is especially useful for COBOL, which has only 1D arrays
(per level of structure). A higher dimensional array can be
created with appropriate structure levels, but that makes for
ugly references. Partial qualification and the ability to move
subscripts, means you can get by with minimal qualification.

I don't know if that helps you, though.

mark.b...@gmail.com

unread,
Jan 4, 2018, 3:51:36 AM1/4/18
to
On Wednesday, 3 January 2018 14:05:14 UTC, Rick C. Hodgin wrote:

> I have added support for this feature to CAlive:

No. You've added yet another thing to your "todo" list.
CAlive only exists as a pipedream.

Kenny McCormack

unread,
Jan 4, 2018, 6:19:29 AM1/4/18
to
In article <faa40359-1089-4ae8...@googlegroups.com>,
Actual implementation would do to his "CAlive" what facts and science
does to his religion. Utterly destroy it.

--
If you don't have faith, it's because you are reading the Bible with an
honest, truthful, real-answer seeking heart.

- Rick C Hodgin -

bartc

unread,
Jan 4, 2018, 6:34:41 AM1/4/18
to
On 04/01/2018 08:51, mark.b...@gmail.com wrote:
> On Wednesday, 3 January 2018 14:05:14 UTC, Rick C. Hodgin wrote:
>
>> I have added support for this feature to CAlive:
>
> No. You've added yet another thing to your "todo" list.

Did anyone understand what the feature was for?

fir

unread,
Jan 4, 2018, 7:03:22 AM1/4/18
to
the great c related improvement you can get is to
filter out idiot hodgin and spare all this wasted time form much better and less donkey-head topics witha word free of at least one malicious idiot... do that, be roesponsible, raise your level of learnig

Rick C. Hodgin

unread,
Jan 4, 2018, 9:34:40 AM1/4/18
to
On Thursday, January 4, 2018 at 6:19:29 AM UTC-5, Kenny McCormack wrote:
> In article <faa40359-1089-4ae8...@googlegroups.com>,
> <mark.b...@gmail.com> wrote:
> >On Wednesday, 3 January 2018 14:05:14 UTC, Rick C. Hodgin wrote:
> >
> >> I have added support for this feature to CAlive:
> >
> >No. You've added yet another thing to your "todo" list.
> >CAlive only exists as a pipedream.
>
> Actual implementation would do to his "CAlive" what facts and science
> does to his religion. Utterly destroy it.

Archaeologists keep finding proof of the Biblical account:

2,700-year-old seal impression cements existence of biblical
Jerusalem governor

https://www.timesofisrael.com/2700-year-old-seal-impression-cements-existence-of-biblical-jerusalem-governor/

Secular evidence that Jesus existed and was crucified:

https://answersingenesis.org/jesus-christ/incarnation/jesus-did-not-exist/

-----[ Begin ]-----
Josephus (AD 37–c.100, Jewish military leader and historian): Wrote about Jesus on two occasions. The authenticity of one occurrence, known as the Testimonium Flavianum, is hotly disputed, but his account of the execution of James is generally accepted, and he mentioned James, “the brother of Jesus who was called the Christ.”

Tacitus (AD 56–120, great Roman historian): Reported that after rumors spread about Nero burning Rome, Nero needed scapegoats for the crime and chose “Christians, [who were] hated for their abominable crimes. Their name comes from Christ, who, during the reign of Tiberius, had been executed by the procurator Pontius Pilate.”

Pliny the Younger (AD 61–c.112, Roman senator): Wrote to Emperor Trajan about his experience with Christians.
-----[ End ]-----

> --
> If you don't have faith, it's because you are reading the Bible with an
> honest, truthful, real-answer seeking heart.
>
> - Rick C Hodgin -

This quote was corrected:

https://groups.google.com/d/msg/comp.lang.c/ZXPVpbmT3Hs/YIUR3lCCBQAJ
https://groups.google.com/d/msg/comp.arch/gL004spHHAE/E_0zlrwYAQAJ

Is all of your research so lacking, Kenny ... that you apply a quote
that was later corrected with citing the correction? Or is your goal
to simply go through life hacking at people with a scythe, trying to
inflict as much damage as possible against those who call upon the name
of Jesus Christ?

The Bible teaches us to establish all things by two or three witnesses,
and to seek the truth in all things. Your pattern has been established.
You seek to do harm, and have no interest in the truth. By your own
well-established witness, you will die in your sin on judgment day ...
unless you repent and ask Jesus to forgive you.

--
Rick C. Hodgin

Alain Ketterlin

unread,
Jan 4, 2018, 9:48:14 AM1/4/18
to
Something the linux kernel has been using for years: get the container
structure when given a pointer to a member. That is how generic
lists/red-black/etc are implemented in the kernel.

https://kernelnewbies.org/FAQ/LinkedLists

I can't see what compiler support would add (besides useless
syntax and complexity).

-- Alain.

Chad

unread,
Jan 4, 2018, 11:16:45 AM1/4/18
to
Here is something I learned at Harvard. Science asks how. Religion asks why. So conflating the two just sounds idiotic at the very best.

Rick C. Hodgin

unread,
Jan 4, 2018, 12:06:36 PM1/4/18
to

Kenny McCormack

unread,
Jan 5, 2018, 12:57:43 PM1/5/18
to
In article <8425b2e9-362c-40cb...@googlegroups.com>,
Rick C. Hodgin <rick.c...@gmail.com> wrote:
...
>> If you don't have faith, it's because you are reading the Bible with an
>> honest, truthful, real-answer seeking heart.
>>
>> - Rick C Hodgin -
>
>This quote was corrected:

You really don't get it, do you?

You simply don't understand that that was your "stopped clock" moment.
That was you, the chronic liar and chronic poster of bullsh*t, actually
posting the truth - if only by accident.

Of course, I'm going to continue to quote the authentic version!

--
Just for a change of pace, this sig is *not* an obscure reference to
comp.lang.c...

Rick C. Hodgin

unread,
Jan 5, 2018, 1:03:05 PM1/5/18
to
On Friday, January 5, 2018 at 12:57:43 PM UTC-5, Kenny McCormack wrote:
> You really don't get it, do you?

I get it. And it causes me to weep for you, Kenny. You have no idea
what's coming. And on that day you will fret and cry out and grasp at
the air trying to prove your innocence or worthiness before God, but
all of your flailings will be for nothing.

Unless you repent of your sin and ask Jesus to forgive you, that final
day will take hold of you like a clamp, and you will be carried through
each component of that time in God's court where the official end of
your existence will be decreed, and the last words written in the book
of your life will be:

And Kenny McCormack was cast into the lake of fire.

There will never be another drop of ink written about you ever again.
The end of Kenny McCormack will have come, and you will be forever
tormented in agony in the flames of Hell because you rejected the
truth, and embraced anti-truth with both arms.

It is why I weep for you. Today, the devil has your number. Also
today, I teach you about how to escape that end. It is only up to
you about which destination you arrive at. Seek forgiveness from
your sin to be saved from Hellfire and you will live. Continue on
as you have, and you will burn.

You have the keys to your fate in your hands, because you have been
told the way of life through forgiveness of sin by Jesus Christ.

-----
You really don't get it, do you? I pray you do, Kenny, BEFORE it's
too late for you.

--
Rick C. Hodgin

Rick C. Hodgin

unread,
Jan 8, 2018, 12:01:13 PM1/8/18
to
On Thursday, January 4, 2018 at 9:48:14 AM UTC-5, Alain Ketterlin wrote:
> bartc <b...@freeuk.com> writes:
> > Did anyone understand what the feature was for?
>
> Something the linux kernel has been using for years: get the container
> structure when given a pointer to a member. That is how generic
> lists/red-black/etc are implemented in the kernel.
>
> https://kernelnewbies.org/FAQ/LinkedLists
>
> I can't see what compiler support would add (besides useless
> syntax and complexity).

At a minimum, it would allow fewer passed parameters in certain cases.

In others, it would aid sanitizers in identifying memory use that's en-
capsulated in other memory uses.

It would also serve as a cue for optimization, such as knowing when all
instances of a given structure (or class in C++) are known to reference
through specific parents, allowing for combination and/or expansions as
appropriate.

--
Rick C. Hodgin

Anton Shepelev

unread,
Jan 8, 2018, 4:14:18 PM1/8/18
to
Melzzzzz:

> Visitor pattern is just buzzwword for callbacks ;)

Is not this true of many other OOP buzzwords, such
as dependency injection, interface, event, straregy
pattern, and adapter pattern?

--
() ascii ribbon campaign -- against html e-mail
/\ http://preview.tinyurl.com/qcy6mjc [archived]

Chad

unread,
Jan 9, 2018, 7:18:07 AM1/9/18
to
On Monday, January 8, 2018 at 1:14:18 PM UTC-8, Anton Shepelev wrote:
> Melzzzzz:
>
> > Visitor pattern is just buzzwword for callbacks ;)
>
> Is not this true of many other OOP buzzwords, such
> as dependency injection, interface, event, straregy
> pattern, and adapter pattern?
>
> --

I don't think using something like the visitor pattern in the context of writing a compiler is OOP in the strictest sense since I don't have to build a lot of the classes. Instead, I just have too make it work. And the thought process behind this seems more procedural than OOPish.

0 new messages