[Bro-Dev] Use of 'any' type
johanna at icir.org
Thu Aug 16 13:57:55 PDT 2018
On 16 Aug 2018, at 13:40, Jim Mellander wrote:
> It would be most convenient if the 'any' type could defer type
> until runtime at the script level.
> For instance, if both A & B are defined as type 'any', a compile time
> "illegal comparison (A < B)"
> occurs upon encountering a bro statement
> if (A < B) do_something();
> even if the actual values stored in A & B at runtime are integral
> types for
> which comparison makes sense.
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
> If the decision could be made at runtime (which could then potentially
> throw an error), a number of useful generic functions could be created
> the script level, rather than creating yet-another-bif. A useful
> yet-another-bif would be 'typeof' to allow varying code paths based on
> type of value actually stored in 'any'.
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
More information about the bro-dev