@TomyLobo If I recall correctly, you have made those pre-processor directives?
If so, can you make them "nestable"?
I have just noticed my "Deprecated" E2 (utility) library doesn't validate/run because of this (see this part).
Also I have noticed I can't test multiple functions as in:
#ifdef function1() & !function2()
# Stuff...
#endif
-or-
#ifdef function1()
#ifndef function2()
# Stuff...
#endif
#endif
I remember that I tried to add these features, but failed. I don't think it's easily feasible.
you'd need to add kind of a stack there
i think there's a stack class somewhere in wiremod that you can use
I haven't seen Stack that comes with Wire, yet..
Anyways, there is one that comes builtin.
I had one in pure Lua (just can't remember where I have saved it..). But, I guess builtin Stack should be good to go.
I had one in pure Lua (just can't remember where I have saved it..). But, I guess builtin Stack should be good to go.
It is in pure Lua, source
yeah you could use that i guess...
@Divran or is that a bad idea due to people trying to use E2 without gmod?
E2 can't be used without gmod anyway, so that doesn't matter. I'd still not use garry's (probably bad) class though. I'd probably just use a regular lua table as a stack.
I'd still not use garry's (probably bad) class though. I'd probably just use a regular lua table as a stack.
Well I mean, it's not bad in implementation terms, but the methods are pretty much just glorified table operations.
I'd still prefer seeing "local bar = foo.Pop()" to "local bar = foo[#foo] foo[#foo] = nil" everywhere.
Hmm, according to PiL, it's much simpler than that:
https://www.lua.org/pil/19.2.html
"With those two functions, it is straightforward to implement stacks[...]. We can initialize such structures as a = {}. A push operation is equivalent to table.insert(a, x); a pop operation is equivalent to table.remove(a)."
> a={1,2,3,4,5}
> function p(a) for x in ipairs(a) do print(x) end end
> p(a)
1
2
3
4
5
> table.insert(a,6)
> p(a)
1
2
3
4
5
6
> return table.remove(a)
6
> return table.remove(a)
5
> return table.remove(a)
4
> return table.remove(a)
3
> return table.remove(a)
2
> return table.remove(a)
1
> return table.remove(a)
>
So yeah, you can just use table.insert/remove instead of garry's stack
Most helpful comment
Hmm, according to PiL, it's much simpler than that:
https://www.lua.org/pil/19.2.html
"With those two functions, it is straightforward to implement stacks[...]. We can initialize such structures as a = {}. A push operation is equivalent to table.insert(a, x); a pop operation is equivalent to table.remove(a)."
So yeah, you can just use table.insert/remove instead of garry's stack