<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 23, 2022, 17:43 Ondrej Zajicek <<a href="mailto:santiago@crfreenet.org">santiago@crfreenet.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, Feb 23, 2022 at 03:46:53PM +0100, Alexander Zubkov wrote:<br>
> Updated patch. Again full and incremental.<br>
<br>
Thanks, will look at it.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Good. Give me know if some additional work on the patch is needed.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
> > One solution would be a global constant empty trie, so you can just set<br>
> > pointer to that. Alternative would be just have NULL like in T_SET,<br>
> > but that would mean to add several special cases to trie functions,<br>
> > so that is probably worse approach. The difference is that for that<br>
> > trees NULLs are naturally valid values, while tries have header.<br>
> <br>
> OK, created a global constant. There is a pointer to the memory pool<br>
> in the f_trie structure, but I believe it is not used in this case. It<br>
> may be even good to have it set to NULL for this constant in case<br>
> somebody tries to add elements to that trie.<br>
<br>
Agreed.<br>
<br>
<br>
> > > 5) When prefix set variable is assigned an empty set, it is promoted<br>
> > > to the T_PREFIX_SET, of course, but after that it becomes not equal to<br>
> > > "[]", because the type is different. But that can be considered a<br>
> > > feature, not a bug.<br>
> ><br>
> > Yes, if FI_EQ used ARG_SAME_TYPE(), the typecheck would force promotion,<br>
> > but our equality check accepts any pair of objects (and returns false<br>
> > for object of different types instead of failing).<br>
> ><br>
> > I will look into this by implementing some restricted variant of<br>
> > ARG_SAME_TYPE() that forces promotion but otherwise ignores mismatched<br>
> > types.<br>
> <br>
> The other possibility is to alter val_same()/val_compare() functions<br>
> to handle that situation like for quads. It just the matter of what<br>
> behaviour is more preferrable. Current patch has this variant<br>
> implemented taking into account that all empty prefix sets use the<br>
> same emtpy trie constant.<br>
<br>
Well, our plan is to remove all these explicit IP<->quad conversions from<br>
the code and keep just constant promotions, which are handled uniformly<br>
by the static type mechanism. They are still here just because it is minor<br>
backward incompatible change (as constant promotion just promote constants,<br>
while these coversions convert values). So we do not want to add more such<br>
exceptions.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Ok, I get it. Yes, than your variant with promotion is more preferable. Fortunately this exception can be easily dropped from the patch or when promotion is implemented.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
> But altering val_compare() will make the comaprison of typed variables<br>
> with empty sets to be true, for example prefix set with int set. On<br>
> the other hand, currently it does the same with different sets<br>
> represented as T_SET. And as I understand, it is also possible to<br>
> compare an ip set with a quad set.<br>
<br>
The fact that non-prefix sets all use T_SET and are not properly differentiated<br>
by different T_*_SET value is unfortunate limitation, but probably not worth<br>
fixing/handling now.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Yes, I do not see a big problem here either. As you said, tries to compare types, which are different syntactically in the first place, looks strange by itself. And can be prohibited at parse time if needed.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If we turn away from sets to say *lists, we already have different values<br>
for empty clist / eclist / lclist (i.e. returning false for val_same()).<br>
If we ever implement proper literal constants for *lists, then these<br>
empty values would be represented by the same empty literal (instead of<br>
the current adhoc syntax).<br>
<br>
<br>
-- <br>
Elen sila lumenn' omentielvo<br>
<br>
Ondrej 'Santiago' Zajicek (email: <a href="mailto:santiago@crfreenet.org" target="_blank" rel="noreferrer">santiago@crfreenet.org</a>)<br>
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, <a href="http://wwwkeys.pgp.net" rel="noreferrer noreferrer" target="_blank">wwwkeys.pgp.net</a>)<br>
"To err is human -- to blame it on a computer is even more so."<br>
</blockquote></div></div></div>