lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, May 23, 2018 at 2:18 PM, Andrew Gierth <andrew@tao11.riddles.org.uk> wrote:
>>>>> "Jon" == Jon Chesterfield <jonathanchesterfield@gmail.com> writes:

 Jon> Good point, well made. ltm.h uses nothing from lstate.h.

Except as already pointed out, it does use G(l) from lstate.h.

Was that pointed out by Ryan? I got the following reply which was difficult to parse. Not sure what gmail is doing here. I get a few hundred emails a day through various mailing lists and only see this on lua-l.

From: Ryan <iggyvolz@gmail.com>
Subject: Re: Circular #include between lstate.h and ltm.h
To: Lua mailing list <lua-l@lists.lua.org>
Message-ID:
        <CAD2kNXC5HmkJNdiAu+EEcOCN1M9bZPjc8Rcv1qxDhg0uTM8jNg@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

QmVjYXVzZSBvZiB0aGUgaWZuZGVmIGd1YXJkLCB0aGUgY29kZSB3aWxsIHN0aWxsIGNvbXBpbGUg
c28gdGhpcyBpcwplc3NlbnRpYWxseSBhIG5vbi1pc3N1ZSAoYXQgbGVhc3QgYXMgZmFyIGFzIGNv
bXBpbGluZykuICBNeSBndWVzcyBpcyB0aGF0CmFueSB0aW1lIG9uZSBvZiB0aG9zZSBpcyBpbmNs
dWRlZCB0aGV5IHdhbnQgYm90aCBvZiB0aGVtIGluY2x1ZGVkLgoKT24gU2F0LCBNYXkgMTksIDIw
MTggYXQgOTo0MyBQTSwgSm9uIENoZXN0ZXJmaWVsZCA8CmpvbmF0aGFuY2hlc3RlcmZpZWxkQGdt
YWlsLmNvbT4gd3JvdGU6Cgo+IEhpLAo+Cj4gSSB3YXMgZGlyZWN0ZWQgaGVyZSBmcm9tIGdpdGh1
YiBodHRwczovL2dpdGh1Yi5jb20vbHVhL2x1YS9wdWxsLzE4Cj4KPiBEZWxldGluZyAjaW5jbHVk
ZSAibHN0YXRlLmgiIGZyb20gbHRtLmggbG9va3MgbGlrZSB0aGUgcmlnaHQgZml4IHRvIG1lLgo+
Cj4gQ2hlZXJzLAo+Cj4gSm9uCj4KLS0tLS0tLS0tLS0tLS0gbmV4dCBwYXJ0IC0tLS0tLS0tLS0t
LS0tCkFuIEhUTUwgYXR0YWNobWVudCB3YXMgc2NydWJiZWQuLi4KVVJMOiBodHRwOi8vbGlzdG1h
c3Rlci5wZXBwZXJmaXNoLm5ldC9jZ2ktYmluL21haWxtYW4vcHJpdmF0ZS9sdWEtbC1saXN0cy5s
dWEub3JnL2F0dGFjaG1lbnRzLzIwMTgwNTE5LzlkZjYyNTFlL2F0dGFjaG1lbnQtMDAwMS5odG1s
Cg==

I missed the macro. So there is an actual cyclic dependency between the headers.

I think I'd be inclined to go with s/gfasttm(G(l), et, e)/gfasttm(l->l_G, et, e)/ to break the cycle.
Otherwise the G() macro could get it's own header that is included in both files with the same effect.

But in fact the inclusion of lstate.h in ltm.h is pointless, because if
you tried to include ltm.h on its own, this would happen:

1. ltm.h defines ltm_h
2. ltm.h includes lstate.h
3. lstate.h includes ltm.h
4. nested include of ltm.h does nothing, because ltm_h is already
   defined
5. lstate.h fails on undefined TM_N


Yes. The C #include model is pretty straightforward. Are we in agreement that cyclic includes are bad and worth removing? It's the only one in your codebase.