<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Thanks, Johanna - I think type_name() may suffice for the purposes I am envisioning.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 16, 2018 at 1:57 PM, Johanna Amann <span dir="ltr">&lt;<a href="mailto:johanna@icir.org" target="_blank">johanna@icir.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Jim,<span class=""><br>
<br>
On 16 Aug 2018, at 13:40, Jim Mellander wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It would be most convenient if the &#39;any&#39; type could defer type checking<br>
until runtime at the script level.<br>
<br>
For instance, if both A &amp; B are defined as type &#39;any&#39;, a compile time error<br>
<br>
&quot;illegal comparison (A &lt; B)&quot;<br>
<br>
occurs upon encountering a bro statement<br>
<br>
if (A &lt; B) do_something();<br>
<br>
even if the actual values stored in A &amp; B at runtime are integral types for<br>
which comparison makes sense.<br>
</blockquote>
<br></span>
I think this is a bit hard to do with how things are set up at the moment internally - and it also does make type-checking at startup less possible-helpful.<br>
<br>
However...<span class=""><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
If the decision could be made at runtime (which could then potentially<br>
throw an error), a number of useful generic functions could be created at<br>
the script level, rather than creating yet-another-bif.  A useful<br>
yet-another-bif would be &#39;typeof&#39; to allow varying code paths based on the<br>
type of value actually stored in &#39;any&#39;.<br>
</blockquote>
<br></span>
This already exists and I think you can actually use it to write code like that; you just have to cast your any-type to the correct type first. The function you want is type_name; it is e.g. used in base/utils/json.bro.<span class="HOEnZb"><font color="#888888"><br>
<br>
Johanna<br>
</font></span></blockquote></div><br></div>