Eigenstate: myrddin-dev mailing list

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

Re: Union tag comparison


> Hello,
> 
> Say, I have a 
> type expr = union
>     `Oadd(expr#, expr#)
>     `Oneg(expr#)
> ;;
> 
> I want to compare two expr values to determine whether they are of the same Op.
> As I know, I can define a function that maps each variant into a distinct integer or string.
> But It'd be nice if it can be as simple as how C  does: 'a.Op == b.Op'.
> I am thinking about a builtin function that retrieves the internal integer value of the union tag.
> Am I missing something?

Seems sane-enough. I'd prefer if instead of a function, it was a magic '.tag' member,
kind of like '.len' on arrays.


Follow-Ups:
Re: Union tag comparisonMural <mail@xxxxxxx>
References:
Union tag comparisonMural <mail@xxxxxxx>